From a132c4d7f8648278537854ae08a83d704853ed42 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 9 Mar 2021 21:04:51 -0500 Subject: [PATCH] Rebuild against current RL main --- lightning-c-bindings/include/lightning.h | 2254 ++++++++++++++++- lightning-c-bindings/include/lightningpp.hpp | 144 +- lightning-c-bindings/include/rust_types.h | 2 + lightning-c-bindings/src/c_types/derived.rs | 192 ++ .../src/chain/chaininterface.rs | 10 + .../src/chain/chainmonitor.rs | 13 +- .../src/chain/channelmonitor.rs | 77 +- .../src/chain/keysinterface.rs | 66 +- lightning-c-bindings/src/chain/mod.rs | 17 + lightning-c-bindings/src/chain/transaction.rs | 13 +- lightning-c-bindings/src/lib.rs | 1 + lightning-c-bindings/src/ln/chan_utils.rs | 120 +- lightning-c-bindings/src/ln/channelmanager.rs | 50 +- lightning-c-bindings/src/ln/features.rs | 134 +- lightning-c-bindings/src/ln/msgs.rs | 475 +++- lightning-c-bindings/src/ln/peer_handler.rs | 68 +- .../src/routing/network_graph.rs | 97 +- lightning-c-bindings/src/routing/router.rs | 42 +- lightning-c-bindings/src/util/config.rs | 58 +- lightning-c-bindings/src/util/errors.rs | 7 + lightning-c-bindings/src/util/events.rs | 79 + lightning-c-bindings/src/util/logger.rs | 5 + lightning-c-bindings/src/util/macro_logger.rs | 6 - lightning-c-bindings/src/util/mod.rs | 1 - lightning-c-bindings/src/util/ser.rs | 1 + 25 files changed, 3718 insertions(+), 214 deletions(-) delete mode 100644 lightning-c-bindings/src/util/macro_logger.rs diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 94ccb26..5869546 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -266,10 +266,16 @@ typedef struct LDKCResult_PublicKeyErrorZ { */ typedef struct MUST_USE_STRUCT LDKTxCreationKeys { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeTxCreationKeys *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKTxCreationKeys; @@ -280,10 +286,16 @@ typedef struct MUST_USE_STRUCT LDKTxCreationKeys { */ 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; @@ -304,10 +316,16 @@ typedef struct LDKCResult_TxCreationKeysDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKChannelPublicKeys { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelPublicKeys *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKChannelPublicKeys; @@ -338,10 +356,16 @@ typedef struct LDKCResult_TxCreationKeysErrorZ { */ typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeHTLCOutputInCommitment *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKHTLCOutputInCommitment; @@ -362,10 +386,16 @@ typedef struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKCounterpartyChannelTransactionParameters { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeCounterpartyChannelTransactionParameters *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; } LDKCounterpartyChannelTransactionParameters; @@ -390,10 +420,16 @@ typedef struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelTransactionParameters *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; } LDKChannelTransactionParameters; @@ -425,10 +461,16 @@ typedef struct LDKCVec_SignatureZ { */ typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeHolderCommitmentTransaction *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; } LDKHolderCommitmentTransaction; @@ -449,10 +491,16 @@ typedef struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKBuiltCommitmentTransaction { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeBuiltCommitmentTransaction *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; } LDKBuiltCommitmentTransaction; @@ -478,10 +526,16 @@ typedef struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKCommitmentTransaction { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeCommitmentTransaction *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; } LDKCommitmentTransaction; @@ -507,10 +561,16 @@ typedef struct LDKCResult_CommitmentTransactionDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKTrustedCommitmentTransaction { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeTrustedCommitmentTransaction *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; } LDKTrustedCommitmentTransaction; @@ -547,10 +607,16 @@ typedef struct LDKCResult_CVec_SignatureZNoneZ { */ 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. */ 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; } LDKAcceptChannel; @@ -561,10 +627,16 @@ typedef struct MUST_USE_STRUCT LDKAcceptChannel { */ typedef struct MUST_USE_STRUCT LDKOpenChannel { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeOpenChannel *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKOpenChannel; @@ -575,10 +647,16 @@ typedef struct MUST_USE_STRUCT LDKOpenChannel { */ typedef struct MUST_USE_STRUCT LDKFundingCreated { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -589,10 +667,16 @@ typedef struct MUST_USE_STRUCT LDKFundingCreated { */ typedef struct MUST_USE_STRUCT LDKFundingSigned { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeFundingSigned *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKFundingSigned; @@ -603,10 +687,16 @@ typedef struct MUST_USE_STRUCT LDKFundingSigned { */ 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. */ 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; } LDKFundingLocked; @@ -617,10 +707,16 @@ typedef struct MUST_USE_STRUCT LDKFundingLocked { */ typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeAnnouncementSignatures *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKAnnouncementSignatures; @@ -632,10 +728,16 @@ typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { */ typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeCommitmentUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKCommitmentUpdate; @@ -646,10 +748,16 @@ typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { */ 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. */ 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; } LDKRevokeAndACK; @@ -660,10 +768,16 @@ typedef struct MUST_USE_STRUCT LDKRevokeAndACK { */ typedef struct MUST_USE_STRUCT LDKClosingSigned { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeClosingSigned *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKClosingSigned; @@ -674,10 +788,16 @@ typedef struct MUST_USE_STRUCT LDKClosingSigned { */ typedef struct MUST_USE_STRUCT LDKShutdown { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeShutdown *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKShutdown; @@ -688,10 +808,16 @@ typedef struct MUST_USE_STRUCT LDKShutdown { */ 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. */ 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; } LDKChannelReestablish; @@ -702,10 +828,16 @@ typedef struct MUST_USE_STRUCT LDKChannelReestablish { */ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelAnnouncement *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKChannelAnnouncement; @@ -716,10 +848,16 @@ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { */ typedef struct MUST_USE_STRUCT LDKChannelUpdate { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKChannelUpdate; @@ -730,10 +868,16 @@ typedef struct MUST_USE_STRUCT LDKChannelUpdate { */ typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -744,10 +888,16 @@ typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { */ typedef struct MUST_USE_STRUCT LDKErrorMessage { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -774,10 +924,16 @@ typedef enum LDKErrorAction_Tag { } LDKErrorAction_Tag; typedef struct LDKErrorAction_LDKDisconnectPeer_Body { + /** + * An error message which we should make an effort to send before we disconnect. + */ struct LDKErrorMessage msg; } LDKErrorAction_LDKDisconnectPeer_Body; typedef struct LDKErrorAction_LDKSendErrorMessage_Body { + /** + * The message to send. + */ struct LDKErrorMessage msg; } LDKErrorAction_LDKSendErrorMessage_Body; @@ -814,16 +970,34 @@ typedef enum LDKHTLCFailChannelUpdate_Tag { } 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; typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body { + /** + * The node_id that has failed. + */ struct LDKPublicKey node_id; + /** + * 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 + */ bool is_permanent; } LDKHTLCFailChannelUpdate_LDKNodeFailure_Body; @@ -846,10 +1020,16 @@ typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate { */ 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. */ 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; } LDKQueryChannelRange; @@ -867,10 +1047,16 @@ typedef struct MUST_USE_STRUCT LDKQueryChannelRange { */ typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeQueryShortChannelIds *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; } LDKQueryShortChannelIds; @@ -971,89 +1157,188 @@ typedef enum LDKMessageSendEvent_Tag { } LDKMessageSendEvent_Tag; typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { + /** + * The node_id of the node which should receive this message + */ struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ struct LDKAcceptChannel msg; } LDKMessageSendEvent_LDKSendAcceptChannel_Body; typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { + /** + * The node_id of the node which should receive this message + */ struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ struct LDKOpenChannel msg; } LDKMessageSendEvent_LDKSendOpenChannel_Body; typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { + /** + * The node_id of the node which should receive this message + */ struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ struct LDKFundingCreated msg; } LDKMessageSendEvent_LDKSendFundingCreated_Body; typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { + /** + * The node_id of the node which should receive this message + */ struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ struct LDKFundingSigned msg; } LDKMessageSendEvent_LDKSendFundingSigned_Body; typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { + /** + * The node_id of the node which should receive these message(s) + */ struct LDKPublicKey node_id; + /** + * The funding_locked message which should be sent. + */ struct LDKFundingLocked msg; } LDKMessageSendEvent_LDKSendFundingLocked_Body; typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { + /** + * The node_id of the node which should receive these message(s) + */ struct LDKPublicKey node_id; + /** + * The announcement_signatures message which should be sent. + */ struct LDKAnnouncementSignatures msg; } LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { + /** + * The node_id of the node which should receive these message(s) + */ struct LDKPublicKey node_id; + /** + * The update messages which should be sent. ALL messages in the struct should be sent! + */ struct LDKCommitmentUpdate updates; } LDKMessageSendEvent_LDKUpdateHTLCs_Body; typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { + /** + * The node_id of the node which should receive this message + */ struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ 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; typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { + /** + * The node_announcement which should be sent. + */ struct LDKNodeAnnouncement msg; } LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { + /** + * The channel_update which should be sent. + */ struct LDKChannelUpdate msg; } LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; typedef struct LDKMessageSendEvent_LDKHandleError_Body { + /** + * The node_id of the node which should receive this message + */ struct LDKPublicKey node_id; + /** + * The action which should be taken. + */ struct LDKErrorAction action; } LDKMessageSendEvent_LDKHandleError_Body; typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body { + /** + * The channel/node update which should be sent to NetGraphMsgHandler + */ struct LDKHTLCFailChannelUpdate update; } LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body; typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { + /** + * The node_id of this message recipient + */ struct LDKPublicKey node_id; + /** + * The query_channel_range which should be sent. + */ struct LDKQueryChannelRange msg; } LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { + /** + * The node_id of this message recipient + */ struct LDKPublicKey node_id; + /** + * The query_short_channel_ids which should be sent. + */ struct LDKQueryShortChannelIds msg; } LDKMessageSendEvent_LDKSendShortIdsQuery_Body; @@ -1093,10 +1378,16 @@ typedef struct LDKCVec_MessageSendEventZ { */ 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. */ 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; } LDKLightningError; @@ -1153,10 +1444,16 @@ typedef struct LDKCVec_PublicKeyZ { */ 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. */ 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; } LDKPeerHandleError; @@ -1200,10 +1497,16 @@ typedef struct LDKCResult_boolPeerHandleErrorZ { */ typedef struct MUST_USE_STRUCT LDKInitFeatures { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -1224,10 +1527,16 @@ typedef struct LDKCResult_InitFeaturesDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKNodeFeatures { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -1248,10 +1557,16 @@ typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKChannelFeatures { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -1267,16 +1582,52 @@ typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { +/** + * Features used within an invoice. + */ +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. + */ + 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; +} LDKInvoiceFeatures; + +typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { + struct LDKInvoiceFeatures *result; + struct LDKDecodeError *err; +} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; + +typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { + union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; + bool result_ok; +} LDKCResult_InvoiceFeaturesDecodeErrorZ; + + + /** * 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; @@ -1298,10 +1649,16 @@ typedef struct LDKCResult_ChannelConfigDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -1323,10 +1680,16 @@ typedef struct LDKCResult_DirectionalChannelInfoDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKChannelInfo { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -1347,10 +1710,16 @@ typedef struct LDKCResult_ChannelInfoDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKRoutingFees { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -1413,24 +1782,54 @@ typedef enum LDKNetAddress_Tag { } LDKNetAddress_Tag; typedef struct LDKNetAddress_LDKIPv4_Body { + /** + * The 4-byte IPv4 address + */ struct LDKFourBytes addr; + /** + * The port on which the node is listening + */ uint16_t port; } LDKNetAddress_LDKIPv4_Body; typedef struct LDKNetAddress_LDKIPv6_Body { + /** + * The 16-byte IPv6 address + */ struct LDKSixteenBytes addr; + /** + * The port on which the node is listening + */ uint16_t port; } LDKNetAddress_LDKIPv6_Body; typedef struct LDKNetAddress_LDKOnionV2_Body { + /** + * The bytes (usually encoded in base32 with \".onion\" appended) + */ struct LDKTenBytes addr; + /** + * The port on which the node is listening + */ uint16_t port; } LDKNetAddress_LDKOnionV2_Body; typedef struct LDKNetAddress_LDKOnionV3_Body { + /** + * The ed25519 long-term public key of the peer + */ struct LDKThirtyTwoBytes ed25519_pubkey; + /** + * The checksum of the pubkey and version, as included in the onion address + */ uint16_t checksum; + /** + * The version byte, as defined by the Tor Onion v3 spec. + */ uint8_t version; + /** + * The port on which the node is listening + */ uint16_t port; } LDKNetAddress_LDKOnionV3_Body; @@ -1456,10 +1855,16 @@ typedef struct LDKCVec_NetAddressZ { */ 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. */ 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; } LDKNodeAnnouncementInfo; @@ -1485,10 +1890,16 @@ typedef struct LDKCVec_u64Z { */ 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; @@ -1509,10 +1920,16 @@ typedef struct LDKCResult_NodeInfoDecodeErrorZ { */ typedef struct MUST_USE_STRUCT LDKNetworkGraph { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeNetworkGraph *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKNetworkGraph; @@ -1560,10 +1977,16 @@ typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { */ 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. */ 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; } LDKHTLCUpdate; @@ -1577,10 +2000,16 @@ typedef struct MUST_USE_STRUCT LDKHTLCUpdate { */ 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; @@ -1627,10 +2056,16 @@ typedef struct LDKCVec_MonitorEventZ { */ 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. */ 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; } LDKDelayedPaymentOutputDescriptor; @@ -1642,10 +2077,16 @@ typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { */ 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. */ 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; } LDKStaticPaymentOutputDescriptor; @@ -1713,7 +2154,13 @@ typedef enum LDKSpendableOutputDescriptor_Tag { } LDKSpendableOutputDescriptor_Tag; typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { + /** + * The outpoint which is spendable + */ struct LDKOutPoint outpoint; + /** + * The output which is referenced by the given outpoint. + */ struct LDKTxOut output; } LDKSpendableOutputDescriptor_LDKStaticOutput_Body; @@ -1803,37 +2250,98 @@ typedef enum LDKEvent_Tag { } LDKEvent_Tag; typedef struct LDKEvent_LDKFundingGenerationReady_Body { + /** + * The random channel_id we picked which you'll need to pass into + * ChannelManager::funding_transaction_generated. + */ struct LDKThirtyTwoBytes temporary_channel_id; + /** + * The value, in satoshis, that the output should have. + */ uint64_t channel_value_satoshis; + /** + * The script which should be used in the transaction output. + */ struct LDKCVec_u8Z output_script; + /** + * The value passed in to ChannelManager::create_channel + */ uint64_t user_channel_id; } LDKEvent_LDKFundingGenerationReady_Body; typedef struct LDKEvent_LDKFundingBroadcastSafe_Body { + /** + * The output, which was passed to ChannelManager::funding_transaction_generated, which is + * now safe to broadcast. + */ struct LDKOutPoint funding_txo; + /** + * The value passed in to ChannelManager::create_channel + */ uint64_t user_channel_id; } LDKEvent_LDKFundingBroadcastSafe_Body; typedef struct LDKEvent_LDKPaymentReceived_Body { + /** + * The hash for which the preimage should be handed to the ChannelManager. + */ struct LDKThirtyTwoBytes payment_hash; + /** + * 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. + */ struct LDKCVec_SpendableOutputDescriptorZ outputs; } LDKEvent_LDKSpendableOutputs_Body; @@ -1873,10 +2381,16 @@ typedef struct LDKCResult_OutPointDecodeErrorZ { */ 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. */ 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; } LDKChannelMonitorUpdate; @@ -1911,10 +2425,16 @@ typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { */ 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. */ 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; } LDKMonitorUpdateError; @@ -1936,6 +2456,26 @@ typedef struct LDKC2Tuple_OutPointScriptZ { struct LDKCVec_u8Z b; } LDKC2Tuple_OutPointScriptZ; +typedef struct LDKC2Tuple_u32ScriptZ { + uint32_t a; + struct LDKCVec_u8Z b; +} LDKC2Tuple_u32ScriptZ; + +typedef struct LDKCVec_C2Tuple_u32ScriptZZ { + struct LDKC2Tuple_u32ScriptZ *data; + uintptr_t datalen; +} LDKCVec_C2Tuple_u32ScriptZZ; + +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + struct LDKThirtyTwoBytes a; + struct LDKCVec_C2Tuple_u32ScriptZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; + +typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; + typedef struct LDKCVec_TransactionZ { struct LDKTransaction *data; uintptr_t datalen; @@ -1999,10 +2539,16 @@ typedef struct LDKCResult_SignatureNoneZ { */ 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. */ 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; } LDKUnsignedChannelAnnouncement; @@ -2026,6 +2572,10 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { * of LN security model, orthogonal of key management issues. */ 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; /** * Gets the per-commitment point for a specific commitment number @@ -2150,9 +2700,21 @@ typedef struct LDKSign { * Will be called before any signatures are applied. */ void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + /** + * 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); + /** + * Serialize the object into a byte array + */ struct LDKCVec_u8Z (*write)(const void *this_arg); - void (*free)(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; @@ -2177,10 +2739,16 @@ typedef struct LDKSign { */ 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. */ 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; } LDKChannelMonitor; @@ -2257,19 +2825,34 @@ typedef enum LDKAPIError_Tag { } 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; typedef struct LDKAPIError_LDKRouteError_Body { + /** + * A human-readable error message + */ struct LDKStr err; } LDKAPIError_LDKRouteError_Body; typedef struct LDKAPIError_LDKChannelUnavailable_Body { + /** + * A human-readable error message + */ struct LDKCVec_u8Z err; } LDKAPIError_LDKChannelUnavailable_Body; @@ -2313,10 +2896,16 @@ typedef struct LDKCVec_APIErrorZ { */ 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. */ 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; } LDKChannelDetails; @@ -2434,6 +3023,10 @@ typedef struct LDKCVec_ChannelMonitorZ { * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure */ typedef struct LDKWatch { + /** + * 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; /** * Watches a channel identified by `funding_txo` using `monitor`. @@ -2462,6 +3055,10 @@ typedef struct LDKWatch { * events. */ 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; @@ -2469,11 +3066,19 @@ typedef struct LDKWatch { * An interface to send a transaction to the Bitcoin network. */ typedef struct LDKBroadcasterInterface { + /** + * 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; /** * Sends a transaction out to (hopefully) be mined. */ 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; @@ -2496,6 +3101,10 @@ typedef struct LDKu8slice { * A trait to describe an object which can get user secrets and key material. */ typedef struct LDKKeysInterface { + /** + * 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; /** * Get node secret key (aka node_id or network_key). @@ -2542,6 +3151,10 @@ typedef struct LDKKeysInterface { * you've read all of the provided bytes to ensure no corruption occurred. */ struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + /** + * 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); } LDKKeysInterface; @@ -2553,6 +3166,10 @@ typedef struct LDKKeysInterface { * called from inside the library in response to chain events, P2P events, or timer events). */ 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; /** * Gets estimated satoshis of fee required per 1000 Weight-Units. @@ -2565,6 +3182,10 @@ typedef struct LDKFeeEstimator { * * ceil(satoshis-per-kbyte / 4) */ 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; @@ -2572,11 +3193,19 @@ typedef struct LDKFeeEstimator { * A trait encapsulating the operations required of a logger */ 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; /** * Logs the `Record` */ void (*log)(const void *this_arg, const char *record); + /** + * 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); } LDKLogger; @@ -2622,10 +3251,16 @@ typedef struct LDKLogger { */ 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. */ 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; } LDKChannelManager; @@ -2682,10 +3317,16 @@ typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { */ 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. */ 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; } LDKInMemorySigner; @@ -2724,10 +3365,16 @@ typedef struct LDKCResult_TransactionNoneZ { */ typedef struct MUST_USE_STRUCT LDKRouteHop { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeRouteHop *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKRouteHop; @@ -2749,10 +3396,16 @@ typedef struct LDKCVec_CVec_RouteHopZZ { */ 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. */ 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; } LDKRoute; @@ -2773,10 +3426,16 @@ typedef struct LDKCResult_RouteDecodeErrorZ { */ 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. */ 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; } LDKRouteHint; @@ -2822,10 +3481,16 @@ typedef struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ { */ 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; @@ -2841,10 +3506,16 @@ typedef struct LDKCVec_UpdateAddHTLCZ { */ typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeUpdateFulfillHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKUpdateFulfillHTLC; @@ -2860,10 +3531,16 @@ typedef struct LDKCVec_UpdateFulfillHTLCZ { */ typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { /** + * A pointer to the opaque Rust object. * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -2879,10 +3556,16 @@ typedef struct LDKCVec_UpdateFailHTLCZ { */ typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeUpdateFailMalformedHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; @@ -2938,10 +3621,16 @@ typedef struct LDKCResult_ClosingSignedDecodeErrorZ { */ 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; @@ -2992,10 +3681,16 @@ typedef struct LDKCResult_FundingLockedDecodeErrorZ { */ 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. */ 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; } LDKInit; @@ -3066,10 +3761,16 @@ typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { */ 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; @@ -3110,10 +3811,16 @@ typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { */ 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. */ 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; } LDKPing; @@ -3134,10 +3841,16 @@ typedef struct LDKCResult_PingDecodeErrorZ { */ 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. */ 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; } LDKPong; @@ -3178,10 +3891,16 @@ typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { */ 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; @@ -3222,10 +3941,16 @@ typedef struct LDKCResult_ErrorMessageDecodeErrorZ { */ 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; @@ -3269,10 +3994,16 @@ typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { */ 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. */ 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; } LDKReplyShortChannelIdsEnd; @@ -3309,10 +4040,16 @@ typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { */ 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. */ 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; } LDKReplyChannelRange; @@ -3335,10 +4072,16 @@ typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { */ 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; @@ -3356,12 +4099,20 @@ typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { * A trait indicating an object may generate message send events */ typedef struct LDKMessageSendEventsProvider { + /** + * 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; /** * Gets the list of pending events which were generated by previous actions, clearing the list * in the process. */ struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_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); } LDKMessageSendEventsProvider; @@ -3369,12 +4120,20 @@ typedef struct LDKMessageSendEventsProvider { * A trait indicating an object may generate events */ typedef struct LDKEventsProvider { + /** + * 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; /** * Gets the list of pending events which were generated by previous actions, clearing the list * in the process. */ struct LDKCVec_EventZ (*get_and_clear_pending_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); } LDKEventsProvider; @@ -3387,10 +4146,16 @@ typedef struct LDKEventsProvider { */ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelHandshakeConfig *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKChannelHandshakeConfig; @@ -3411,10 +4176,16 @@ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { */ typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelHandshakeLimits *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKChannelHandshakeLimits; @@ -3428,10 +4199,16 @@ typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { */ typedef struct MUST_USE_STRUCT LDKUserConfig { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeUserConfig *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKUserConfig; @@ -3440,6 +4217,10 @@ typedef struct MUST_USE_STRUCT LDKUserConfig { * UTXOs. */ typedef struct LDKAccess { + /** + * 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; /** * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. @@ -3449,6 +4230,10 @@ typedef struct LDKAccess { * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id */ struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); + /** + * 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); } LDKAccess; @@ -3459,6 +4244,10 @@ typedef struct LDKAccess { * Useful when needing to replay chain data upon startup or as new chain events occur. */ typedef struct LDKListen { + /** + * 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; /** * Notifies the listener that a block was added at the given height. @@ -3468,6 +4257,10 @@ typedef struct LDKListen { * Notifies the listener that a block was removed at the given height. */ void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + /** + * 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); } LDKListen; @@ -3495,6 +4288,10 @@ typedef struct LDKListen { * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki */ typedef struct LDKFilter { + /** + * 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; /** * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as @@ -3506,6 +4303,10 @@ typedef struct LDKFilter { * `script_pubkey` as the spending condition. */ void (*register_output)(const void *this_arg, const struct LDKOutPoint *NONNULL_PTR outpoint, struct LDKu8slice script_pubkey); + /** + * 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); } LDKFilter; @@ -3523,6 +4324,10 @@ typedef struct LDKFilter { * kept up-to-date. */ typedef struct LDKPersist { + /** + * 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; /** * Persist a new channel's data. The data can be stored any way you want, but @@ -3568,6 +4373,10 @@ typedef struct LDKPersist { * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html */ struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data); + /** + * 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); } LDKPersist; @@ -3587,10 +4396,16 @@ typedef struct LDKPersist { */ typedef struct MUST_USE_STRUCT LDKChainMonitor { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChainMonitor *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; } LDKChainMonitor; @@ -3607,10 +4422,16 @@ typedef struct MUST_USE_STRUCT LDKChainMonitor { */ typedef struct MUST_USE_STRUCT LDKKeysManager { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeKeysManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKKeysManager; @@ -3625,10 +4446,16 @@ typedef struct MUST_USE_STRUCT LDKKeysManager { */ typedef struct MUST_USE_STRUCT LDKChainParameters { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChainParameters *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; } LDKChainParameters; @@ -3643,6 +4470,10 @@ typedef struct LDKThreeBytes { * they MUST NOT be called in parallel when the two calls have the same their_node_id. */ typedef struct LDKChannelMessageHandler { + /** + * 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; /** * Handle an incoming open_channel message from the given peer. @@ -3723,7 +4554,14 @@ typedef struct LDKChannelMessageHandler { * Handle an incoming error message from the given peer. */ void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + /** + * Implementation of MessageSendEventsProvider for this object. + */ struct LDKMessageSendEventsProvider 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. + */ void (*free)(void *this_arg); } LDKChannelMessageHandler; @@ -3758,10 +4596,16 @@ typedef struct LDKChannelMessageHandler { */ typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeChannelManagerReadArgs *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKChannelManagerReadArgs; @@ -3775,10 +4619,16 @@ typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { */ typedef struct MUST_USE_STRUCT LDKDataLossProtect { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeDataLossProtect *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKDataLossProtect; @@ -3792,6 +4642,10 @@ typedef struct MUST_USE_STRUCT LDKDataLossProtect { * repeated disk I/O for queries accessing different parts of the network graph. */ typedef struct LDKRoutingMessageHandler { + /** + * 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; /** * Handle an incoming node_announcement message, returning true if it should be forwarded on, @@ -3854,7 +4708,14 @@ typedef struct LDKRoutingMessageHandler { * list of short_channel_ids. */ struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + /** + * Implementation of MessageSendEventsProvider for this object. + */ struct LDKMessageSendEventsProvider 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. + */ void (*free)(void *this_arg); } LDKRoutingMessageHandler; @@ -3866,10 +4727,16 @@ typedef struct LDKRoutingMessageHandler { */ typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeIgnoringMessageHandler *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; } LDKIgnoringMessageHandler; @@ -3881,10 +4748,16 @@ typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { */ typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeErroringMessageHandler *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; } LDKErroringMessageHandler; @@ -3895,10 +4768,16 @@ typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { */ typedef struct MUST_USE_STRUCT LDKMessageHandler { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKMessageHandler; @@ -3916,6 +4795,10 @@ typedef struct MUST_USE_STRUCT LDKMessageHandler { * PeerManager::socket_disconnected(). */ typedef struct LDKSocketDescriptor { + /** + * 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; /** * Attempts to send some data from the given slice to the peer. @@ -3942,9 +4825,25 @@ typedef struct LDKSocketDescriptor { * socket_disconnected but prior to socket_disconnected returning. */ void (*disconnect_socket)(void *this_arg); + /** + * Checks if two objects are equal given this object's this_arg pointer and another object. + */ bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + /** + * 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. + */ uint64_t (*hash)(const void *this_arg); + /** + * 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. + */ 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); } LDKSocketDescriptor; @@ -3962,10 +4861,16 @@ typedef struct LDKSocketDescriptor { */ typedef struct MUST_USE_STRUCT LDKPeerManager { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativePeerManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKPeerManager; @@ -3980,10 +4885,16 @@ typedef struct MUST_USE_STRUCT LDKPeerManager { */ typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeDirectedChannelTransactionParameters *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; } LDKDirectedChannelTransactionParameters; @@ -3996,10 +4907,16 @@ typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { */ typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph { /** + * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativeLockedNetworkGraph *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; } LDKLockedNetworkGraph; @@ -4014,10 +4931,16 @@ typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph { */ 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; @@ -4207,6 +5130,12 @@ struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeError void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); + +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); + struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); @@ -4323,6 +5252,20 @@ struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); + +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); + +void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); + +void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); + +struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); + +void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); + +void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); + void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); @@ -4751,14 +5694,29 @@ void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTime struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); +/** + * Frees any resources used by the Event + */ void Event_free(struct LDKEvent this_ptr); +/** + * Creates a copy of the Event + */ struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +/** + * Serialize the Event object into a byte array which can be read by Event_read + */ struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +/** + * Frees any resources used by the MessageSendEvent + */ void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +/** + * Creates a copy of the MessageSendEvent + */ struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); /** @@ -4771,10 +5729,19 @@ void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr */ void EventsProvider_free(struct LDKEventsProvider this_ptr); +/** + * Frees any resources used by the APIError + */ void APIError_free(struct LDKAPIError this_ptr); +/** + * Creates a copy of the APIError + */ struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); +/** + * Creates a copy of the Level + */ enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); /** @@ -4787,7 +5754,10 @@ MUST_USE_RES enum LDKLevel Level_max(void); */ void Logger_free(struct LDKLogger this_ptr); -void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_ptr); +/** + * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. + */ +void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); /** * Confirmations we will wait for before considering the channel locked in. @@ -4861,13 +5831,25 @@ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChanne */ void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); +/** + * Constructs a new ChannelHandshakeConfig given each field + */ MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg); +/** + * Creates a copy of the ChannelHandshakeConfig + */ struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); +/** + * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. + */ MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); -void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_ptr); +/** + * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. + */ +void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); /** * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so @@ -5039,8 +6021,8 @@ void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKCha * Not checking this value would be a security issue, as our peer would be able to set it to * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. * - * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value - * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) + * 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) */ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -5050,18 +6032,30 @@ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelH * Not checking this value would be a security issue, as our peer would be able to set it to * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. * - * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value - * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) + * 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) */ void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +/** + * Constructs a new ChannelHandshakeLimits given each field + */ MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); +/** + * Creates a copy of the ChannelHandshakeLimits + */ struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); +/** + * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. + */ MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); -void ChannelConfig_free(struct LDKChannelConfig this_ptr); +/** + * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. + */ +void ChannelConfig_free(struct LDKChannelConfig this_obj); /** * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. @@ -5141,17 +6135,35 @@ bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelCon */ void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); +/** + * Constructs a new ChannelConfig given each field + */ MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); +/** + * Creates a copy of the ChannelConfig + */ struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); +/** + * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. + */ MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); +/** + * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read + */ struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); +/** + * Read a ChannelConfig from a byte array, created by ChannelConfig_write + */ struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); -void UserConfig_free(struct LDKUserConfig this_ptr); +/** + * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. + */ +void UserConfig_free(struct LDKUserConfig this_obj); /** * Channel config that we propose to our counterparty. @@ -5183,12 +6195,24 @@ struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfi */ void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +/** + * Constructs a new UserConfig given each field + */ MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg); +/** + * Creates a copy of the UserConfig + */ struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); +/** + * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. + */ MUST_USE_RES struct LDKUserConfig UserConfig_default(void); +/** + * Creates a copy of the AccessError + */ enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); /** @@ -5216,6 +6240,9 @@ void Filter_free(struct LDKFilter this_ptr); */ void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); +/** + * Creates a copy of the ConfirmationTarget + */ enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); /** @@ -5223,7 +6250,10 @@ enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTa */ void FeeEstimator_free(struct LDKFeeEstimator this_ptr); -void ChainMonitor_free(struct LDKChainMonitor this_ptr); +/** + * Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. + */ +void ChainMonitor_free(struct LDKChainMonitor this_obj); /** * Dispatches to per-channel monitors, which are responsible for updating their on-chain view @@ -5264,11 +6294,22 @@ void ChainMonitor_block_disconnected(const struct LDKChainMonitor *NONNULL_PTR t */ MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); +/** + * 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 + */ struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); -void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_ptr); +/** + * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. + */ +void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); /** * The sequence number of this update. Updates *must* be replayed in-order according to this @@ -5304,32 +6345,74 @@ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate */ void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); +/** + * Creates a copy of the ChannelMonitorUpdate + */ struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); +/** + * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read + */ struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); +/** + * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write + */ struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); +/** + * Creates a copy of the ChannelMonitorUpdateErr + */ enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig); -void MonitorUpdateError_free(struct LDKMonitorUpdateError this_ptr); +/** + * Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL. + */ +void MonitorUpdateError_free(struct LDKMonitorUpdateError this_obj); +/** + * Creates a copy of the MonitorUpdateError + */ struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig); +/** + * Frees any resources used by the MonitorEvent + */ void MonitorEvent_free(struct LDKMonitorEvent this_ptr); +/** + * Creates a copy of the MonitorEvent + */ struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); -void HTLCUpdate_free(struct LDKHTLCUpdate this_ptr); +/** + * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. + */ +void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); +/** + * Creates a copy of the HTLCUpdate + */ struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); +/** + * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read + */ struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); +/** + * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write + */ struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); -void ChannelMonitor_free(struct LDKChannelMonitor this_ptr); +/** + * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. + */ +void ChannelMonitor_free(struct LDKChannelMonitor this_obj); +/** + * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read + */ struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); /** @@ -5352,9 +6435,22 @@ MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChanne MUST_USE_RES struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * 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`]. - * + * 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_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + +/** + * 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. + */ +void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR 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`]. + * * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events */ MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); @@ -5408,9 +6504,15 @@ void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_P */ void Persist_free(struct LDKPersist this_ptr); +/** + * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write + */ struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); -void OutPoint_free(struct LDKOutPoint this_ptr); +/** + * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. + */ +void OutPoint_free(struct LDKOutPoint this_obj); /** * The referenced transaction's txid. @@ -5432,8 +6534,14 @@ uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); */ void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); +/** + * Constructs a new OutPoint given each field + */ MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); +/** + * Creates a copy of the OutPoint + */ struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); /** @@ -5441,11 +6549,20 @@ struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); */ MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); +/** + * Serialize the OutPoint object into a byte array which can be read by OutPoint_read + */ struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); +/** + * Read a OutPoint from a byte array, created by OutPoint_write + */ struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_ptr); +/** + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + */ +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** * The outpoint which is spendable @@ -5520,11 +6637,20 @@ uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct */ void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +/** + * Constructs a new DelayedPaymentOutputDescriptor given each field + */ MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +/** + * Creates a copy of the DelayedPaymentOutputDescriptor + */ struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_ptr); +/** + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + */ +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** * The outpoint which is spendable @@ -5565,18 +6691,39 @@ uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct L */ void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +/** + * Constructs a new StaticPaymentOutputDescriptor given each field + */ MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +/** + * Creates a copy of the StaticPaymentOutputDescriptor + */ struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +/** + * Frees any resources used by the SpendableOutputDescriptor + */ void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +/** + * Creates a copy of the SpendableOutputDescriptor + */ struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +/** + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + */ struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +/** + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + */ struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +/** + * Creates a copy of a Sign + */ struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); /** @@ -5589,7 +6736,10 @@ void Sign_free(struct LDKSign this_ptr); */ void KeysInterface_free(struct LDKKeysInterface this_ptr); -void InMemorySigner_free(struct LDKInMemorySigner this_ptr); +/** + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + */ +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** * Private key of anchor tx @@ -5651,6 +6801,9 @@ const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigne */ void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Creates a copy of the InMemorySigner + */ struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** @@ -5719,13 +6872,26 @@ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterpa */ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +/** + * 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 + */ struct LDKSign InMemorySigner_as_Sign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +/** + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + */ struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +/** + * Read a InMemorySigner from a byte array, created by InMemorySigner_write + */ struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser); -void KeysManager_free(struct LDKKeysManager this_ptr); +/** + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + */ +void KeysManager_free(struct LDKKeysManager this_obj); /** * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your @@ -5774,11 +6940,21 @@ MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const stru */ MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight); +/** + * 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 + */ struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg); -void ChannelManager_free(struct LDKChannelManager this_ptr); +/** + * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. + */ +void ChannelManager_free(struct LDKChannelManager this_obj); -void ChainParameters_free(struct LDKChainParameters this_ptr); +/** + * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. + */ +void ChainParameters_free(struct LDKChainParameters this_obj); /** * The network for determining the `chain_hash` in Lightning messages. @@ -5814,9 +6990,15 @@ uintptr_t ChainParameters_get_latest_height(const struct LDKChainParameters *NON */ void ChainParameters_set_latest_height(struct LDKChainParameters *NONNULL_PTR this_ptr, uintptr_t val); +/** + * Constructs a new ChainParameters given each field + */ MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKThirtyTwoBytes latest_hash_arg, uintptr_t latest_height_arg); -void ChannelDetails_free(struct LDKChannelDetails this_ptr); +/** + * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + */ +void ChannelDetails_free(struct LDKChannelDetails this_obj); /** * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, @@ -5924,10 +7106,19 @@ bool ChannelDetails_get_is_live(const struct LDKChannelDetails *NONNULL_PTR this */ void ChannelDetails_set_is_live(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +/** + * Creates a copy of the ChannelDetails + */ struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +/** + * Frees any resources used by the PaymentSendFailure + */ void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); +/** + * Creates a copy of the PaymentSendFailure + */ struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); /** @@ -6147,10 +7338,22 @@ MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDK */ void ChannelManager_channel_monitor_updated(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOutPoint *NONNULL_PTR funding_txo, uint64_t highest_applied_update_id); +/** + * 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 + */ struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); /** @@ -6173,11 +7376,21 @@ void ChannelManager_block_disconnected(const struct LDKChannelManager *NONNULL_P */ void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + */ struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); -void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_ptr); +/** + * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + */ +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); /** * The keys provider which will give us relevant keys. Some keys will be loaded during @@ -6270,13 +7483,25 @@ void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs */ MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); +/** + * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write + */ struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); -void DecodeError_free(struct LDKDecodeError this_ptr); +/** + * Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. + */ +void DecodeError_free(struct LDKDecodeError this_obj); +/** + * Creates a copy of the DecodeError + */ struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); -void Init_free(struct LDKInit this_ptr); +/** + * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + */ +void Init_free(struct LDKInit this_obj); /** * The relevant features which the sender supports @@ -6288,11 +7513,20 @@ struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ */ void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +/** + * Constructs a new Init given each field + */ MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg); +/** + * Creates a copy of the Init + */ struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); -void ErrorMessage_free(struct LDKErrorMessage this_ptr); +/** + * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + */ +void ErrorMessage_free(struct LDKErrorMessage this_obj); /** * The channel ID involved in the error @@ -6320,11 +7554,20 @@ struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR th */ void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +/** + * Constructs a new ErrorMessage given each field + */ MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z data_arg); +/** + * Creates a copy of the ErrorMessage + */ struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); -void Ping_free(struct LDKPing this_ptr); +/** + * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + */ +void Ping_free(struct LDKPing this_obj); /** * The desired response length @@ -6348,11 +7591,20 @@ uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); */ void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +/** + * Constructs a new Ping given each field + */ MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +/** + * Creates a copy of the Ping + */ struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); -void Pong_free(struct LDKPong this_ptr); +/** + * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + */ +void Pong_free(struct LDKPong this_obj); /** * The pong packet size. @@ -6366,11 +7618,20 @@ uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); */ void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); +/** + * Constructs a new Pong given each field + */ MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); +/** + * Creates a copy of the Pong + */ struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); -void OpenChannel_free(struct LDKOpenChannel this_ptr); +/** + * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + */ +void OpenChannel_free(struct LDKOpenChannel this_obj); /** * The genesis hash of the blockchain where the channel is to be opened @@ -6552,9 +7813,15 @@ uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR t */ void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); +/** + * Creates a copy of the OpenChannel + */ struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); -void AcceptChannel_free(struct LDKAcceptChannel this_ptr); +/** + * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + */ +void AcceptChannel_free(struct LDKAcceptChannel this_obj); /** * A temporary channel ID, until the funding outpoint is announced @@ -6696,9 +7963,15 @@ struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LD */ void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the AcceptChannel + */ struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); -void FundingCreated_free(struct LDKFundingCreated this_ptr); +/** + * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + */ +void FundingCreated_free(struct LDKFundingCreated this_obj); /** * A temporary channel ID, until the funding is established @@ -6740,11 +8013,20 @@ struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated */ void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); +/** + * Constructs a new FundingCreated given each field + */ MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); +/** + * Creates a copy of the FundingCreated + */ struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); -void FundingSigned_free(struct LDKFundingSigned this_ptr); +/** + * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + */ +void FundingSigned_free(struct LDKFundingSigned this_obj); /** * The channel ID @@ -6766,11 +8048,20 @@ struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *N */ void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +/** + * Constructs a new FundingSigned given each field + */ MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); +/** + * Creates a copy of the FundingSigned + */ struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); -void FundingLocked_free(struct LDKFundingLocked this_ptr); +/** + * Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL. + */ +void FundingLocked_free(struct LDKFundingLocked this_obj); /** * The channel ID @@ -6792,11 +8083,20 @@ struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDK */ void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Constructs a new FundingLocked given each field + */ MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg); +/** + * Creates a copy of the FundingLocked + */ struct LDKFundingLocked FundingLocked_clone(const struct LDKFundingLocked *NONNULL_PTR orig); -void Shutdown_free(struct LDKShutdown this_ptr); +/** + * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. + */ +void Shutdown_free(struct LDKShutdown this_obj); /** * The channel ID @@ -6820,11 +8120,20 @@ struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PT */ void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +/** + * Constructs a new Shutdown given each field + */ MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); +/** + * Creates a copy of the Shutdown + */ struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); -void ClosingSigned_free(struct LDKClosingSigned this_ptr); +/** + * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. + */ +void ClosingSigned_free(struct LDKClosingSigned this_obj); /** * The channel ID @@ -6856,11 +8165,20 @@ struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *N */ void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +/** + * Constructs a new ClosingSigned given each field + */ MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg); +/** + * Creates a copy of the ClosingSigned + */ struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); -void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_ptr); +/** + * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. + */ +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); /** * The channel ID @@ -6912,9 +8230,15 @@ uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PT */ void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); +/** + * Creates a copy of the UpdateAddHTLC + */ struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); -void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_ptr); +/** + * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. + */ +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); /** * The channel ID @@ -6946,11 +8270,20 @@ const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFul */ void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Constructs a new UpdateFulfillHTLC given each field + */ MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); +/** + * Creates a copy of the UpdateFulfillHTLC + */ struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); -void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_ptr); +/** + * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. + */ +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); /** * The channel ID @@ -6972,9 +8305,15 @@ uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR */ void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); +/** + * Creates a copy of the UpdateFailHTLC + */ struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); -void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_ptr); +/** + * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. + */ +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); /** * The channel ID @@ -7006,9 +8345,15 @@ uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalf */ void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); +/** + * Creates a copy of the UpdateFailMalformedHTLC + */ struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); -void CommitmentSigned_free(struct LDKCommitmentSigned this_ptr); +/** + * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. + */ +void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); /** * The channel ID @@ -7035,11 +8380,20 @@ void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this */ void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +/** + * Constructs a new CommitmentSigned given each field + */ MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); +/** + * Creates a copy of the CommitmentSigned + */ struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); -void RevokeAndACK_free(struct LDKRevokeAndACK this_ptr); +/** + * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. + */ +void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); /** * The channel ID @@ -7071,11 +8425,20 @@ struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKR */ void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Constructs a new RevokeAndACK given each field + */ MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); +/** + * Creates a copy of the RevokeAndACK + */ struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); -void UpdateFee_free(struct LDKUpdateFee this_ptr); +/** + * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. + */ +void UpdateFee_free(struct LDKUpdateFee this_obj); /** * The channel ID @@ -7097,11 +8460,20 @@ uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR thi */ void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); +/** + * Constructs a new UpdateFee given each field + */ MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); +/** + * Creates a copy of the UpdateFee + */ struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); -void DataLossProtect_free(struct LDKDataLossProtect this_ptr); +/** + * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. + */ +void DataLossProtect_free(struct LDKDataLossProtect this_obj); /** * Proof that the sender knows the per-commitment secret of a specific commitment transaction @@ -7125,11 +8497,20 @@ struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const st */ void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Constructs a new DataLossProtect given each field + */ MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); +/** + * Creates a copy of the DataLossProtect + */ struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); -void ChannelReestablish_free(struct LDKChannelReestablish this_ptr); +/** + * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. + */ +void ChannelReestablish_free(struct LDKChannelReestablish this_obj); /** * The channel ID @@ -7161,9 +8542,15 @@ uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKCh */ void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +/** + * Creates a copy of the ChannelReestablish + */ struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); -void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_ptr); +/** + * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. + */ +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); /** * The channel ID @@ -7205,19 +8592,40 @@ struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LD */ void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +/** + * Constructs a new AnnouncementSignatures given each field + */ MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); +/** + * Creates a copy of the AnnouncementSignatures + */ struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +/** + * Frees any resources used by the NetAddress + */ void NetAddress_free(struct LDKNetAddress this_ptr); +/** + * Creates a copy of the NetAddress + */ struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); +/** + * Serialize the NetAddress object into a byte array which can be read by NetAddress_read + */ struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); +/** + * Read a Result from a byte array, created by Result_write + */ struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser); -void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_ptr); +/** + * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. + */ +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); /** * The advertised features @@ -7278,9 +8686,15 @@ void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONN */ void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); +/** + * Creates a copy of the UnsignedNodeAnnouncement + */ struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); -void NodeAnnouncement_free(struct LDKNodeAnnouncement this_ptr); +/** + * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. + */ +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); /** * The signature by the node key @@ -7302,11 +8716,20 @@ struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LD */ void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); +/** + * Constructs a new NodeAnnouncement given each field + */ MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); +/** + * Creates a copy of the NodeAnnouncement + */ struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); -void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_ptr); +/** + * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. + */ +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); /** * The advertised channel features @@ -7378,9 +8801,15 @@ struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct L */ void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the UnsignedChannelAnnouncement + */ struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); -void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_ptr); +/** + * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. + */ +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); /** * Authentication of the announcement by the first public node @@ -7432,11 +8861,20 @@ struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const str */ void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); +/** + * Constructs a new ChannelAnnouncement given each field + */ MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); +/** + * Creates a copy of the ChannelAnnouncement + */ struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); -void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_ptr); +/** + * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. + */ +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); /** * The genesis hash of the blockchain where the channel is to be opened @@ -7518,9 +8956,15 @@ uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKU */ void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +/** + * Creates a copy of the UnsignedChannelUpdate + */ struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); -void ChannelUpdate_free(struct LDKChannelUpdate this_ptr); +/** + * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. + */ +void ChannelUpdate_free(struct LDKChannelUpdate this_obj); /** * A signature of the channel update @@ -7542,11 +8986,20 @@ struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChann */ void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); +/** + * Constructs a new ChannelUpdate given each field + */ MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); +/** + * Creates a copy of the ChannelUpdate + */ struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); -void QueryChannelRange_free(struct LDKQueryChannelRange this_ptr); +/** + * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. + */ +void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); /** * The genesis hash of the blockchain being queried @@ -7578,11 +9031,20 @@ uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRang */ void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +/** + * Constructs a new QueryChannelRange given each field + */ MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); +/** + * Creates a copy of the QueryChannelRange + */ struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); -void ReplyChannelRange_free(struct LDKReplyChannelRange this_ptr); +/** + * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. + */ +void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); /** * The genesis hash of the blockchain being queried @@ -7629,11 +9091,20 @@ void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PT */ void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +/** + * Constructs a new ReplyChannelRange given each field + */ MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); +/** + * Creates a copy of the ReplyChannelRange + */ struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); -void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_ptr); +/** + * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. + */ +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); /** * The genesis hash of the blockchain being queried @@ -7650,11 +9121,20 @@ void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL */ void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); -MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +/** + * Constructs a new QueryShortChannelIds given each field + */ +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +/** + * Creates a copy of the QueryShortChannelIds + */ struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); -void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_ptr); +/** + * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. + */ +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); /** * The genesis hash of the blockchain that was queried @@ -7678,11 +9158,20 @@ bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChan */ void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); +/** + * Constructs a new ReplyShortChannelIdsEnd given each field + */ MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +/** + * Creates a copy of the ReplyShortChannelIdsEnd + */ struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); -void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_ptr); +/** + * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. + */ +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); /** * The genesis hash of the blockchain for channel and node information @@ -7714,15 +9203,30 @@ uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimesta */ void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +/** + * Constructs a new GossipTimestampFilter given each field + */ MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); +/** + * Creates a copy of the GossipTimestampFilter + */ struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +/** + * Frees any resources used by the ErrorAction + */ void ErrorAction_free(struct LDKErrorAction this_ptr); +/** + * Creates a copy of the ErrorAction + */ struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); -void LightningError_free(struct LDKLightningError this_ptr); +/** + * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. + */ +void LightningError_free(struct LDKLightningError this_obj); /** * A human-readable message describing the error @@ -7744,11 +9248,20 @@ struct LDKErrorAction LightningError_get_action(const struct LDKLightningError * */ void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); +/** + * Constructs a new LightningError given each field + */ MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKCVec_u8Z err_arg, struct LDKErrorAction action_arg); +/** + * Creates a copy of the LightningError + */ struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); -void CommitmentUpdate_free(struct LDKCommitmentUpdate this_ptr); +/** + * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. + */ +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); /** * update_add_htlc messages which should be sent @@ -7790,12 +9303,24 @@ struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct L */ void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); +/** + * Constructs a new CommitmentUpdate given each field + */ MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); +/** + * Creates a copy of the CommitmentUpdate + */ struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +/** + * Frees any resources used by the HTLCFailChannelUpdate + */ void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr); +/** + * Creates a copy of the HTLCFailChannelUpdate + */ struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig); /** @@ -7808,150 +9333,364 @@ void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); */ void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +/** + * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read + */ struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); +/** + * Read a AcceptChannel from a byte array, created by AcceptChannel_write + */ struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); +/** + * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read + */ struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); +/** + * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write + */ struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); +/** + * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read + */ struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); +/** + * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write + */ struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); +/** + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + */ struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); +/** + * Read a ClosingSigned from a byte array, created by ClosingSigned_write + */ struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); +/** + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + */ struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); +/** + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + */ struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); +/** + * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read + */ struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); +/** + * Read a FundingCreated from a byte array, created by FundingCreated_write + */ struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); +/** + * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read + */ struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); +/** + * Read a FundingSigned from a byte array, created by FundingSigned_write + */ struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); +/** + * Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read + */ struct LDKCVec_u8Z FundingLocked_write(const struct LDKFundingLocked *NONNULL_PTR obj); +/** + * Read a FundingLocked from a byte array, created by FundingLocked_write + */ struct LDKCResult_FundingLockedDecodeErrorZ FundingLocked_read(struct LDKu8slice ser); +/** + * Serialize the Init object into a byte array which can be read by Init_read + */ struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); +/** + * Read a Init from a byte array, created by Init_write + */ struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); +/** + * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read + */ struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); +/** + * Read a OpenChannel from a byte array, created by OpenChannel_write + */ struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); +/** + * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read + */ struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); +/** + * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write + */ struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); +/** + * Serialize the Shutdown object into a byte array which can be read by Shutdown_read + */ struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); +/** + * Read a Shutdown from a byte array, created by Shutdown_write + */ struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); +/** + * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read + */ struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); +/** + * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write + */ struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); +/** + * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read + */ struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); +/** + * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write + */ struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); +/** + * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read + */ struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); +/** + * Read a UpdateFee from a byte array, created by UpdateFee_write + */ struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); +/** + * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read + */ struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); +/** + * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write + */ struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); +/** + * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read + */ struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); +/** + * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write + */ struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +/** + * Serialize the Ping object into a byte array which can be read by Ping_read + */ struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); +/** + * Read a Ping from a byte array, created by Ping_write + */ struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); +/** + * Serialize the Pong object into a byte array which can be read by Pong_read + */ struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); +/** + * Read a Pong from a byte array, created by Pong_write + */ struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); +/** + * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read + */ struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); +/** + * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write + */ struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); +/** + * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read + */ struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); +/** + * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write + */ struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); +/** + * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read + */ struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); +/** + * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write + */ struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); +/** + * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read + */ struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); +/** + * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write + */ struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); +/** + * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read + */ struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); +/** + * Read a ErrorMessage from a byte array, created by ErrorMessage_write + */ struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +/** + * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read + */ struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); +/** + * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write + */ struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); +/** + * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read + */ struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); +/** + * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write + */ struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); +/** + * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write + */ struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); +/** + * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read + */ struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); +/** + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + */ struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); +/** + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + */ struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +/** + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + */ struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); +/** + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + */ struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); +/** + * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write + */ struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); +/** + * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read + */ struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); +/** + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + */ struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); +/** + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + */ struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); -void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_ptr); +/** + * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. + */ +void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); +/** + * Constructs a new IgnoringMessageHandler given each field + */ MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); +/** + * 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 + */ struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); -void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_ptr); +/** + * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. + */ +void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); /** * Constructs a new ErroringMessageHandler */ MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); +/** + * 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 + */ struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); -void MessageHandler_free(struct LDKMessageHandler this_ptr); +/** + * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. + */ +void MessageHandler_free(struct LDKMessageHandler this_obj); /** * A message handler which handles messages specific to channels. Usually this is just a @@ -7977,8 +9716,14 @@ const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const st */ void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +/** + * Constructs a new MessageHandler given each field + */ MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg); +/** + * Creates a copy of a SocketDescriptor + */ struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); /** @@ -7986,7 +9731,10 @@ struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescript */ void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); -void PeerHandleError_free(struct LDKPeerHandleError this_ptr); +/** + * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. + */ +void PeerHandleError_free(struct LDKPeerHandleError this_obj); /** * Used to indicate that we probably can't make any future connections to this peer, implying @@ -8000,11 +9748,20 @@ bool PeerHandleError_get_no_connection_possible(const struct LDKPeerHandleError */ void PeerHandleError_set_no_connection_possible(struct LDKPeerHandleError *NONNULL_PTR this_ptr, bool val); +/** + * Constructs a new PeerHandleError given each field + */ MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); +/** + * Creates a copy of the PeerHandleError + */ struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); -void PeerManager_free(struct LDKPeerManager this_ptr); +/** + * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. + */ +void PeerManager_free(struct LDKPeerManager this_obj); /** * Constructs a new PeerManager with the given message handlers and node_id secret key @@ -8166,7 +9923,10 @@ struct LDKCResult_SecretKeyErrorZ derive_private_revocation_key(const uint8_t (* */ struct LDKCResult_PublicKeyErrorZ derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); -void TxCreationKeys_free(struct LDKTxCreationKeys this_ptr); +/** + * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. + */ +void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); /** * The broadcaster's per-commitment public key which was used to derive the other keys. @@ -8222,15 +9982,30 @@ struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const str */ void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Constructs a new TxCreationKeys given each field + */ MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); +/** + * Creates a copy of the TxCreationKeys + */ struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); +/** + * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read + */ struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); +/** + * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write + */ struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); -void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_ptr); +/** + * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. + */ +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); /** * The public key which is used to sign all commitment transactions, as it appears in the @@ -8300,12 +10075,24 @@ struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannel */ void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Constructs a new ChannelPublicKeys given each field + */ MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); +/** + * Creates a copy of the ChannelPublicKeys + */ struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +/** + * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read + */ struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); +/** + * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write + */ struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); /** @@ -8327,7 +10114,10 @@ MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_from_channel_ */ struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); -void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_ptr); +/** + * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. + */ +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); /** * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). @@ -8377,10 +10167,19 @@ const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutp */ void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Creates a copy of the HTLCOutputInCommitment + */ struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +/** + * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read + */ struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); +/** + * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write + */ struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); /** @@ -8400,7 +10199,10 @@ struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, st */ struct LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); -void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_ptr); +/** + * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. + */ +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); /** * Holder public keys @@ -8456,11 +10258,20 @@ struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struc */ void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +/** + * Constructs a new ChannelTransactionParameters given each field + */ MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg); +/** + * Creates a copy of the ChannelTransactionParameters + */ struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); -void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_ptr); +/** + * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. + */ +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); /** * Counter-party public keys @@ -8482,8 +10293,14 @@ uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(con */ void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +/** + * Constructs a new CounterpartyChannelTransactionParameters given each field + */ MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); +/** + * Creates a copy of the CounterpartyChannelTransactionParameters + */ struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); /** @@ -8507,15 +10324,30 @@ MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionPa */ MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +/** + * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read + */ struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); +/** + * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write + */ struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); +/** + * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read + */ struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); +/** + * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write + */ struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); -void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_ptr); +/** + * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. + */ +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); /** * Get the channel pubkeys for the broadcaster @@ -8546,7 +10378,10 @@ MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct */ MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); -void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_ptr); +/** + * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. + */ +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); /** * Our counterparty's signature for the transaction @@ -8563,10 +10398,19 @@ void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitment */ void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +/** + * Creates a copy of the HolderCommitmentTransaction + */ struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); +/** + * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read + */ struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); +/** + * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write + */ struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); /** @@ -8575,7 +10419,10 @@ struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransa */ MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); -void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_ptr); +/** + * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. + */ +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); /** * The commitment transaction @@ -8603,12 +10450,24 @@ const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitm */ void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Constructs a new BuiltCommitmentTransaction given each field + */ MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); +/** + * Creates a copy of the BuiltCommitmentTransaction + */ struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); +/** + * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read + */ struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); +/** + * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write + */ struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); /** @@ -8624,12 +10483,24 @@ MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all */ MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); -void CommitmentTransaction_free(struct LDKCommitmentTransaction this_ptr); +/** + * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. + */ +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); +/** + * Creates a copy of the CommitmentTransaction + */ struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); +/** + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + */ struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); +/** + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + */ struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); /** @@ -8672,7 +10543,10 @@ MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust( */ MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); -void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_ptr); +/** + * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. + */ +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); /** * The transaction ID of the built Bitcoin transaction @@ -8702,17 +10576,45 @@ MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction */ uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); +/** + * Creates a copy of the InitFeatures + */ struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +/** + * Creates a copy of the NodeFeatures + */ struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +/** + * Creates a copy of the ChannelFeatures + */ struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); -void InitFeatures_free(struct LDKInitFeatures this_ptr); +/** + * Creates a copy of the InvoiceFeatures + */ +struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); + +/** + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. + */ +void InitFeatures_free(struct LDKInitFeatures this_obj); + +/** + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + */ +void NodeFeatures_free(struct LDKNodeFeatures this_obj); -void NodeFeatures_free(struct LDKNodeFeatures this_ptr); +/** + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + */ +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); -void ChannelFeatures_free(struct LDKChannelFeatures this_ptr); +/** + * Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. + */ +void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); /** * Create a blank Features with no features set @@ -8750,19 +10652,62 @@ MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); */ MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); +/** + * Create a blank Features with no features set + */ +MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); + +/** + * Creates features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. + * + * [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS + */ +MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); + +/** + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + */ struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +/** + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + */ struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +/** + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + */ struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +/** + * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read + */ +struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); + +/** + * Read a InitFeatures from a byte array, created by InitFeatures_write + */ struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +/** + * Read a NodeFeatures from a byte array, created by NodeFeatures_write + */ struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +/** + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + */ struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); -void RouteHop_free(struct LDKRouteHop this_ptr); +/** + * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write + */ +struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + */ +void RouteHop_free(struct LDKRouteHop this_obj); /** * The node_id of the node at this hop. @@ -8834,11 +10779,20 @@ uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR th */ void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); +/** + * Constructs a new RouteHop given each field + */ MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); +/** + * Creates a copy of the RouteHop + */ struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); -void Route_free(struct LDKRoute this_ptr); +/** + * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + */ +void Route_free(struct LDKRoute this_obj); /** * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the @@ -8850,15 +10804,30 @@ void Route_free(struct LDKRoute this_ptr); */ void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); +/** + * Constructs a new Route given each field + */ MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg); +/** + * Creates a copy of the Route + */ struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); +/** + * Serialize the Route object into a byte array which can be read by Route_read + */ struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); +/** + * Read a Route from a byte array, created by Route_write + */ struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); -void RouteHint_free(struct LDKRouteHint this_ptr); +/** + * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. + */ +void RouteHint_free(struct LDKRouteHint this_obj); /** * The node_id of the non-target end of the route @@ -8900,11 +10869,17 @@ uint16_t RouteHint_get_cltv_expiry_delta(const struct LDKRouteHint *NONNULL_PTR */ void RouteHint_set_cltv_expiry_delta(struct LDKRouteHint *NONNULL_PTR this_ptr, uint16_t val); +/** + * Creates a copy of the RouteHint + */ struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** * 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. * @@ -8920,15 +10895,27 @@ struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig) * 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. */ -struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); +struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); -void NetworkGraph_free(struct LDKNetworkGraph this_ptr); +/** + * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. + */ +void NetworkGraph_free(struct LDKNetworkGraph this_obj); +/** + * Creates a copy of the NetworkGraph + */ struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); -void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_ptr); +/** + * Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL. + */ +void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj); -void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_ptr); +/** + * Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL. + */ +void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); /** * Creates a new tracker of the actual state of the network of channels and nodes, @@ -8965,11 +10952,22 @@ MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(c */ MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); +/** + * 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 + */ struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); -void DirectionalChannelInfo_free(struct LDKDirectionalChannelInfo this_ptr); +/** + * Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. + */ +void DirectionalChannelInfo_free(struct LDKDirectionalChannelInfo this_obj); /** * When the last update to the channel direction was issued. @@ -9039,13 +11037,25 @@ struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const str */ void DirectionalChannelInfo_set_last_update_message(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +/** + * Creates a copy of the DirectionalChannelInfo + */ struct LDKDirectionalChannelInfo DirectionalChannelInfo_clone(const struct LDKDirectionalChannelInfo *NONNULL_PTR orig); +/** + * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read + */ struct LDKCVec_u8Z DirectionalChannelInfo_write(const struct LDKDirectionalChannelInfo *NONNULL_PTR obj); +/** + * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write + */ struct LDKCResult_DirectionalChannelInfoDecodeErrorZ DirectionalChannelInfo_read(struct LDKu8slice ser); -void ChannelInfo_free(struct LDKChannelInfo this_ptr); +/** + * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. + */ +void ChannelInfo_free(struct LDKChannelInfo this_obj); /** * Protocol features of a channel communicated during its announcement @@ -9113,13 +11123,25 @@ struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct */ void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +/** + * Creates a copy of the ChannelInfo + */ struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +/** + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + */ struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); +/** + * Read a ChannelInfo from a byte array, created by ChannelInfo_write + */ struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); -void RoutingFees_free(struct LDKRoutingFees this_ptr); +/** + * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. + */ +void RoutingFees_free(struct LDKRoutingFees this_obj); /** * Flat routing fee in satoshis @@ -9143,15 +11165,30 @@ uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NO */ void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +/** + * Constructs a new RoutingFees given each field + */ MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +/** + * Creates a copy of the RoutingFees + */ struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); +/** + * Read a RoutingFees from a byte array, created by RoutingFees_write + */ struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); +/** + * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read + */ struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); -void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_ptr); +/** + * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. + */ +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); /** * Protocol features the node announced support for @@ -9220,15 +11257,30 @@ struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const s */ void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); +/** + * Constructs a new NodeAnnouncementInfo given each field + */ MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKThirtyTwoBytes alias_arg, struct LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); +/** + * Creates a copy of the NodeAnnouncementInfo + */ struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +/** + * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read + */ struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); +/** + * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write + */ struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); -void NodeInfo_free(struct LDKNodeInfo this_ptr); +/** + * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + */ +void NodeInfo_free(struct LDKNodeInfo this_obj); /** * All valid channels a node has announced @@ -9263,16 +11315,34 @@ struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNo */ void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); +/** + * Constructs a new NodeInfo given each field + */ MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKRoutingFees lowest_inbound_channel_fees_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); +/** + * Creates a copy of the NodeInfo + */ struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +/** + * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read + */ struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); +/** + * Read a NodeInfo from a byte array, created by NodeInfo_write + */ struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); +/** + * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read + */ struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); +/** + * Read a NetworkGraph from a byte array, created by NetworkGraph_write + */ struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser); /** diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 3151b9c..cf59e43 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -300,6 +300,21 @@ public: const LDKChannelFeatures* operator &() const { return &self; } const LDKChannelFeatures* operator ->() const { return &self; } }; +class InvoiceFeatures { +private: + LDKInvoiceFeatures 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; } +}; class ChannelHandshakeConfig { private: LDKChannelHandshakeConfig self; @@ -1676,20 +1691,20 @@ public: const LDKCResult_FundingCreatedDecodeErrorZ* operator &() const { return &self; } const LDKCResult_FundingCreatedDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ChannelAnnouncementDecodeErrorZ { +class CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { private: - LDKCResult_ChannelAnnouncementDecodeErrorZ self; + LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ 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; } + CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ(const CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ&) = delete; + CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ(CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ)); } + CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ)); } + operator LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ() && { LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ)); return res; } + ~CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ() { CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(self); } + CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ& operator=(CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ&& o) { CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ)); return *this; } + LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ* operator &() { return &self; } + LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ* operator ->() const { return &self; } }; class CResult_HTLCUpdateDecodeErrorZ { private: @@ -1751,6 +1766,21 @@ public: const LDKCResult_ChannelInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelInfoDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ChannelAnnouncementDecodeErrorZ { +private: + LDKCResult_ChannelAnnouncementDecodeErrorZ 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; } +}; class CResult_CVec_u8ZPeerHandleErrorZ { private: LDKCResult_CVec_u8ZPeerHandleErrorZ self; @@ -1766,6 +1796,21 @@ 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; @@ -1796,21 +1841,6 @@ public: const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_GossipTimestampFilterDecodeErrorZ { -private: - LDKCResult_GossipTimestampFilterDecodeErrorZ self; -public: - CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete; - CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); } - CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); } - operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; } - ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); } - CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; } - LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; } - LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_TxOutAccessErrorZ { private: LDKCResult_TxOutAccessErrorZ self; @@ -1841,6 +1871,21 @@ public: const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_GossipTimestampFilterDecodeErrorZ { +private: + LDKCResult_GossipTimestampFilterDecodeErrorZ self; +public: + CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete; + CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); } + CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); } + operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; } + ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); } + CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; } + LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; } + LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_ChannelReestablishDecodeErrorZ { private: LDKCResult_ChannelReestablishDecodeErrorZ self; @@ -2741,6 +2786,21 @@ public: const LDKCVec_u64Z* operator &() const { return &self; } const LDKCVec_u64Z* operator ->() const { return &self; } }; +class C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { +private: + LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ self; +public: + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ(const C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ&) = delete; + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ(C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ)); } + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ)); } + operator LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ() && { LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ)); return res; } + ~C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ() { C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(self); } + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ& operator=(C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ&& o) { C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ)); return *this; } + LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator &() { return &self; } + LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator ->() { return &self; } + const LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator &() const { return &self; } + const LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator ->() const { return &self; } +}; class CVec_RouteHintZ { private: LDKCVec_RouteHintZ self; @@ -3101,6 +3161,21 @@ public: const LDKCVec_MonitorEventZ* operator &() const { return &self; } const LDKCVec_MonitorEventZ* operator ->() const { return &self; } }; +class CVec_C2Tuple_u32ScriptZZ { +private: + LDKCVec_C2Tuple_u32ScriptZZ self; +public: + CVec_C2Tuple_u32ScriptZZ(const CVec_C2Tuple_u32ScriptZZ&) = delete; + CVec_C2Tuple_u32ScriptZZ(CVec_C2Tuple_u32ScriptZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_u32ScriptZZ)); } + CVec_C2Tuple_u32ScriptZZ(LDKCVec_C2Tuple_u32ScriptZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_u32ScriptZZ)); } + operator LDKCVec_C2Tuple_u32ScriptZZ() && { LDKCVec_C2Tuple_u32ScriptZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_u32ScriptZZ)); return res; } + ~CVec_C2Tuple_u32ScriptZZ() { CVec_C2Tuple_u32ScriptZZ_free(self); } + CVec_C2Tuple_u32ScriptZZ& operator=(CVec_C2Tuple_u32ScriptZZ&& o) { CVec_C2Tuple_u32ScriptZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_u32ScriptZZ)); return *this; } + LDKCVec_C2Tuple_u32ScriptZZ* operator &() { return &self; } + LDKCVec_C2Tuple_u32ScriptZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_u32ScriptZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_u32ScriptZZ* operator ->() const { return &self; } +}; class CResult_NoneChannelMonitorUpdateErrZ { private: LDKCResult_NoneChannelMonitorUpdateErrZ self; @@ -3281,6 +3356,21 @@ public: const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_u32ScriptZ { +private: + LDKC2Tuple_u32ScriptZ self; +public: + C2Tuple_u32ScriptZ(const C2Tuple_u32ScriptZ&) = delete; + C2Tuple_u32ScriptZ(C2Tuple_u32ScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_u32ScriptZ)); } + C2Tuple_u32ScriptZ(LDKC2Tuple_u32ScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_u32ScriptZ)); } + operator LDKC2Tuple_u32ScriptZ() && { LDKC2Tuple_u32ScriptZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_u32ScriptZ)); return res; } + ~C2Tuple_u32ScriptZ() { C2Tuple_u32ScriptZ_free(self); } + C2Tuple_u32ScriptZ& operator=(C2Tuple_u32ScriptZ&& o) { C2Tuple_u32ScriptZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_u32ScriptZ)); return *this; } + LDKC2Tuple_u32ScriptZ* operator &() { return &self; } + LDKC2Tuple_u32ScriptZ* operator ->() { return &self; } + const LDKC2Tuple_u32ScriptZ* operator &() const { return &self; } + const LDKC2Tuple_u32ScriptZ* operator ->() const { return &self; } +}; class CResult_CResult_NetAddressu8ZDecodeErrorZ { private: LDKCResult_CResult_NetAddressu8ZDecodeErrorZ self; diff --git a/lightning-c-bindings/include/rust_types.h b/lightning-c-bindings/include/rust_types.h index 6d573e9..f8ec85e 100644 --- a/lightning-c-bindings/include/rust_types.h +++ b/lightning-c-bindings/include/rust_types.h @@ -47,6 +47,8 @@ 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; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index c16f9a2..0f99ddc 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -1731,6 +1731,66 @@ impl From CResult_InvoiceFeaturesDecodeErrorZ { + CResult_InvoiceFeaturesDecodeErrorZ { + contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +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, + } +} +#[no_mangle] +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { + 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_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)] pub union CResult_ChannelConfigDecodeErrorZPtr { pub result: *mut crate::util::config::ChannelConfig, pub err: *mut crate::ln::msgs::DecodeError, @@ -2879,6 +2939,138 @@ pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutP #[no_mangle] pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } #[repr(C)] +pub struct C2Tuple_u32ScriptZ { + pub a: u32, + 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(), + } + } +} +#[no_mangle] +pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { orig.clone() } +#[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] +pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } +#[repr(C)] +pub struct CVec_C2Tuple_u32ScriptZZ { + pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, + pub datalen: usize +} +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) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +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() } } + } +} +#[no_mangle] +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_C2Tuple_u32ScriptZZ { + 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)] +pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + pub a: crate::c_types::ThirtyTwoBytes, + pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, +} +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, + } + } +} +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] +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] +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } +#[repr(C)] +pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, + pub datalen: usize +} +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 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] +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)] pub struct CVec_TransactionZ { pub data: *mut crate::c_types::Transaction, pub datalen: usize diff --git a/lightning-c-bindings/src/chain/chaininterface.rs b/lightning-c-bindings/src/chain/chaininterface.rs index b5f5103..3b585d3 100644 --- a/lightning-c-bindings/src/chain/chaininterface.rs +++ b/lightning-c-bindings/src/chain/chaininterface.rs @@ -11,9 +11,13 @@ 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 {} @@ -93,6 +97,7 @@ impl ConfirmationTarget { } } } +/// Creates a copy of the ConfirmationTarget #[no_mangle] pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> ConfirmationTarget { orig.clone() @@ -104,6 +109,8 @@ pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> Confirm /// 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. /// @@ -115,6 +122,8 @@ pub struct FeeEstimator { /// * 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 {} @@ -146,6 +155,7 @@ impl Drop for FeeEstimator { } } } +/// 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 index c05f901..3039ec6 100644 --- a/lightning-c-bindings/src/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/chain/chainmonitor.rs @@ -41,9 +41,15 @@ type nativeChainMonitor = nativeChainMonitorImport for crate::chain::Watch { 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 { @@ -167,6 +176,8 @@ impl From for crate::util::events::EventsProvider { 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 { diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs index 9fab7e0..ae4dc26 100644 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/chain/channelmonitor.rs @@ -26,9 +26,15 @@ type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport; #[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, } @@ -39,8 +45,9 @@ impl Drop for ChannelMonitorUpdate { } } } +/// 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_ptr: ChannelMonitorUpdate) { } +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) { @@ -106,13 +113,22 @@ pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const 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 }) } @@ -121,6 +137,7 @@ pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> 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() }; @@ -219,6 +236,7 @@ impl ChannelMonitorUpdateErr { } } } +/// Creates a copy of the ChannelMonitorUpdateErr #[no_mangle] pub extern "C" fn ChannelMonitorUpdateErr_clone(orig: &ChannelMonitorUpdateErr) -> ChannelMonitorUpdateErr { orig.clone() @@ -235,9 +253,15 @@ type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport; #[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, } @@ -248,8 +272,9 @@ impl Drop for MonitorUpdateError { } } } +/// 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_ptr: MonitorUpdateError) { } +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) { @@ -280,6 +305,7 @@ pub(crate) extern "C" fn MonitorUpdateError_clone_void(this_ptr: *const 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() } @@ -360,8 +386,10 @@ impl MonitorEvent { } } } +/// 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() @@ -378,9 +406,15 @@ type nativeHTLCUpdate = nativeHTLCUpdateImport; #[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, } @@ -391,8 +425,9 @@ impl Drop for HTLCUpdate { } } } +/// 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_ptr: HTLCUpdate) { } +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) { @@ -423,10 +458,12 @@ pub(crate) extern "C" fn HTLCUpdate_clone_void(this_ptr: *const c_void) -> *mut 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 }) } @@ -435,6 +472,7 @@ pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_t 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() }; @@ -463,9 +501,15 @@ type nativeChannelMonitor = nativeChannelMonitorImport crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) } @@ -531,6 +577,24 @@ pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> c 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`]. /// @@ -614,6 +678,8 @@ pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, h /// 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 @@ -657,6 +723,8 @@ pub struct Persist { /// [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html #[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 {} @@ -695,6 +763,7 @@ impl Drop for Persist { } } #[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); diff --git a/lightning-c-bindings/src/chain/keysinterface.rs b/lightning-c-bindings/src/chain/keysinterface.rs index abd7796..c5b0324 100644 --- a/lightning-c-bindings/src/chain/keysinterface.rs +++ b/lightning-c-bindings/src/chain/keysinterface.rs @@ -15,9 +15,15 @@ type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptor #[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, } @@ -28,8 +34,9 @@ impl Drop for DelayedPaymentOutputDescriptor { } } } +/// 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_ptr: DelayedPaymentOutputDescriptor) { } +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) { @@ -124,6 +131,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this 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 { @@ -152,6 +160,7 @@ pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_clone_void(this_ptr: *co 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() } @@ -164,9 +173,15 @@ type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorIm #[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, } @@ -177,8 +192,9 @@ impl Drop for StaticPaymentOutputDescriptor { } } } +/// 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_ptr: StaticPaymentOutputDescriptor) { } +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) { @@ -236,6 +252,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ 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 { @@ -261,6 +278,7 @@ pub(crate) extern "C" fn StaticPaymentOutputDescriptor_clone_void(this_ptr: *con 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() } @@ -279,7 +297,9 @@ pub enum SpendableOutputDescriptor { /// 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. @@ -415,17 +435,21 @@ impl SpendableOutputDescriptor { } } } +/// 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() }; @@ -450,6 +474,8 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - /// of LN security model, orthogonal of key management issues. #[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, /// Gets the per-commitment point for a specific commitment number /// @@ -559,12 +585,19 @@ pub struct Sign { /// /// 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), + /// 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>, + /// Serialize the object into a byte array pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, +/// 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 Sign {} #[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 }, @@ -677,6 +710,8 @@ impl Drop for Sign { /// 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). /// @@ -717,6 +752,8 @@ pub struct KeysInterface { /// 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 {} @@ -782,9 +819,15 @@ type nativeInMemorySigner = nativeInMemorySignerImport; #[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, } @@ -795,8 +838,9 @@ impl Drop for InMemorySigner { } } } +/// 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_ptr: InMemorySigner) { } +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) { @@ -893,6 +937,7 @@ pub(crate) extern "C" fn InMemorySigner_clone_void(this_ptr: *const 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() } @@ -1001,6 +1046,8 @@ impl From for crate::chain::keysinterface::Sign { 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 { @@ -1093,6 +1140,7 @@ extern "C" fn InMemorySigner_Sign_ready_channel(this_arg: *mut c_void, channel_p } #[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 }) } @@ -1101,6 +1149,7 @@ pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate: 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() }; @@ -1120,9 +1169,15 @@ type nativeKeysManager = nativeKeysManagerImport; #[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, } @@ -1133,8 +1188,9 @@ impl Drop for KeysManager { } } } +/// 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_ptr: KeysManager) { } +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) { @@ -1219,6 +1275,8 @@ impl From for crate::chain::keysinterface::KeysInterface { 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 { diff --git a/lightning-c-bindings/src/chain/mod.rs b/lightning-c-bindings/src/chain/mod.rs index fb72263..c3adcf6 100644 --- a/lightning-c-bindings/src/chain/mod.rs +++ b/lightning-c-bindings/src/chain/mod.rs @@ -52,6 +52,7 @@ impl AccessError { } } } +/// Creates a copy of the AccessError #[no_mangle] pub extern "C" fn AccessError_clone(orig: &AccessError) -> AccessError { orig.clone() @@ -60,6 +61,8 @@ pub extern "C" fn AccessError_clone(orig: &AccessError) -> AccessError { /// 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 @@ -68,6 +71,8 @@ pub struct Access { /// [`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 {} @@ -106,11 +111,15 @@ impl Drop for Access { /// 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, } @@ -167,6 +176,8 @@ impl Drop for Listen { /// [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.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`. /// @@ -192,6 +203,8 @@ pub struct Watch { /// 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 {} @@ -257,6 +270,8 @@ impl Drop for Watch { /// [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. @@ -264,6 +279,8 @@ pub struct Filter { /// Registers interest in spends of a transaction output identified by `outpoint` having /// `script_pubkey` as the spending condition. pub register_output: extern "C" fn (this_arg: *const c_void, outpoint: &crate::chain::transaction::OutPoint, script_pubkey: crate::c_types::u8slice), +/// 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 {} diff --git a/lightning-c-bindings/src/chain/transaction.rs b/lightning-c-bindings/src/chain/transaction.rs index f943223..0079873 100644 --- a/lightning-c-bindings/src/chain/transaction.rs +++ b/lightning-c-bindings/src/chain/transaction.rs @@ -15,9 +15,15 @@ type nativeOutPoint = nativeOutPointImport; #[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, } @@ -28,8 +34,9 @@ impl Drop for OutPoint { } } } +/// 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_ptr: OutPoint) { } +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) { @@ -67,6 +74,7 @@ pub extern "C" fn OutPoint_get_index(this_ptr: &OutPoint) -> u16 { 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 { @@ -90,6 +98,7 @@ pub(crate) extern "C" fn OutPoint_clone_void(this_ptr: *const c_void) -> *mut c_ 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() } @@ -102,6 +111,7 @@ pub extern "C" fn OutPoint_to_channel_id(this_arg: &OutPoint) -> crate::c_types: } #[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 }) } @@ -110,6 +120,7 @@ pub(crate) extern "C" fn OutPoint_write_void(obj: *const c_void) -> crate::c_typ 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() }; diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index 89dfc09..044c328 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -16,6 +16,7 @@ #![allow(unused_parens)] #![allow(unused_unsafe)] #![allow(unused_braces)] +#![deny(missing_docs)] mod c_types; mod bitcoin; pub mod util; diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs index 4a26567..f2a2a5a 100644 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ b/lightning-c-bindings/src/ln/chan_utils.rs @@ -89,9 +89,15 @@ type nativeTxCreationKeys = nativeTxCreationKeysImport; #[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, } @@ -102,8 +108,9 @@ impl Drop for TxCreationKeys { } } } +/// 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_ptr: TxCreationKeys) { } +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) { @@ -178,6 +185,7 @@ pub extern "C" fn TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr: & 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 { @@ -204,10 +212,12 @@ pub(crate) extern "C" fn TxCreationKeys_clone_void(this_ptr: *const 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 }) } @@ -216,6 +226,7 @@ pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate: 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() }; @@ -229,9 +240,15 @@ type nativeChannelPublicKeys = nativeChannelPublicKeysImport; #[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, } @@ -242,8 +259,9 @@ impl Drop for ChannelPublicKeys { } } } +/// 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_ptr: ChannelPublicKeys) { } +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) { @@ -332,6 +350,7 @@ pub extern "C" fn ChannelPublicKeys_get_htlc_basepoint(this_ptr: &ChannelPublicK 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 { @@ -358,10 +377,12 @@ pub(crate) extern "C" fn ChannelPublicKeys_clone_void(this_ptr: *const 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 }) } @@ -370,6 +391,7 @@ pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> cra 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() }; @@ -395,6 +417,7 @@ pub extern "C" fn TxCreationKeys_from_channel_static_keys(mut per_commitment_poi 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; @@ -415,9 +438,15 @@ type nativeHTLCOutputInCommitment = nativeHTLCOutputInCommitmentImport; #[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, } @@ -428,8 +457,9 @@ impl Drop for HTLCOutputInCommitment { } } } +/// 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_ptr: HTLCOutputInCommitment) { } +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) { @@ -512,10 +542,12 @@ pub(crate) extern "C" fn HTLCOutputInCommitment_clone_void(this_ptr: *const c_vo 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 }) } @@ -524,6 +556,7 @@ pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) - 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() }; @@ -565,9 +598,15 @@ type nativeChannelTransactionParameters = nativeChannelTransactionParametersImpo #[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, } @@ -578,8 +617,9 @@ impl Drop for ChannelTransactionParameters { } } } +/// 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_ptr: ChannelTransactionParameters) { } +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) { @@ -658,6 +698,7 @@ pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &m 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 { @@ -686,6 +727,7 @@ pub(crate) extern "C" fn ChannelTransactionParameters_clone_void(this_ptr: *cons 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() } @@ -697,9 +739,15 @@ type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelT #[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, } @@ -710,8 +758,9 @@ impl Drop for CounterpartyChannelTransactionParameters { } } } +/// 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_ptr: CounterpartyChannelTransactionParameters) { } +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) { @@ -749,6 +798,7 @@ pub extern "C" fn CounterpartyChannelTransactionParameters_get_selected_contest_ 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 { @@ -772,6 +822,7 @@ pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_clone_void(thi 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() } @@ -806,6 +857,7 @@ pub extern "C" fn ChannelTransactionParameters_as_counterparty_broadcastable(thi } #[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 }) } @@ -814,12 +866,14 @@ pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj 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 }) } @@ -828,6 +882,7 @@ pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_v 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() }; @@ -845,9 +900,15 @@ type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransacti #[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, } @@ -858,8 +919,9 @@ impl Drop for DirectedChannelTransactionParameters { } } } +/// 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_ptr: DirectedChannelTransactionParameters) { } +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) { @@ -929,9 +991,15 @@ type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport #[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, } @@ -942,8 +1010,9 @@ impl Drop for HolderCommitmentTransaction { } } } +/// 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_ptr: HolderCommitmentTransaction) { } +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) { @@ -991,10 +1060,12 @@ pub(crate) extern "C" fn HolderCommitmentTransaction_clone_void(this_ptr: *const 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 }) } @@ -1003,6 +1074,7 @@ pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_vo 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() }; @@ -1026,9 +1098,15 @@ type nativeBuiltCommitmentTransaction = nativeBuiltCommitmentTransactionImport; #[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, } @@ -1039,8 +1117,9 @@ impl Drop for BuiltCommitmentTransaction { } } } +/// 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_ptr: BuiltCommitmentTransaction) { } +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) { @@ -1085,6 +1164,7 @@ pub extern "C" fn BuiltCommitmentTransaction_get_txid(this_ptr: &BuiltCommitment 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 { @@ -1108,10 +1188,12 @@ pub(crate) extern "C" fn BuiltCommitmentTransaction_clone_void(this_ptr: *const 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 }) } @@ -1120,6 +1202,7 @@ pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_voi 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() }; @@ -1157,9 +1240,15 @@ type nativeCommitmentTransaction = nativeCommitmentTransactionImport; #[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, } @@ -1170,8 +1259,9 @@ impl Drop for CommitmentTransaction { } } } +/// 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_ptr: CommitmentTransaction) { } +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) { @@ -1202,10 +1292,12 @@ pub(crate) extern "C" fn CommitmentTransaction_clone_void(this_ptr: *const c_voi 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 }) } @@ -1214,6 +1306,7 @@ pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> 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() }; @@ -1291,9 +1384,15 @@ type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImpo #[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, } @@ -1304,8 +1403,9 @@ impl Drop for TrustedCommitmentTransaction { } } } +/// 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_ptr: TrustedCommitmentTransaction) { } +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) { diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index 86257f7..502520a 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -56,9 +56,15 @@ type nativeChannelManager = nativeChannelManagerImport ChainParameters { @@ -182,9 +197,15 @@ type nativeChannelDetails = nativeChannelDetailsImport; #[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, } @@ -195,8 +216,9 @@ impl Drop for ChannelDetails { } } } +/// 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_ptr: ChannelDetails) { } +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) { @@ -341,6 +363,7 @@ pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const 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() } @@ -504,8 +527,10 @@ impl PaymentSendFailure { } } } +/// 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() @@ -784,6 +809,8 @@ impl From for crate::util::events::MessageSendEventsProvid 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 { @@ -810,6 +837,8 @@ impl From for crate::util::events::EventsProvider { 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 { @@ -836,6 +865,8 @@ impl From for crate::chain::Listen { 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 { @@ -887,6 +918,8 @@ impl From for crate::ln::msgs::ChannelMessageHandler { 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 { @@ -984,6 +1017,7 @@ extern "C" fn ChannelManager_ChannelMessageHandler_get_and_clear_pending_msg_eve } #[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 }) } @@ -1023,9 +1057,15 @@ type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, #[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, } @@ -1036,8 +1076,9 @@ impl Drop for ChannelManagerReadArgs { } } } +/// 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_ptr: ChannelManagerReadArgs) { } +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) { @@ -1155,6 +1196,7 @@ pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::chain::key } #[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); diff --git a/lightning-c-bindings/src/ln/features.rs b/lightning-c-bindings/src/ln/features.rs index 06dc420..1866068 100644 --- a/lightning-c-bindings/src/ln/features.rs +++ b/lightning-c-bindings/src/ln/features.rs @@ -35,6 +35,7 @@ pub(crate) extern "C" fn InitFeatures_clone_void(this_ptr: *const c_void) -> *mu 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() } @@ -53,6 +54,7 @@ pub(crate) extern "C" fn NodeFeatures_clone_void(this_ptr: *const c_void) -> *mu 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() } @@ -71,9 +73,29 @@ pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const 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; @@ -82,9 +104,15 @@ type nativeInitFeatures = nativeInitFeaturesImport; #[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, } @@ -95,8 +123,9 @@ impl Drop for InitFeatures { } } } +/// 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_ptr: InitFeatures) { } +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) { @@ -120,9 +149,15 @@ type nativeNodeFeatures = nativeNodeFeaturesImport; #[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, } @@ -133,8 +168,9 @@ impl Drop for NodeFeatures { } } } +/// 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_ptr: NodeFeatures) { } +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) { @@ -158,9 +194,15 @@ type nativeChannelFeatures = nativeChannelFeaturesImport; #[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, } @@ -171,8 +213,9 @@ impl Drop for ChannelFeatures { } } } +/// 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_ptr: ChannelFeatures) { } +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) { @@ -188,6 +231,51 @@ impl ChannelFeatures { 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] @@ -242,7 +330,26 @@ pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { 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 features known by the implementation as defined by [`T::KNOWN_FEATURE_FLAGS`]. +/// +/// [`T::KNOWN_FEATURE_FLAGS`]: sealed/trait.Context.html#associatedconstant.KNOWN_FEATURE_FLAGS +#[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 }) } @@ -251,6 +358,7 @@ pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c 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 }) } @@ -259,6 +367,7 @@ pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c 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 }) } @@ -267,20 +376,39 @@ pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate 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/msgs.rs b/lightning-c-bindings/src/ln/msgs.rs index 416b532..7089593 100644 --- a/lightning-c-bindings/src/ln/msgs.rs +++ b/lightning-c-bindings/src/ln/msgs.rs @@ -27,9 +27,15 @@ type nativeDecodeError = nativeDecodeErrorImport; #[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, } @@ -40,8 +46,9 @@ impl Drop for DecodeError { } } } +/// 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_ptr: DecodeError) { } +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) { @@ -72,6 +79,7 @@ pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut 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() } @@ -83,9 +91,15 @@ type nativeInit = nativeInitImport; #[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, } @@ -96,8 +110,9 @@ impl Drop for Init { } } } +/// 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_ptr: Init) { } +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) { @@ -124,6 +139,7 @@ pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::ln::features::Ini 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 { @@ -146,6 +162,7 @@ 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() } @@ -157,9 +174,15 @@ type nativeErrorMessage = nativeErrorMessageImport; #[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, } @@ -170,8 +193,9 @@ impl Drop for ErrorMessage { } } } +/// 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_ptr: ErrorMessage) { } +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) { @@ -215,6 +239,7 @@ pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_typ 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 { @@ -238,6 +263,7 @@ pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mu 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() } @@ -249,9 +275,15 @@ type nativePing = nativePingImport; #[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, } @@ -262,8 +294,9 @@ impl Drop for Ping { } } } +/// 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_ptr: Ping) { } +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) { @@ -303,6 +336,7 @@ pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 { 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 { @@ -326,6 +360,7 @@ 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() } @@ -337,9 +372,15 @@ type nativePong = nativePongImport; #[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, } @@ -350,8 +391,9 @@ impl Drop for Pong { } } } +/// 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_ptr: Pong) { } +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) { @@ -380,6 +422,7 @@ pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 { 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 { @@ -402,6 +445,7 @@ 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() } @@ -413,9 +457,15 @@ type nativeOpenChannel = nativeOpenChannelImport; #[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, } @@ -426,8 +476,9 @@ impl Drop for OpenChannel { } } } +/// 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_ptr: OpenChannel) { } +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) { @@ -656,6 +707,7 @@ pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut 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() } @@ -667,9 +719,15 @@ type nativeAcceptChannel = nativeAcceptChannelImport; #[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, } @@ -680,8 +738,9 @@ impl Drop for AcceptChannel { } } } +/// 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_ptr: AcceptChannel) { } +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) { @@ -866,6 +925,7 @@ pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *m 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() } @@ -877,9 +937,15 @@ type nativeFundingCreated = nativeFundingCreatedImport; #[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, } @@ -890,8 +956,9 @@ impl Drop for FundingCreated { } } } +/// 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_ptr: FundingCreated) { } +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) { @@ -951,6 +1018,7 @@ pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> cra 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 { @@ -976,6 +1044,7 @@ pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const 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() } @@ -987,9 +1056,15 @@ type nativeFundingSigned = nativeFundingSignedImport; #[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, } @@ -1000,8 +1075,9 @@ impl Drop for FundingSigned { } } } +/// 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_ptr: FundingSigned) { } +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) { @@ -1039,6 +1115,7 @@ pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate 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 { @@ -1062,6 +1139,7 @@ pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *m 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() } @@ -1073,9 +1151,15 @@ type nativeFundingLocked = nativeFundingLockedImport; #[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, } @@ -1086,8 +1170,9 @@ impl Drop for FundingLocked { } } } +/// 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_ptr: FundingLocked) { } +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) { @@ -1125,6 +1210,7 @@ pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &Funding 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 { @@ -1148,6 +1234,7 @@ pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *m 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() } @@ -1159,9 +1246,15 @@ type nativeShutdown = nativeShutdownImport; #[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, } @@ -1172,8 +1265,9 @@ impl Drop for Shutdown { } } } +/// 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_ptr: Shutdown) { } +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) { @@ -1213,6 +1307,7 @@ pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_typ 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 { @@ -1236,6 +1331,7 @@ pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_ 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() } @@ -1247,9 +1343,15 @@ type nativeClosingSigned = nativeClosingSignedImport; #[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, } @@ -1260,8 +1362,9 @@ impl Drop for ClosingSigned { } } } +/// 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_ptr: ClosingSigned) { } +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) { @@ -1310,6 +1413,7 @@ pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate 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 { @@ -1334,6 +1438,7 @@ pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *m 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() } @@ -1345,9 +1450,15 @@ type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport; #[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, } @@ -1358,8 +1469,9 @@ impl Drop for UpdateAddHTLC { } } } +/// 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_ptr: UpdateAddHTLC) { } +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) { @@ -1445,6 +1557,7 @@ pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *m 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() } @@ -1456,9 +1569,15 @@ type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport; #[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, } @@ -1469,8 +1588,9 @@ impl Drop for UpdateFulfillHTLC { } } } +/// 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_ptr: UpdateFulfillHTLC) { } +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) { @@ -1519,6 +1639,7 @@ pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfil 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 { @@ -1543,6 +1664,7 @@ pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const 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() } @@ -1554,9 +1676,15 @@ type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport; #[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, } @@ -1567,8 +1695,9 @@ impl Drop for UpdateFailHTLC { } } } +/// 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_ptr: UpdateFailHTLC) { } +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) { @@ -1621,6 +1750,7 @@ pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const 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() } @@ -1632,9 +1762,15 @@ type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport; #[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, } @@ -1645,8 +1781,9 @@ impl Drop for UpdateFailMalformedHTLC { } } } +/// 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_ptr: UpdateFailMalformedHTLC) { } +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) { @@ -1710,6 +1847,7 @@ pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_v 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() } @@ -1721,9 +1859,15 @@ type nativeCommitmentSigned = nativeCommitmentSignedImport; #[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, } @@ -1734,8 +1878,9 @@ impl Drop for CommitmentSigned { } } } +/// 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_ptr: CommitmentSigned) { } +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) { @@ -1779,6 +1924,7 @@ pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut Commitment 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 { @@ -1804,6 +1950,7 @@ pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const 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() } @@ -1815,9 +1962,15 @@ type nativeRevokeAndACK = nativeRevokeAndACKImport; #[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, } @@ -1828,8 +1981,9 @@ impl Drop for RevokeAndACK { } } } +/// 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_ptr: RevokeAndACK) { } +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) { @@ -1878,6 +2032,7 @@ pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAn 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 { @@ -1902,6 +2057,7 @@ pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mu 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() } @@ -1913,9 +2069,15 @@ type nativeUpdateFee = nativeUpdateFeeImport; #[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, } @@ -1926,8 +2088,9 @@ impl Drop for UpdateFee { } } } +/// 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_ptr: UpdateFee) { } +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) { @@ -1965,6 +2128,7 @@ pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 { 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 { @@ -1988,6 +2152,7 @@ pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c 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() } @@ -2002,9 +2167,15 @@ type nativeDataLossProtect = nativeDataLossProtectImport; #[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, } @@ -2015,8 +2186,9 @@ impl Drop for DataLossProtect { } } } +/// 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_ptr: DataLossProtect) { } +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) { @@ -2056,6 +2228,7 @@ pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: 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 { @@ -2079,6 +2252,7 @@ pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const 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() } @@ -2090,9 +2264,15 @@ type nativeChannelReestablish = nativeChannelReestablishImport; #[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, } @@ -2103,8 +2283,9 @@ impl Drop for ChannelReestablish { } } } +/// 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_ptr: ChannelReestablish) { } +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) { @@ -2168,6 +2349,7 @@ pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const 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() } @@ -2179,9 +2361,15 @@ type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport; #[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, } @@ -2192,8 +2380,9 @@ impl Drop for AnnouncementSignatures { } } } +/// 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_ptr: AnnouncementSignatures) { } +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) { @@ -2253,6 +2442,7 @@ pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &Announ 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 { @@ -2278,6 +2468,7 @@ pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_vo 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() } @@ -2288,26 +2479,36 @@ pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> 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, }, } @@ -2458,17 +2659,21 @@ impl NetAddress { } } } +/// 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() }; @@ -2482,9 +2687,15 @@ type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport; #[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, } @@ -2495,8 +2706,9 @@ impl Drop for UnsignedNodeAnnouncement { } } } +/// 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_ptr: UnsignedNodeAnnouncement) { } +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) { @@ -2592,6 +2804,7 @@ pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_ 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() } @@ -2603,9 +2816,15 @@ type nativeNodeAnnouncement = nativeNodeAnnouncementImport; #[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, } @@ -2616,8 +2835,9 @@ impl Drop for NodeAnnouncement { } } } +/// 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_ptr: NodeAnnouncement) { } +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) { @@ -2655,6 +2875,7 @@ pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> 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 { @@ -2678,6 +2899,7 @@ pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const 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() } @@ -2689,9 +2911,15 @@ type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport #[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, } @@ -2702,8 +2930,9 @@ impl Drop for UnsignedChannelAnnouncement { } } } +/// 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_ptr: UnsignedChannelAnnouncement) { } +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) { @@ -2811,6 +3040,7 @@ pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const 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() } @@ -2822,9 +3052,15 @@ type nativeChannelAnnouncement = nativeChannelAnnouncementImport; #[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, } @@ -2835,8 +3071,9 @@ impl Drop for ChannelAnnouncement { } } } +/// 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_ptr: ChannelAnnouncement) { } +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) { @@ -2907,6 +3144,7 @@ pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncemen 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 { @@ -2933,6 +3171,7 @@ pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const 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() } @@ -2944,9 +3183,15 @@ type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport; #[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, } @@ -2957,8 +3202,9 @@ impl Drop for UnsignedChannelUpdate { } } } +/// 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_ptr: UnsignedChannelUpdate) { } +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) { @@ -3077,6 +3323,7 @@ pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_voi 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() } @@ -3088,9 +3335,15 @@ type nativeChannelUpdate = nativeChannelUpdateImport; #[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, } @@ -3101,8 +3354,9 @@ impl Drop for ChannelUpdate { } } } +/// 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_ptr: ChannelUpdate) { } +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) { @@ -3140,6 +3394,7 @@ pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate: 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 { @@ -3163,6 +3418,7 @@ pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *m 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() } @@ -3177,9 +3433,15 @@ type nativeQueryChannelRange = nativeQueryChannelRangeImport; #[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, } @@ -3190,8 +3452,9 @@ impl Drop for QueryChannelRange { } } } +/// 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_ptr: QueryChannelRange) { } +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) { @@ -3240,6 +3503,7 @@ pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannel 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 { @@ -3264,6 +3528,7 @@ pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const 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() } @@ -3281,9 +3546,15 @@ type nativeReplyChannelRange = nativeReplyChannelRangeImport; #[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, } @@ -3294,8 +3565,9 @@ impl Drop for ReplyChannelRange { } } } +/// 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_ptr: ReplyChannelRange) { } +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) { @@ -3361,6 +3633,7 @@ pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyCh 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 { @@ -3388,6 +3661,7 @@ pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const 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() } @@ -3406,9 +3680,15 @@ type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport; #[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, } @@ -3419,8 +3699,9 @@ impl Drop for QueryShortChannelIds { } } } +/// 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_ptr: QueryShortChannelIds) { } +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) { @@ -3453,6 +3734,7 @@ pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut Quer 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 { @@ -3477,6 +3759,7 @@ pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const 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() } @@ -3491,9 +3774,15 @@ type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport; #[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, } @@ -3504,8 +3793,9 @@ impl Drop for ReplyShortChannelIdsEnd { } } } +/// 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_ptr: ReplyShortChannelIdsEnd) { } +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) { @@ -3545,6 +3835,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyS 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 { @@ -3568,6 +3859,7 @@ pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_v 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() } @@ -3581,9 +3873,15 @@ type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport; #[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, } @@ -3594,8 +3892,9 @@ impl Drop for GossipTimestampFilter { } } } +/// 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_ptr: GossipTimestampFilter) { } +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) { @@ -3644,6 +3943,7 @@ pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTim 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 { @@ -3668,6 +3968,7 @@ pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_voi 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() } @@ -3678,12 +3979,14 @@ pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> G 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, }, } @@ -3762,8 +4065,10 @@ impl ErrorAction { } } } +/// 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() @@ -3776,9 +4081,15 @@ type nativeLightningError = nativeLightningErrorImport; #[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, } @@ -3789,8 +4100,9 @@ impl Drop for LightningError { } } } +/// 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_ptr: LightningError) { } +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) { @@ -3828,6 +4140,7 @@ pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate: 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 { @@ -3851,6 +4164,7 @@ pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const 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() } @@ -3863,9 +4177,15 @@ type nativeCommitmentUpdate = nativeCommitmentUpdateImport; #[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, } @@ -3876,8 +4196,9 @@ impl Drop for CommitmentUpdate { } } } +/// 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_ptr: CommitmentUpdate) { } +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) { @@ -3941,6 +4262,7 @@ pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUp 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 { @@ -3973,6 +4295,7 @@ pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const 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() } @@ -3985,16 +4308,24 @@ pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentU 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, }, } @@ -4099,8 +4430,10 @@ impl HTLCFailChannelUpdate { } } } +/// 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() @@ -4111,6 +4444,8 @@ pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> H /// 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), @@ -4153,7 +4488,10 @@ pub struct ChannelMessageHandler { pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish), /// Handle an incoming error message from the given peer. pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage), +/// 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 { @@ -4252,6 +4590,8 @@ impl Drop for ChannelMessageHandler { /// 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. @@ -4301,7 +4641,10 @@ pub struct RoutingMessageHandler { /// 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 {} @@ -4387,6 +4730,7 @@ impl Drop for RoutingMessageHandler { } } #[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 }) } @@ -4395,12 +4739,14 @@ pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate:: 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 }) } @@ -4409,12 +4755,14 @@ pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) - 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 }) } @@ -4423,12 +4771,14 @@ pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> cr 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 }) } @@ -4437,12 +4787,14 @@ pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate:: 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 }) } @@ -4451,12 +4803,14 @@ pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crat 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 }) } @@ -4465,12 +4819,14 @@ pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate: 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 }) } @@ -4479,12 +4835,14 @@ pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate:: 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 }) } @@ -4493,12 +4851,14 @@ pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate:: 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 }) } @@ -4507,12 +4867,14 @@ pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types:: 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 }) } @@ -4521,12 +4883,14 @@ pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_ 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 }) } @@ -4535,12 +4899,14 @@ pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c 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 }) } @@ -4549,12 +4915,14 @@ pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_typ 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 }) } @@ -4563,12 +4931,14 @@ pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate: 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 }) } @@ -4577,12 +4947,14 @@ pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) 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 }) } @@ -4591,12 +4963,14 @@ pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_ty 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 }) } @@ -4605,12 +4979,14 @@ pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> cra 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 }) } @@ -4619,12 +4995,14 @@ pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate:: 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 }) } @@ -4633,12 +5011,14 @@ pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types:: 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 }) } @@ -4647,12 +5027,14 @@ pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types:: 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 }) } @@ -4661,12 +5043,14 @@ pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_vo 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 }) } @@ -4675,12 +5059,14 @@ pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> c 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 }) } @@ -4689,12 +5075,14 @@ pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> 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 }) } @@ -4703,12 +5091,14 @@ pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate:: 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 }) } @@ -4717,12 +5107,14 @@ pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c 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 }) } @@ -4731,12 +5123,14 @@ pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) 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 }) } @@ -4745,18 +5139,21 @@ pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crat 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 }) } @@ -4765,12 +5162,14 @@ pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> 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 }) } @@ -4779,12 +5178,14 @@ pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) } #[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 }) } @@ -4793,12 +5194,14 @@ pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> cra 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 }) } @@ -4807,12 +5210,14 @@ pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> cra 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 }) } diff --git a/lightning-c-bindings/src/ln/peer_handler.rs b/lightning-c-bindings/src/ln/peer_handler.rs index 9e7422a..6cb11f3 100644 --- a/lightning-c-bindings/src/ln/peer_handler.rs +++ b/lightning-c-bindings/src/ln/peer_handler.rs @@ -19,9 +19,15 @@ type nativeIgnoringMessageHandler = nativeIgnoringMessageHandlerImport; #[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, } @@ -32,8 +38,9 @@ impl Drop for IgnoringMessageHandler { } } } +/// 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_ptr: IgnoringMessageHandler) { } +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) { @@ -49,6 +56,7 @@ impl IgnoringMessageHandler { ret } } +/// Constructs a new IgnoringMessageHandler given each field #[must_use] #[no_mangle] pub extern "C" fn IgnoringMessageHandler_new() -> IgnoringMessageHandler { @@ -65,6 +73,8 @@ impl From for crate::util::events::MessageSendEven 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 { @@ -91,6 +101,8 @@ impl From for crate::ln::msgs::RoutingMessageHandl 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 { @@ -192,9 +204,15 @@ type nativeErroringMessageHandler = nativeErroringMessageHandlerImport; #[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, } @@ -205,8 +223,9 @@ impl Drop for ErroringMessageHandler { } } } +/// 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_ptr: ErroringMessageHandler) { } +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) { @@ -240,6 +259,8 @@ impl From for crate::util::events::MessageSendEven 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 { @@ -266,6 +287,8 @@ impl From for crate::ln::msgs::ChannelMessageHandl 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 { @@ -370,9 +393,15 @@ type nativeMessageHandler = nativeMessageHandlerImport 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 { @@ -447,6 +478,8 @@ pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::ln::msgs::Chan /// 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. /// @@ -470,9 +503,17 @@ pub struct SocketDescriptor { /// 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 {} @@ -483,6 +524,7 @@ 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 }, @@ -540,9 +582,15 @@ type nativePeerHandleError = nativePeerHandleErrorImport; #[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, } @@ -553,8 +601,9 @@ impl Drop for PeerHandleError { } } } +/// 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_ptr: PeerHandleError) { } +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) { @@ -583,6 +632,7 @@ pub extern "C" fn PeerHandleError_get_no_connection_possible(this_ptr: &PeerHand 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 { @@ -605,6 +655,7 @@ pub(crate) extern "C" fn PeerHandleError_clone_void(this_ptr: *const 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() } @@ -623,9 +674,15 @@ type nativePeerManager = nativePeerManagerImport *mu 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() } @@ -70,9 +78,15 @@ type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>; #[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, } @@ -83,8 +97,9 @@ impl Drop for LockedNetworkGraph { } } } +/// 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_ptr: LockedNetworkGraph) { } +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) { @@ -112,9 +127,15 @@ type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport for crate::ln::msgs::RoutingMessageHandler { 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 { @@ -305,6 +329,8 @@ impl From for crate::util::events::MessageSendEventsPr 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 { @@ -330,9 +356,15 @@ type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport; #[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, } @@ -343,8 +375,9 @@ impl Drop for DirectionalChannelInfo { } } } +/// 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_ptr: DirectionalChannelInfo) { } +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) { @@ -451,10 +484,12 @@ pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_vo 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 }) } @@ -463,6 +498,7 @@ pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) - 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() }; @@ -477,9 +513,15 @@ type nativeChannelInfo = nativeChannelInfoImport; #[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, } @@ -490,8 +532,9 @@ impl Drop for ChannelInfo { } } } +/// 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_ptr: ChannelInfo) { } +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) { @@ -600,10 +643,12 @@ pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut 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 }) } @@ -612,6 +657,7 @@ pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_ 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() }; @@ -625,9 +671,15 @@ type nativeRoutingFees = nativeRoutingFeesImport; #[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, } @@ -638,8 +690,9 @@ impl Drop for RoutingFees { } } } +/// 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_ptr: RoutingFees) { } +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) { @@ -679,6 +732,7 @@ pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees 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 { @@ -702,16 +756,19 @@ pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut 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 }) } @@ -727,9 +784,15 @@ type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport; #[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, } @@ -740,8 +803,9 @@ impl Drop for NodeAnnouncementInfo { } } } +/// 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_ptr: NodeAnnouncementInfo) { } +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) { @@ -832,6 +896,7 @@ pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut N 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 { @@ -861,10 +926,12 @@ pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const 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 }) } @@ -873,6 +940,7 @@ pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> 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() }; @@ -886,9 +954,15 @@ type nativeNodeInfo = nativeNodeInfoImport; #[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, } @@ -899,8 +973,9 @@ impl Drop for NodeInfo { } } } +/// 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_ptr: NodeInfo) { } +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) { @@ -956,6 +1031,7 @@ pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut va 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 { @@ -983,10 +1059,12 @@ pub(crate) extern "C" fn NodeInfo_clone_void(this_ptr: *const c_void) -> *mut c_ 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 }) } @@ -995,12 +1073,14 @@ pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_typ 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 }) } @@ -1009,6 +1089,7 @@ pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c 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() }; diff --git a/lightning-c-bindings/src/routing/router.rs b/lightning-c-bindings/src/routing/router.rs index 32b4aeb..496781f 100644 --- a/lightning-c-bindings/src/routing/router.rs +++ b/lightning-c-bindings/src/routing/router.rs @@ -15,9 +15,15 @@ type nativeRouteHop = nativeRouteHopImport; #[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, } @@ -28,8 +34,9 @@ impl Drop for RouteHop { } } } +/// 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_ptr: RouteHop) { } +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) { @@ -121,6 +128,7 @@ pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 { 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 { @@ -148,6 +156,7 @@ pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_ 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() } @@ -160,9 +169,15 @@ type nativeRoute = nativeRouteImport; #[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, } @@ -173,8 +188,9 @@ impl Drop for Route { } } } +/// 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_ptr: Route) { } +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) { @@ -201,6 +217,7 @@ pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types: 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 { @@ -224,10 +241,12 @@ pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_voi 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 }) } @@ -236,6 +255,7 @@ pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types: 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() }; @@ -249,9 +269,15 @@ type nativeRouteHint = nativeRouteHintImport; #[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, } @@ -262,8 +288,9 @@ impl Drop for RouteHint { } } } +/// 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_ptr: RouteHint) { } +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) { @@ -338,11 +365,15 @@ pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c 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. /// @@ -358,10 +389,11 @@ pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { /// 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, 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 { +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_first_hops, &local_last_hops[..], final_value_msat, final_cltv, logger); + 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 index 9f8769d..a680d5c 100644 --- a/lightning-c-bindings/src/util/config.rs +++ b/lightning-c-bindings/src/util/config.rs @@ -15,9 +15,15 @@ type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport; #[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, } @@ -28,8 +34,9 @@ impl Drop for ChannelHandshakeConfig { } } } +/// 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_ptr: ChannelHandshakeConfig) { } +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) { @@ -120,6 +127,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &Ch 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 { @@ -144,9 +152,11 @@ pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_vo 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 { @@ -170,9 +180,15 @@ type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport; #[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, } @@ -183,8 +199,9 @@ impl Drop for ChannelHandshakeLimits { } } } +/// 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_ptr: ChannelHandshakeLimits) { } +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) { @@ -378,8 +395,8 @@ pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference( /// Not checking this value would be a security issue, as our peer would be able to set it to /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. /// -/// Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value -/// so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) +/// 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; @@ -390,12 +407,13 @@ pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &Chan /// Not checking this value would be a security issue, as our peer would be able to set it to /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. /// -/// Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value -/// so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) +/// 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 { @@ -427,9 +445,11 @@ pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_vo 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 { @@ -444,9 +464,15 @@ type nativeChannelConfig = nativeChannelConfigImport; #[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, } @@ -457,8 +483,9 @@ impl Drop for ChannelConfig { } } } +/// 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_ptr: ChannelConfig) { } +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) { @@ -555,6 +582,7 @@ pub extern "C" fn ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &Ch 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 announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool) -> ChannelConfig { @@ -579,15 +607,18 @@ pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *m 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 }) } @@ -596,6 +627,7 @@ pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate:: 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() }; @@ -612,9 +644,15 @@ type nativeUserConfig = nativeUserConfigImport; #[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, } @@ -625,8 +663,9 @@ impl Drop for UserConfig { } } } +/// 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_ptr: UserConfig) { } +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) { @@ -675,6 +714,7 @@ pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate 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 { @@ -699,9 +739,11 @@ pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut 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 { diff --git a/lightning-c-bindings/src/util/errors.rs b/lightning-c-bindings/src/util/errors.rs index 9b0e757..d24df67 100644 --- a/lightning-c-bindings/src/util/errors.rs +++ b/lightning-c-bindings/src/util/errors.rs @@ -13,24 +13,29 @@ 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 @@ -158,8 +163,10 @@ impl APIError { } } } +/// 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 index 5289367..3ec8def 100644 --- a/lightning-c-bindings/src/util/events.rs +++ b/lightning-c-bindings/src/util/events.rs @@ -24,16 +24,24 @@ pub enum Event { /// 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, }, /// Used to indicate that the client may now broadcast the funding transaction it created for a /// channel. Broadcasting such a transaction prior to this event may lead to our counterparty /// trivially stealing all funds in the funding transaction! FundingBroadcastSafe { + /// The output, which was passed to ChannelManager::funding_transaction_generated, which is + /// now safe to broadcast. funding_txo: crate::chain::transaction::OutPoint, + /// 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 @@ -47,8 +55,21 @@ pub enum Event { /// 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 @@ -56,6 +77,9 @@ pub enum Event { /// 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 @@ -63,12 +87,20 @@ pub enum Event { /// 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. @@ -76,6 +108,7 @@ pub enum Event { /// 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, }, } @@ -306,13 +339,16 @@ impl Event { } } } +/// 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()) } @@ -326,59 +362,81 @@ 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 @@ -390,36 +448,47 @@ pub enum MessageSendEvent { /// 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, }, } @@ -932,8 +1001,10 @@ impl MessageSendEvent { } } } +/// 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() @@ -941,11 +1012,15 @@ pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSend /// 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, } @@ -979,11 +1054,15 @@ impl Drop for MessageSendEventsProvider { /// 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, } diff --git a/lightning-c-bindings/src/util/logger.rs b/lightning-c-bindings/src/util/logger.rs index 8a1fbb1..9099450 100644 --- a/lightning-c-bindings/src/util/logger.rs +++ b/lightning-c-bindings/src/util/logger.rs @@ -74,6 +74,7 @@ impl Level { } } } +/// Creates a copy of the Level #[no_mangle] pub extern "C" fn Level_clone(orig: &Level) -> Level { orig.clone() @@ -89,9 +90,13 @@ pub extern "C" fn Level_max() -> crate::util::logger::Level { /// 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 {} diff --git a/lightning-c-bindings/src/util/macro_logger.rs b/lightning-c-bindings/src/util/macro_logger.rs deleted file mode 100644 index 79c1ea1..0000000 --- a/lightning-c-bindings/src/util/macro_logger.rs +++ /dev/null @@ -1,6 +0,0 @@ -/// Logging macro utilities. - -use std::ffi::c_void; -use bitcoin::hashes::Hash; -use crate::c_types::*; - diff --git a/lightning-c-bindings/src/util/mod.rs b/lightning-c-bindings/src/util/mod.rs index 8e5bf04..c35bf64 100644 --- a/lightning-c-bindings/src/util/mod.rs +++ b/lightning-c-bindings/src/util/mod.rs @@ -7,6 +7,5 @@ use crate::c_types::*; pub mod events; pub mod errors; pub mod ser; -pub mod macro_logger; pub mod logger; pub mod config; diff --git a/lightning-c-bindings/src/util/ser.rs b/lightning-c-bindings/src/util/ser.rs index db9549c..b088e96 100644 --- a/lightning-c-bindings/src/util/ser.rs +++ b/lightning-c-bindings/src/util/ser.rs @@ -5,6 +5,7 @@ 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; -- 2.39.5