#else
#define NONNULL_PTR
#endif
+struct nativeBlindedRouteOpaque;
+typedef struct nativeBlindedRouteOpaque LDKnativeBlindedRoute;
+struct nativeBlindedHopOpaque;
+typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop;
struct nativeCounterpartyCommitmentSecretsOpaque;
typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets;
struct nativeTxCreationKeysOpaque;
typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput;
struct nativeMultiThreadedLockableScoreOpaque;
typedef struct nativeMultiThreadedLockableScoreOpaque LDKnativeMultiThreadedLockableScore;
+struct nativeMultiThreadedScoreLockOpaque;
+typedef struct nativeMultiThreadedScoreLockOpaque LDKnativeMultiThreadedScoreLock;
struct nativeChannelUsageOpaque;
typedef struct nativeChannelUsageOpaque LDKnativeChannelUsage;
struct nativeFixedPenaltyScorerOpaque;
typedef struct nativeOutPointOpaque LDKnativeOutPoint;
struct nativeInvoicePayerOpaque;
typedef struct nativeInvoicePayerOpaque LDKnativeInvoicePayer;
+struct nativeInFlightHtlcsOpaque;
+typedef struct nativeInFlightHtlcsOpaque LDKnativeInFlightHtlcs;
struct nativeInvoiceOpaque;
typedef struct nativeInvoiceOpaque LDKnativeInvoice;
struct nativeSignedRawInvoiceOpaque;
typedef struct nativePeerHandleErrorOpaque LDKnativePeerHandleError;
struct nativePeerManagerOpaque;
typedef struct nativePeerManagerOpaque LDKnativePeerManager;
+struct nativeOnionMessengerOpaque;
+typedef struct nativeOnionMessengerOpaque LDKnativeOnionMessenger;
struct nativeRapidGossipSyncOpaque;
typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync;
struct nativeDecodeErrorOpaque;
typedef struct nativeClosingSignedOpaque LDKnativeClosingSigned;
struct nativeUpdateAddHTLCOpaque;
typedef struct nativeUpdateAddHTLCOpaque LDKnativeUpdateAddHTLC;
+struct nativeOnionMessageOpaque;
+typedef struct nativeOnionMessageOpaque LDKnativeOnionMessage;
struct nativeUpdateFulfillHTLCOpaque;
typedef struct nativeUpdateFulfillHTLCOpaque LDKnativeUpdateFulfillHTLC;
struct nativeUpdateFailHTLCOpaque;
typedef struct nativeDefaultRouterOpaque LDKnativeDefaultRouter;
struct nativeRecordOpaque;
typedef struct nativeRecordOpaque LDKnativeRecord;
+struct nativeFutureOpaque;
+typedef struct nativeFutureOpaque LDKnativeFuture;
struct nativeMonitorUpdateIdOpaque;
typedef struct nativeMonitorUpdateIdOpaque LDKnativeMonitorUpdateId;
struct nativeLockedChannelMonitorOpaque;
uint64_t value;
} LDKTxOut;
+/**
+ * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array.
+ */
+typedef struct LDKPublicKey {
+ /**
+ * The bytes of the public key
+ */
+ uint8_t compressed_form[33];
+} LDKPublicKey;
+
+/**
+ * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_PublicKeyZ {
+ /**
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ */
+ struct LDKPublicKey *data;
+ /**
+ * The number of elements pointed to by `data`.
+ */
+ uintptr_t datalen;
+} LDKCVec_PublicKeyZ;
+
+
+
+/**
+ * Onion messages can be sent and received to blinded routes, which serve to hide the identity of
+ * the recipient.
+ */
+typedef struct MUST_USE_STRUCT LDKBlindedRoute {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeBlindedRoute *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;
+} LDKBlindedRoute;
+
+/**
+ * The contents of CResult_BlindedRouteNoneZ
+ */
+typedef union LDKCResult_BlindedRouteNoneZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKBlindedRoute *result;
+ /**
+ * Note that this value is always NULL, as there are no contents in the Err variant
+ */
+ void *err;
+} LDKCResult_BlindedRouteNoneZPtr;
+
+/**
+ * A CResult_BlindedRouteNoneZ represents the result of a fallible operation,
+ * containing a crate::lightning::onion_message::blinded_route::BlindedRoute on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_BlindedRouteNoneZ {
+ /**
+ * The contents of this CResult_BlindedRouteNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_BlindedRouteNoneZPtr contents;
+ /**
+ * Whether this CResult_BlindedRouteNoneZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_BlindedRouteNoneZ;
+
+
+
+/**
+ * An error in decoding a message or struct.
+ */
+typedef struct MUST_USE_STRUCT LDKDecodeError {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeDecodeError *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKDecodeError;
+
+/**
+ * The contents of CResult_BlindedRouteDecodeErrorZ
+ */
+typedef union LDKCResult_BlindedRouteDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKBlindedRoute *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_BlindedRouteDecodeErrorZPtr;
+
+/**
+ * A CResult_BlindedRouteDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::onion_message::blinded_route::BlindedRoute on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_BlindedRouteDecodeErrorZ {
+ /**
+ * The contents of this CResult_BlindedRouteDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_BlindedRouteDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_BlindedRouteDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_BlindedRouteDecodeErrorZ;
+
+
+
+/**
+ * Used to construct the blinded hops portion of a blinded route. These hops cannot be identified
+ * by outside observers and thus can be used to hide the identity of the recipient.
+ */
+typedef struct MUST_USE_STRUCT LDKBlindedHop {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeBlindedHop *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;
+} LDKBlindedHop;
+
+/**
+ * The contents of CResult_BlindedHopDecodeErrorZ
+ */
+typedef union LDKCResult_BlindedHopDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKBlindedHop *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_BlindedHopDecodeErrorZPtr;
+
+/**
+ * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::onion_message::blinded_route::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_BlindedHopDecodeErrorZ {
+ /**
+ * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_BlindedHopDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_BlindedHopDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_BlindedHopDecodeErrorZ;
+
/**
* The contents of CResult_NoneNoneZ
*/
bool is_owned;
} LDKCounterpartyCommitmentSecrets;
-
-
-/**
- * An error in decoding a message or struct.
- */
-typedef struct MUST_USE_STRUCT LDKDecodeError {
- /**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeDecodeError *inner;
- /**
- * Indicates that this is the only struct which contains the same pointer.
- * Rust functions which take ownership of an object provided via an argument require
- * this to be true and invalidate the object pointed to by inner.
- */
- bool is_owned;
-} LDKDecodeError;
-
/**
* The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ
*/
bool result_ok;
} LDKCResult_SecretKeyErrorZ;
-/**
- * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array.
- */
-typedef struct LDKPublicKey {
- /**
- * The bytes of the public key
- */
- uint8_t compressed_form[33];
-} LDKPublicKey;
-
/**
* The contents of CResult_PublicKeyErrorZ
*/
bool result_ok;
} LDKCResult_ShutdownScriptInvalidShutdownScriptZ;
+
+
/**
- * The contents of CResult_NoneErrorZ
+ * Represents the compressed public key of a node
*/
-typedef union LDKCResult_NoneErrorZPtr {
+typedef struct MUST_USE_STRUCT LDKNodeId {
/**
- * Note that this value is always NULL, as there are no contents in the OK variant
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- void *result;
+ LDKnativeNodeId *inner;
/**
- * A pointer to the contents in the error state.
- * Reading from this pointer when `result_ok` is set is undefined.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- enum LDKIOError *err;
-} LDKCResult_NoneErrorZPtr;
+ bool is_owned;
+} LDKNodeId;
+
+
/**
- * A CResult_NoneErrorZ represents the result of a fallible operation,
- * containing a () on success and a crate::c_types::IOError on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`].
*/
-typedef struct LDKCResult_NoneErrorZ {
+typedef struct MUST_USE_STRUCT LDKChannelUsage {
/**
- * The contents of this CResult_NoneErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- union LDKCResult_NoneErrorZPtr contents;
+ LDKnativeChannelUsage *inner;
/**
- * Whether this CResult_NoneErrorZ represents a success state.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- bool result_ok;
-} LDKCResult_NoneErrorZ;
+ bool is_owned;
+} LDKChannelUsage;
bool is_owned;
} LDKRouteHop;
+/**
+ * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_RouteHopZ {
+ /**
+ * The elements in the array.
+ * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ */
+ struct LDKRouteHop *data;
+ /**
+ * The number of elements pointed to by `data`.
+ */
+ uintptr_t datalen;
+} LDKCVec_RouteHopZ;
+
+/**
+ * An interface used to score payment channels for path finding.
+ *
+ *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel.
+ */
+typedef struct LDKScore {
+ /**
+ * 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 fee in msats willing to be paid to avoid routing `send_amt_msat` through the
+ * given channel in the direction from `source` to `target`.
+ *
+ * The channel's capacity (less any other MPP parts that are also being considered for use in
+ * the same payment) is given by `capacity_msat`. It may be determined from various sources
+ * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
+ * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
+ * Thus, implementations should be overflow-safe.
+ */
+ uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage);
+ /**
+ * Handles updating channel penalties after failing to route through a channel.
+ */
+ void (*payment_path_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ /**
+ * Handles updating channel penalties after successfully routing along a path.
+ */
+ void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path);
+ /**
+ * Handles updating channel penalties after a probe over the given path failed.
+ */
+ void (*probe_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ /**
+ * Handles updating channel penalties after a probe over the given path succeeded.
+ */
+ void (*probe_successful)(void *this_arg, struct LDKCVec_RouteHopZ path);
+ /**
+ * Serialize the object into a byte array
+ */
+ struct LDKCVec_u8Z (*write)(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);
+} LDKScore;
+
+/**
+ * A scorer that is accessed under a lock.
+ *
+ * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while
+ * having shared ownership of a scorer but without requiring internal locking in [`Score`]
+ * implementations. Internal locking would be detrimental to route finding performance and could
+ * result in [`Score::channel_penalty_msat`] returning a different value for the same channel.
+ *
+ * [`find_route`]: crate::routing::router::find_route
+ */
+typedef struct LDKLockableScore {
+ /**
+ * 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 locked scorer.
+ */
+ struct LDKScore (*lock)(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);
+} LDKLockableScore;
+
+/**
+ * Refers to a scorer that is accessible under lock and also writeable to disk
+ *
+ * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to
+ * use the Persister to persist it.
+ */
+typedef struct LDKWriteableScore {
+ /**
+ * 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;
+ /**
+ * Implementation of LockableScore for this object.
+ */
+ struct LDKLockableScore LockableScore;
+ /**
+ * Serialize the object into a byte array
+ */
+ struct LDKCVec_u8Z (*write)(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);
+} LDKWriteableScore;
+
+/**
+ * An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not
+ */
+typedef enum LDKCOption_WriteableScoreZ_Tag {
+ /**
+ * When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore
+ */
+ LDKCOption_WriteableScoreZ_Some,
+ /**
+ * When we're in this state, this COption_WriteableScoreZ contains nothing
+ */
+ LDKCOption_WriteableScoreZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_WriteableScoreZ_Sentinel,
+} LDKCOption_WriteableScoreZ_Tag;
+
+typedef struct LDKCOption_WriteableScoreZ {
+ LDKCOption_WriteableScoreZ_Tag tag;
+ union {
+ struct {
+ struct LDKWriteableScore some;
+ };
+ };
+} LDKCOption_WriteableScoreZ;
+
+/**
+ * The contents of CResult_NoneErrorZ
+ */
+typedef union LDKCResult_NoneErrorZPtr {
+ /**
+ * Note that this value is always NULL, as there are no contents in the OK variant
+ */
+ void *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ enum LDKIOError *err;
+} LDKCResult_NoneErrorZPtr;
+
+/**
+ * A CResult_NoneErrorZ represents the result of a fallible operation,
+ * containing a () on success and a crate::c_types::IOError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_NoneErrorZ {
+ /**
+ * The contents of this CResult_NoneErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_NoneErrorZPtr contents;
+ /**
+ * Whether this CResult_NoneErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_NoneErrorZ;
+
/**
* The contents of CResult_RouteHopDecodeErrorZ
*/
bool result_ok;
} LDKCResult_RouteHopDecodeErrorZ;
-/**
- * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_RouteHopZ {
- /**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- */
- struct LDKRouteHop *data;
- /**
- * The number of elements pointed to by `data`.
- */
- uintptr_t datalen;
-} LDKCVec_RouteHopZ;
-
/**
* A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size.
* This corresponds to std::vector in C++
* containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure.
* `result_ok` indicates the overall state, and the contents are provided via `contents`.
*/
-typedef struct LDKCResult_RouteLightningErrorZ {
- /**
- * The contents of this CResult_RouteLightningErrorZ, accessible via either
- * `err` or `result` depending on the state of `result_ok`.
- */
- union LDKCResult_RouteLightningErrorZPtr contents;
- /**
- * Whether this CResult_RouteLightningErrorZ represents a success state.
- */
- bool result_ok;
-} LDKCResult_RouteLightningErrorZ;
-
-/**
- * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_PublicKeyZ {
+typedef struct LDKCResult_RouteLightningErrorZ {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * The contents of this CResult_RouteLightningErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
*/
- struct LDKPublicKey *data;
+ union LDKCResult_RouteLightningErrorZPtr contents;
/**
- * The number of elements pointed to by `data`.
+ * Whether this CResult_RouteLightningErrorZ represents a success state.
*/
- uintptr_t datalen;
-} LDKCVec_PublicKeyZ;
+ bool result_ok;
+} LDKCResult_RouteLightningErrorZ;
/**
* Arbitrary 32 bytes, which could represent one of a few different things. You probably want to
* 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;
+ bool payment_failed_permanently;
/**
* Any failure information conveyed via the Onion return packet by a node along the failed
* payment route.
-/**
- * A node_announcement message to be sent or received from a peer
- */
-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;
-
-
-
/**
* An error message to be sent or received from a peer
*/
* Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
*/
LDKMessageSendEvent_SendChannelReestablish,
+ /**
+ * Used to send a channel_announcement and channel_update to a specific peer, likely on
+ * initial connection to ensure our peers know about our channels.
+ */
+ LDKMessageSendEvent_SendChannelAnnouncement,
/**
* Used to indicate that a channel_announcement and channel_update should be broadcast to all
* peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
*
- * Note that after doing so, you very likely (unless you did so very recently) want to call
- * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
- * This ensures that any nodes which see our channel_announcement also have a relevant
+ * Note that after doing so, you very likely (unless you did so very recently) want to
+ * broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This
+ * ensures that any nodes which see our channel_announcement also have a relevant
* node_announcement, including relevant feature flags which may be important for routing
* through or to us.
+ *
+ * [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement
*/
LDKMessageSendEvent_BroadcastChannelAnnouncement,
- /**
- * Used to indicate that a node_announcement should be broadcast to all peers.
- */
- LDKMessageSendEvent_BroadcastNodeAnnouncement,
/**
* Used to indicate that a channel_update should be broadcast to all peers.
*/
struct LDKChannelReestablish msg;
} LDKMessageSendEvent_LDKSendChannelReestablish_Body;
-typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body {
+typedef struct LDKMessageSendEvent_LDKSendChannelAnnouncement_Body {
+ /**
+ * The node_id of the node which should receive this message
+ */
+ struct LDKPublicKey node_id;
/**
* The channel_announcement which should be sent.
*/
* The followup channel_update which should be sent.
*/
struct LDKChannelUpdate update_msg;
-} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body;
+} LDKMessageSendEvent_LDKSendChannelAnnouncement_Body;
-typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body {
+typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body {
+ /**
+ * The channel_announcement which should be sent.
+ */
+ struct LDKChannelAnnouncement msg;
/**
- * The node_announcement which should be sent.
+ * The followup channel_update which should be sent.
*/
- struct LDKNodeAnnouncement msg;
-} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body;
+ struct LDKChannelUpdate update_msg;
+} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body;
typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body {
/**
LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
+ LDKMessageSendEvent_LDKSendChannelAnnouncement_Body send_channel_announcement;
LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
- LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update;
LDKMessageSendEvent_LDKHandleError_Body handle_error;
uintptr_t datalen;
} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ;
-/**
- * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not
- */
-typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag {
- /**
- * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ
- */
- LDKCOption_C2Tuple_usizeTransactionZZ_Some,
- /**
- * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing
- */
- LDKCOption_C2Tuple_usizeTransactionZZ_None,
- /**
- * Must be last for serialization purposes
- */
- LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel,
-} LDKCOption_C2Tuple_usizeTransactionZZ_Tag;
-
-typedef struct LDKCOption_C2Tuple_usizeTransactionZZ {
- LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag;
- union {
- struct {
- struct LDKC2Tuple_usizeTransactionZ some;
- };
- };
-} LDKCOption_C2Tuple_usizeTransactionZZ;
-
/**
};
} LDKCOption_C2Tuple_u64u64ZZ;
-
-
-/**
- * Represents the compressed public key of a node
- */
-typedef struct MUST_USE_STRUCT LDKNodeId {
- /**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeNodeId *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;
-} LDKNodeId;
-
/**
* A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size.
* This corresponds to std::vector in C++
} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
/**
- * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size.
- * This corresponds to std::vector in C++
+ * An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not
*/
-typedef struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+typedef enum LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag {
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- */
- struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data;
- /**
- * The number of elements pointed to by `data`.
+ * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ
*/
- uintptr_t datalen;
-} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
-
-/**
- * A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size.
- * This corresponds to std::vector in C++
- */
-typedef struct LDKCVec_NodeAnnouncementZ {
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some,
/**
- * The elements in the array.
- * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing
*/
- struct LDKNodeAnnouncement *data;
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None,
/**
- * The number of elements pointed to by `data`.
+ * Must be last for serialization purposes
*/
- uintptr_t datalen;
-} LDKCVec_NodeAnnouncementZ;
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Sentinel,
+} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag;
+
+typedef struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag tag;
+ union {
+ struct {
+ struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ some;
+ };
+ };
+} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
/**
* The contents of CResult_NoneLightningErrorZ
bool result_ok;
} LDKCResult_SecretKeyNoneZ;
+/**
+ * Represents a scalar value between zero and the secp256k1 curve order, in big endian.
+ */
+typedef struct LDKBigEndianScalar {
+ /**
+ * The bytes of the scalar value.
+ */
+ uint8_t big_endian_bytes[32];
+} LDKBigEndianScalar;
+
+/**
+ * An enum which can either contain a crate::c_types::BigEndianScalar or not
+ */
+typedef enum LDKCOption_ScalarZ_Tag {
+ /**
+ * When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar
+ */
+ LDKCOption_ScalarZ_Some,
+ /**
+ * When we're in this state, this COption_ScalarZ contains nothing
+ */
+ LDKCOption_ScalarZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_ScalarZ_Sentinel,
+} LDKCOption_ScalarZ_Tag;
+
+typedef struct LDKCOption_ScalarZ {
+ LDKCOption_ScalarZ_Tag tag;
+ union {
+ struct {
+ struct LDKBigEndianScalar some;
+ };
+ };
+} LDKCOption_ScalarZ;
+
+/**
+ * The contents of CResult_SharedSecretNoneZ
+ */
+typedef union LDKCResult_SharedSecretNoneZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKThirtyTwoBytes *result;
+ /**
+ * Note that this value is always NULL, as there are no contents in the Err variant
+ */
+ void *err;
+} LDKCResult_SharedSecretNoneZPtr;
+
+/**
+ * A CResult_SharedSecretNoneZ represents the result of a fallible operation,
+ * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_SharedSecretNoneZ {
+ /**
+ * The contents of this CResult_SharedSecretNoneZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_SharedSecretNoneZPtr contents;
+ /**
+ * Whether this CResult_SharedSecretNoneZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_SharedSecretNoneZ;
+
/**
/**
- * An update generated by the underlying Channel itself which contains some new information the
- * ChannelMonitor should be made aware of.
+ * An update generated by the underlying channel itself which contains some new information the
+ * [`ChannelMonitor`] should be made aware of.
+ *
+ * Because this represents only a small number of updates to the underlying state, it is generally
+ * much smaller than a full [`ChannelMonitor`]. However, for large single commitment transaction
+ * updates (e.g. ones during which there are hundreds of HTLCs pending on the commitment
+ * transaction), a single update may reach upwards of 1 MiB in serialized size.
*/
typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
/**
* parameter.
*/
struct LDKCResult_SecretKeyNoneZ (*get_node_secret)(const void *this_arg, enum LDKRecipient recipient);
+ /**
+ * Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if
+ * one is provided. Note that this tweak can be applied to `other_key` instead of our node
+ * secret, though this is less efficient.
+ *
+ * [`node secret`]: Self::get_node_secret
+ */
+ struct LDKCResult_SharedSecretNoneZ (*ecdh)(const void *this_arg, enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak);
/**
* Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
*
bool result_ok;
} LDKCResult_PaymentIdPaymentErrorZ;
+
+
+/**
+ * A map with liquidity value (in msat) keyed by a short channel id and the direction the HTLC
+ * is traveling in. The direction boolean is determined by checking if the HTLC source's public
+ * key is less than its destination. See [`InFlightHtlcs::used_liquidity_msat`] for more
+ * details.
+ */
+typedef struct MUST_USE_STRUCT LDKInFlightHtlcs {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeInFlightHtlcs *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;
+} LDKInFlightHtlcs;
+
+/**
+ * The contents of CResult_InFlightHtlcsDecodeErrorZ
+ */
+typedef union LDKCResult_InFlightHtlcsDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKInFlightHtlcs *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_InFlightHtlcsDecodeErrorZPtr;
+
+/**
+ * A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::payment::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_InFlightHtlcsDecodeErrorZ {
+ /**
+ * The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_InFlightHtlcsDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_InFlightHtlcsDecodeErrorZ;
+
/**
* Sub-errors which don't have specific information in them use this type.
*/
* fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
* likely to be claimed by our counterparty before we do.
*/
- LDKBalance_MaybeClaimableHTLCAwaitingTimeout,
+ LDKBalance_MaybeTimeoutClaimableHTLC,
+ /**
+ * HTLCs which we received from our counterparty which are claimable with a preimage which we
+ * do not currently have. This will only be claimable if we receive the preimage from the node
+ * to which we forwarded this HTLC before the timeout.
+ */
+ LDKBalance_MaybePreimageClaimableHTLC,
+ /**
+ * The channel has been closed, and our counterparty broadcasted a revoked commitment
+ * transaction.
+ *
+ * Thus, we're able to claim all outputs in the commitment transaction, one of which has the
+ * following amount.
+ */
+ LDKBalance_CounterpartyRevokedOutputClaimable,
/**
* Must be last for serialization purposes
*/
uint32_t timeout_height;
} LDKBalance_LDKContentiousClaimable_Body;
-typedef struct LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body {
+typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body {
/**
- * The amount available to claim, in satoshis, excluding the on-chain fees which will be
- * required to do so.
+ * The amount potentially available to claim, in satoshis, excluding the on-chain fees
+ * which will be required to do so.
*/
uint64_t claimable_amount_satoshis;
/**
* done so.
*/
uint32_t claimable_height;
-} LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body;
+} LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body;
+
+typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body {
+ /**
+ * The amount potentially available to claim, in satoshis, excluding the on-chain fees
+ * which will be required to do so.
+ */
+ uint64_t claimable_amount_satoshis;
+ /**
+ * The height at which our counterparty will be able to claim the balance if we have not
+ * yet received the preimage and claimed it ourselves.
+ */
+ uint32_t expiry_height;
+} LDKBalance_LDKMaybePreimageClaimableHTLC_Body;
+
+typedef struct LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body {
+ /**
+ * The amount, in satoshis, of the output which we can claim.
+ *
+ * Note that for outputs from HTLC balances this may be excluding some on-chain fees that
+ * were already spent.
+ */
+ uint64_t claimable_amount_satoshis;
+} LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body;
typedef struct MUST_USE_STRUCT LDKBalance {
LDKBalance_Tag tag;
LDKBalance_LDKClaimableOnChannelClose_Body claimable_on_channel_close;
LDKBalance_LDKClaimableAwaitingConfirmations_Body claimable_awaiting_confirmations;
LDKBalance_LDKContentiousClaimable_Body contentious_claimable;
- LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body maybe_claimable_htlc_awaiting_timeout;
+ LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body maybe_timeout_claimable_htlc;
+ LDKBalance_LDKMaybePreimageClaimableHTLC_Body maybe_preimage_claimable_htlc;
+ LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body counterparty_revoked_output_claimable;
};
} LDKBalance;
bool result_ok;
} LDKCResult_boolPeerHandleErrorZ;
+/**
+ * Errors that may occur when [sending an onion message].
+ *
+ * [sending an onion message]: OnionMessenger::send_onion_message
+ */
+typedef enum LDKSendError_Tag {
+ /**
+ * Errored computing onion message packet keys.
+ */
+ LDKSendError_Secp256k1,
+ /**
+ * Because implementations such as Eclair will drop onion messages where the message packet
+ * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size.
+ */
+ LDKSendError_TooBigPacket,
+ /**
+ * The provided [`Destination`] was an invalid [`BlindedRoute`], due to having fewer than two
+ * blinded hops.
+ */
+ LDKSendError_TooFewBlindedHops,
+ /**
+ * Our next-hop peer was offline or does not support onion message forwarding.
+ */
+ LDKSendError_InvalidFirstHop,
+ /**
+ * Our next-hop peer's buffer was full or our total outbound buffer was full.
+ */
+ LDKSendError_BufferFull,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKSendError_Sentinel,
+} LDKSendError_Tag;
+
+typedef struct MUST_USE_STRUCT LDKSendError {
+ LDKSendError_Tag tag;
+ union {
+ struct {
+ enum LDKSecp256k1Error secp256k1;
+ };
+ };
+} LDKSendError;
+
+/**
+ * The contents of CResult_NoneSendErrorZ
+ */
+typedef union LDKCResult_NoneSendErrorZPtr {
+ /**
+ * Note that this value is always NULL, as there are no contents in the OK variant
+ */
+ void *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKSendError *err;
+} LDKCResult_NoneSendErrorZPtr;
+
+/**
+ * A CResult_NoneSendErrorZ represents the result of a fallible operation,
+ * containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_NoneSendErrorZ {
+ /**
+ * The contents of this CResult_NoneSendErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_NoneSendErrorZPtr contents;
+ /**
+ * Whether this CResult_NoneSendErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_NoneSendErrorZ;
+
/**
* All-encompassing standard error type that processing can return
*/
+/**
+ * An onion message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKOnionMessage {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeOnionMessage *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;
+} LDKOnionMessage;
+
+/**
+ * The contents of CResult_OnionMessageDecodeErrorZ
+ */
+typedef union LDKCResult_OnionMessageDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKOnionMessage *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_OnionMessageDecodeErrorZPtr;
+
+/**
+ * A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_OnionMessageDecodeErrorZ {
+ /**
+ * The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_OnionMessageDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_OnionMessageDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_OnionMessageDecodeErrorZ;
+
+
+
/**
* A ping message to be sent or received from a peer
*/
bool result_ok;
} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ;
+
+
+/**
+ * A node_announcement message to be sent or received from a peer
+ */
+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;
+
/**
* The contents of CResult_NodeAnnouncementDecodeErrorZ
*/
*
* Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
* spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
- * the return value of [`Filter::register_output`].
+ * [`Confirm::transactions_confirmed`].
*
* If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
* may have been spent there. See [`Filter::register_output`] for details.
/**
* Registers interest in spends of a transaction output.
*
- * Optionally, when `output.block_hash` is set, should return any transaction spending the
- * output that is found in the corresponding block along with its index.
- *
- * This return value is useful for Electrum clients in order to supply in-block descendant
- * transactions which otherwise were not included. This is not necessary for other clients if
- * such descendant transactions were already included (e.g., when a BIP 157 client provides the
- * full block).
+ * Note that this method might be called during processing of a new block. You therefore need
+ * to ensure that also dependent output spents within an already connected block are correctly
+ * handled, e.g., by re-scanning the block in question whenever new outputs have been
+ * registered mid-processing.
*/
- struct LDKCOption_C2Tuple_usizeTransactionZZ (*register_output)(const void *this_arg, struct LDKWatchedOutput output);
+ void (*register_output)(const void *this_arg, struct LDKWatchedOutput output);
/**
* 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;
+/**
+ * A trait indicating an object may generate onion messages to send
+ */
+typedef struct LDKOnionMessageProvider {
+ /**
+ * 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 next pending onion message for the peer with the given node id.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_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);
+} LDKOnionMessageProvider;
+
/**
* A trait implemented for objects handling events from [`EventsProvider`].
*/
*
* # Requirements
*
- * See [`process_pending_events`] for requirements around event processing.
- *
* When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
- * event since the last invocation. The handler must either act upon the event immediately
- * or preserve it for later handling.
+ * event since the last invocation.
+ *
+ * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
+ * and replay any unhandled events on startup. An [`Event`] is considered handled when
+ * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
+ * relevant changes to disk *before* returning.
+ *
+ * Further, because an application may crash between an [`Event`] being handled and the
+ * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
+ * effect, [`Event`]s may be replayed.
*
* Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
* consult the provider's documentation on the implication of processing events and how a handler
/**
* Processes any events generated since the last call using the given event handler.
*
- * Subsequent calls must only process new events. However, handlers must be capable of handling
- * duplicate events across process restarts. This may occur if the provider was recovered from
- * an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ * See the trait-level documentation for requirements.
*/
void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler);
/**
bool is_owned;
} LDKBigSize;
-
-
-/**
- * Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`].
- */
-typedef struct MUST_USE_STRUCT LDKChannelUsage {
- /**
- * A pointer to the opaque Rust object.
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeChannelUsage *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;
-} LDKChannelUsage;
-
/**
- * An interface used to score payment channels for path finding.
- *
- *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel.
+ * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
*/
-typedef struct LDKScore {
+typedef struct LDKPersister {
/**
* 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 fee in msats willing to be paid to avoid routing `send_amt_msat` through the
- * given channel in the direction from `source` to `target`.
- *
- * The channel's capacity (less any other MPP parts that are also being considered for use in
- * the same payment) is given by `capacity_msat`. It may be determined from various sources
- * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
- * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
- * Thus, implementations should be overflow-safe.
+ * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
*/
- uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage);
+ struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager);
/**
- * Handles updating channel penalties after failing to route through a channel.
+ * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
*/
- void (*payment_path_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph);
/**
- * Handles updating channel penalties after successfully routing along a path.
+ * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
*/
- void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path);
+ struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKWriteableScore *NONNULL_PTR scorer);
/**
- * Handles updating channel penalties after a probe over the given path failed.
+ * 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 (*probe_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ void (*free)(void *this_arg);
+} LDKPersister;
+
+/**
+ * A callback which is called when a [`Future`] completes.
+ *
+ * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
+ * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`]
+ * instead.
+ *
+ * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
+ * futures when they receive a wake, rather than immediately executing them.
+ */
+typedef struct LDKFutureCallback {
/**
- * Handles updating channel penalties after a probe over the given path succeeded.
+ * 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 (*probe_successful)(void *this_arg, struct LDKCVec_RouteHopZ path);
+ void *this_arg;
/**
- * Serialize the object into a byte array
+ * The method which is called.
*/
- struct LDKCVec_u8Z (*write)(const void *this_arg);
+ void (*call)(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);
-} LDKScore;
+} LDKFutureCallback;
/**
- * A concrete implementation of [`LockableScore`] which supports multi-threading.
+ * A simple future which can complete once, and calls some callback(s) when it does so.
*/
-typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore {
+typedef struct MUST_USE_STRUCT LDKFuture {
/**
* A pointer to the opaque Rust object.
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeMultiThreadedLockableScore *inner;
+ LDKnativeFuture *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;
-} LDKMultiThreadedLockableScore;
-
-/**
- * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`MultiThreadedLockableScore`] to disk.
- */
-typedef struct LDKPersister {
- /**
- * 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 the given ['ChannelManager'] to disk, returning an error if persistence failed.
- */
- struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager);
- /**
- * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
- */
- struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph);
- /**
- * Persist the given [`MultiThreadedLockableScore`] to disk, returning an error if persistence failed.
- */
- struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKMultiThreadedLockableScore *NONNULL_PTR scorer);
- /**
- * 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);
-} LDKPersister;
+} LDKFuture;
* in the event of a chain reorganization, it must not be called with a `header` that is no
* longer in the chain as of the last call to [`best_block_updated`].
*
- * [chain order]: Confirm#Order
+ * [chain order]: Confirm#order
* [`best_block_updated`]: Self::best_block_updated
*/
void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height);
* Processes a transaction that is no longer confirmed as result of a chain reorganization.
*
* Should be called for any transaction returned by [`get_relevant_txids`] if it has been
- * reorganized out of the best chain. Once called, the given transaction should not be returned
- * by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`].
+ * reorganized out of the best chain. Once called, the given transaction will not be returned
+ * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`].
*
* [`get_relevant_txids`]: Self::get_relevant_txids
* [`transactions_confirmed`]: Self::transactions_confirmed
/**
* Returns transactions that should be monitored for reorganization out of the chain.
*
- * Should include any transactions passed to [`transactions_confirmed`] that have insufficient
- * confirmations to be safe from a chain reorganization. Should not include any transactions
- * passed to [`transaction_unconfirmed`] unless later reconfirmed.
+ * Will include any transactions passed to [`transactions_confirmed`] that have insufficient
+ * confirmations to be safe from a chain reorganization. Will not include any transactions
+ * passed to [`transaction_unconfirmed`], unless later reconfirmed.
*
* May be called to determine the subset of transactions that must still be monitored for
* reorganization. Will be idempotent between calls but may change as a result of calls to the
bool is_owned;
} LDKChainParameters;
-/**
- * A 3-byte byte array.
- */
-typedef struct LDKThreeBytes {
- /**
- * The three bytes
- */
- uint8_t data[3];
-} LDKThreeBytes;
-
/**
* A trait to describe an object which can receive channel messages.
*
* 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);
+ /**
+ * Gets the node feature flags which this handler itself supports. All available handlers are
+ * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ * which are broadcasted in our [`NodeAnnouncement`] message.
+ */
+ struct LDKNodeFeatures (*provided_node_features)(const void *this_arg);
+ /**
+ * Gets the init feature flags which should be sent to the given peer. All available handlers
+ * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ * which are sent in our [`Init`] message.
+ *
+ * Note that this method is called before [`Self::peer_connected`].
+ */
+ struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id);
/**
* Implementation of MessageSendEventsProvider for this object.
*/
bool is_owned;
} LDKDataLossProtect;
+/**
+ * A 3-byte byte array.
+ */
+typedef struct LDKThreeBytes {
+ /**
+ * The three bytes
+ */
+ uint8_t data[3];
+} LDKThreeBytes;
+
/**
* A trait to describe an object which can receive routing messages.
*
*/
struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg);
/**
- * Gets a subset of the channel announcements and updates required to dump our routing table
- * to a remote node, starting at the short_channel_id indicated by starting_point and
- * including the batch_amount entries immediately higher in numerical value than starting_point.
+ * Gets channel announcements and updates required to dump our routing table to a remote node,
+ * starting at the short_channel_id indicated by starting_point and including announcements
+ * for a single channel.
*/
- struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount);
+ struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcement)(const void *this_arg, uint64_t starting_point);
/**
- * Gets a subset of the node announcements required to dump our routing table to a remote node,
- * starting at the node *after* the provided publickey and including batch_amount entries
- * immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
+ * Gets a node announcement required to dump our routing table to a remote node, starting at
+ * the node *after* the provided pubkey and including up to one announcement immediately
+ * higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
* If None is provided for starting_point, we start at the first node.
*
* Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- struct LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount);
+ struct LDKNodeAnnouncement (*get_next_node_announcement)(const void *this_arg, struct LDKPublicKey starting_point);
/**
* Called when a connection is established with a peer. This can be used to
* perform routing table synchronization using a strategy defined by the
* 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);
+ /**
+ * Gets the node feature flags which this handler itself supports. All available handlers are
+ * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ * which are broadcasted in our [`NodeAnnouncement`] message.
+ */
+ struct LDKNodeFeatures (*provided_node_features)(const void *this_arg);
+ /**
+ * Gets the init feature flags which should be sent to the given peer. All available handlers
+ * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ * which are sent in our [`Init`] message.
+ *
+ * Note that this method is called before [`Self::peer_connected`].
+ */
+ struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id);
/**
* Implementation of MessageSendEventsProvider for this object.
*/
void (*free)(void *this_arg);
} LDKRoutingMessageHandler;
+/**
+ * A trait to describe an object that can receive onion messages.
+ */
+typedef struct LDKOnionMessageHandler {
+ /**
+ * 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 onion_message message from the given peer.
+ */
+ void (*handle_onion_message)(const void *this_arg, struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg);
+ /**
+ * Called when a connection is established with a peer. Can be used to track which peers
+ * advertise onion message support and are online.
+ */
+ void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init);
+ /**
+ * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
+ * drop and refuse to forward onion messages to this peer.
+ */
+ void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible);
+ /**
+ * Gets the node feature flags which this handler itself supports. All available handlers are
+ * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ * which are broadcasted in our [`NodeAnnouncement`] message.
+ */
+ struct LDKNodeFeatures (*provided_node_features)(const void *this_arg);
+ /**
+ * Gets the init feature flags which should be sent to the given peer. All available handlers
+ * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ * which are sent in our [`Init`] message.
+ *
+ * Note that this method is called before [`Self::peer_connected`].
+ */
+ struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id);
+ /**
+ * Implementation of OnionMessageProvider for this object.
+ */
+ struct LDKOnionMessageProvider OnionMessageProvider;
+ /**
+ * 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);
+} LDKOnionMessageHandler;
+
/**
* Trait to be implemented by custom message (unrelated to the channel/gossip LN layers)
* decoders.
};
} LDKEffectiveCapacity;
+
+
/**
- * A scorer that is accessed under a lock.
- *
- * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while
- * having shared ownership of a scorer but without requiring internal locking in [`Score`]
- * implementations. Internal locking would be detrimental to route finding performance and could
- * result in [`Score::channel_penalty_msat`] returning a different value for the same channel.
- *
- * [`find_route`]: crate::routing::router::find_route
+ * A concrete implementation of [`LockableScore`] which supports multi-threading.
*/
-typedef struct LDKLockableScore {
+typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore {
/**
- * An opaque pointer which is passed to your function implementations as an argument.
- * This has no meaning in the LDK, and can be NULL or any other value.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- void *this_arg;
+ LDKnativeMultiThreadedLockableScore *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;
+} LDKMultiThreadedLockableScore;
+
+
+
+/**
+ * A locked `MultiThreadedLockableScore`.
+ */
+typedef struct MUST_USE_STRUCT LDKMultiThreadedScoreLock {
/**
- * Returns the locked scorer.
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- struct LDKScore (*lock)(const void *this_arg);
+ LDKnativeMultiThreadedScoreLock *inner;
/**
- * 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.
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
*/
- void (*free)(void *this_arg);
-} LDKLockableScore;
+ bool is_owned;
+} LDKMultiThreadedScoreLock;
+/**
+ * A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be
+ * used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending
+ * and receiving empty onion messages is supported.
+ *
+ * # Example
+ *
+ * ```
+ * # extern crate bitcoin;
+ * # use bitcoin::hashes::_export::_core::time::Duration;
+ * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
+ * # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
+ * # use lightning::onion_message::messenger::{Destination, OnionMessenger};
+ * # use lightning::onion_message::blinded_route::BlindedRoute;
+ * # use lightning::util::logger::{Logger, Record};
+ * # use std::sync::Arc;
+ * # struct FakeLogger {};
+ * # impl Logger for FakeLogger {
+ * # fn log(&self, record: &Record) { unimplemented!() }
+ * # }
+ * # let seed = [42u8; 32];
+ * # let time = Duration::from_secs(123456);
+ * # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos());
+ * # let logger = Arc::new(FakeLogger {});
+ * # let node_secret = SecretKey::from_slice(&hex::decode(\"0101010101010101010101010101010101010101010101010101010101010101\").unwrap()[..]).unwrap();
+ * # let secp_ctx = Secp256k1::new();
+ * # let hop_node_id1 = PublicKey::from_secret_key(&secp_ctx, &node_secret);
+ * # let (hop_node_id2, hop_node_id3, hop_node_id4) = (hop_node_id1, hop_node_id1,
+ * hop_node_id1);
+ * # let destination_node_id = hop_node_id1;
+ * #
+ * // Create the onion messenger. This must use the same `keys_manager` as is passed to your
+ * // ChannelManager.
+ * let onion_messenger = OnionMessenger::new(&keys_manager, logger);
+ *
+ * // Send an empty onion message to a node id.
+ * let intermediate_hops = [hop_node_id1, hop_node_id2];
+ * let reply_path = None;
+ * onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), reply_path);
+ *
+ * // Create a blinded route to yourself, for someone to send an onion message to.
+ * # let your_node_id = hop_node_id1;
+ * let hops = [hop_node_id3, hop_node_id4, your_node_id];
+ * let blinded_route = BlindedRoute::new(&hops, &keys_manager, &secp_ctx).unwrap();
+ *
+ * // Send an empty onion message to a blinded route.
+ * # let intermediate_hops = [hop_node_id1, hop_node_id2];
+ * let reply_path = None;
+ * onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), reply_path);
+ * ```
+ *
+ * [offers]: <https://github.com/lightning/bolts/pull/798>
+ * [`OnionMessenger`]: crate::onion_message::OnionMessenger
+ */
+typedef struct MUST_USE_STRUCT LDKOnionMessenger {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeOnionMessenger *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;
+} LDKOnionMessenger;
+
+/**
+ * The destination of an onion message.
+ */
+typedef enum LDKDestination_Tag {
+ /**
+ * We're sending this onion message to a node.
+ */
+ LDKDestination_Node,
+ /**
+ * We're sending this onion message to a blinded route.
+ */
+ LDKDestination_BlindedRoute,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKDestination_Sentinel,
+} LDKDestination_Tag;
+
+typedef struct MUST_USE_STRUCT LDKDestination {
+ LDKDestination_Tag tag;
+ union {
+ struct {
+ struct LDKPublicKey node;
+ };
+ struct {
+ struct LDKBlindedRoute blinded_route;
+ };
+ };
+} LDKDestination;
+
+
+
/**
* FilesystemPersister persists channel data on disk, where each channel's
* data is stored in a file named after its funding outpoint.
*
* Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer);
+ struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs);
+ /**
+ * Lets the router know that payment through a specific path has failed.
+ */
+ void (*notify_payment_path_failed)(const void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ /**
+ * Lets the router know that payment through a specific path was successful.
+ */
+ void (*notify_payment_path_successful)(const void *this_arg, struct LDKCVec_RouteHopZ path);
+ /**
+ * Lets the router know that a payment probe was successful.
+ */
+ void (*notify_payment_probe_successful)(const void *this_arg, struct LDKCVec_RouteHopZ path);
+ /**
+ * Lets the router know that a payment probe failed.
+ */
+ void (*notify_payment_probe_failed)(const void *this_arg, struct LDKCVec_RouteHopZ path, 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.
const void *__unmangle_inner_ptr(const void *ptr);
#endif
+/**
+ * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ */
+void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res);
+
+/**
+ * Creates a new CResult_BlindedRouteNoneZ in the success state.
+ */
+struct LDKCResult_BlindedRouteNoneZ CResult_BlindedRouteNoneZ_ok(struct LDKBlindedRoute o);
+
+/**
+ * Creates a new CResult_BlindedRouteNoneZ in the error state.
+ */
+struct LDKCResult_BlindedRouteNoneZ CResult_BlindedRouteNoneZ_err(void);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_BlindedRouteNoneZ_is_ok(const struct LDKCResult_BlindedRouteNoneZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_BlindedRouteNoneZ.
+ */
+void CResult_BlindedRouteNoneZ_free(struct LDKCResult_BlindedRouteNoneZ _res);
+
+/**
+ * Creates a new CResult_BlindedRouteDecodeErrorZ in the success state.
+ */
+struct LDKCResult_BlindedRouteDecodeErrorZ CResult_BlindedRouteDecodeErrorZ_ok(struct LDKBlindedRoute o);
+
+/**
+ * Creates a new CResult_BlindedRouteDecodeErrorZ in the error state.
+ */
+struct LDKCResult_BlindedRouteDecodeErrorZ CResult_BlindedRouteDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_BlindedRouteDecodeErrorZ_is_ok(const struct LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_BlindedRouteDecodeErrorZ.
+ */
+void CResult_BlindedRouteDecodeErrorZ_free(struct LDKCResult_BlindedRouteDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_BlindedHopDecodeErrorZ in the success state.
+ */
+struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o);
+
+/**
+ * Creates a new CResult_BlindedHopDecodeErrorZ in the error state.
+ */
+struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_BlindedHopDecodeErrorZ.
+ */
+void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res);
+
/**
* Creates a new CResult_NoneNoneZ in the success state.
*/
*/
struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig);
+/**
+ * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore
+ */
+struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o);
+
+/**
+ * Constructs a new COption_WriteableScoreZ containing nothing
+ */
+struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state
+ */
+void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res);
+
/**
* Creates a new CResult_NoneErrorZ in the success state.
*/
*/
struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig);
-/**
- * Frees the buffer pointed to by `data` if `datalen` is non-0.
- */
-void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res);
-
/**
* Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state.
*/
*/
void CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res);
-/**
- * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ
- */
-struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o);
-
-/**
- * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing
- */
-struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void);
-
-/**
- * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state
- */
-void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res);
-
-/**
- * Creates a new COption_C2Tuple_usizeTransactionZZ which has the same data as `orig`
- * but with all dynamically-allocated buffers duplicated in new buffers.
- */
-struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig);
-
/**
* Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state.
*/
void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res);
/**
- * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ
*/
-void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res);
+struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o);
/**
- * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing
+ */
+struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state
+ */
+void COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res);
+
+/**
+ * Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
*/
-void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res);
+struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR orig);
/**
* Creates a new CResult_NoneLightningErrorZ in the success state.
*/
struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_clone(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR orig);
+/**
+ * Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar
+ */
+struct LDKCOption_ScalarZ COption_ScalarZ_some(struct LDKBigEndianScalar o);
+
+/**
+ * Constructs a new COption_ScalarZ containing nothing
+ */
+struct LDKCOption_ScalarZ COption_ScalarZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state
+ */
+void COption_ScalarZ_free(struct LDKCOption_ScalarZ _res);
+
+/**
+ * Creates a new CResult_SharedSecretNoneZ in the success state.
+ */
+struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_ok(struct LDKThirtyTwoBytes o);
+
+/**
+ * Creates a new CResult_SharedSecretNoneZ in the error state.
+ */
+struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_err(void);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_SharedSecretNoneZ_is_ok(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_SharedSecretNoneZ.
+ */
+void CResult_SharedSecretNoneZ_free(struct LDKCResult_SharedSecretNoneZ _res);
+
+/**
+ * Creates a new CResult_SharedSecretNoneZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_clone(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_SignDecodeErrorZ in the success state.
*/
*/
struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state.
+ */
+struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_ok(struct LDKInFlightHtlcs o);
+
+/**
+ * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state.
+ */
+struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_InFlightHtlcsDecodeErrorZ_is_ok(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ.
+ */
+void CResult_InFlightHtlcsDecodeErrorZ_free(struct LDKCResult_InFlightHtlcsDecodeErrorZ _res);
+
/**
* Creates a new CResult_SiPrefixParseErrorZ in the success state.
*/
*/
struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_NoneSendErrorZ in the success state.
+ */
+struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void);
+
+/**
+ * Creates a new CResult_NoneSendErrorZ in the error state.
+ */
+struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_NoneSendErrorZ.
+ */
+void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res);
+
/**
* Creates a new CResult_u32GraphSyncErrorZ in the success state.
*/
*/
struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new CResult_OnionMessageDecodeErrorZ in the success state.
+ */
+struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_ok(struct LDKOnionMessage o);
+
+/**
+ * Creates a new CResult_OnionMessageDecodeErrorZ in the error state.
+ */
+struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_OnionMessageDecodeErrorZ_is_ok(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_OnionMessageDecodeErrorZ.
+ */
+void CResult_OnionMessageDecodeErrorZ_free(struct LDKCResult_OnionMessageDecodeErrorZ _res);
+
+/**
+ * Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_clone(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_PingDecodeErrorZ in the success state.
*/
/**
* Utility method to constructs a new PaymentPathFailed-variant Event
*/
-struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry);
+struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry);
/**
* Utility method to constructs a new ProbeSuccessful-variant Event
struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg);
/**
- * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
+ * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent
*/
-struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg);
+struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg);
/**
- * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
+ * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
*/
-struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg);
+struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg);
/**
* Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
*/
void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr);
+/**
+ * Calls the free function if one is set
+ */
+void OnionMessageProvider_free(struct LDKOnionMessageProvider this_ptr);
+
/**
* Calls the free function if one is set
*/
*/
void Persister_free(struct LDKPersister this_ptr);
+/**
+ * Calls the free function if one is set
+ */
+void FutureCallback_free(struct LDKFutureCallback this_ptr);
+
+/**
+ * Frees any resources used by the Future, if is_owned is set and inner is non-NULL.
+ */
+void Future_free(struct LDKFuture this_obj);
+
+/**
+ * Registers a callback to be called upon completion of this future. If the future has already
+ * completed, the callback will be called immediately.
+ */
+void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, struct LDKFutureCallback callback);
+
/**
* Creates a copy of the Level
*/
*
* The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
*
- * Default value: true.
+ * Default value: true.
+ *
+ * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+ */
+bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+
+/**
+ * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
+ * supports it, they will then enforce the mutual-close output to us matches what we provided
+ * at intialization, preventing us from closing to an alternate pubkey.
+ *
+ * This is set to true by default to provide a slight increase in security, though ultimately
+ * any attacker who is able to take control of a channel can just as easily send the funds via
+ * lightning payments, so we never require that our counterparties support this option.
+ *
+ * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
+ *
+ * Default value: true.
+ *
+ * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+ */
+void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val);
+
+/**
+ * The Proportion of the channel value to configure as counterparty's channel reserve,
+ * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
+ *
+ * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
+ * on their side, at all times.
+ * This ensures that if our counterparty broadcasts a revoked state, we can punish them by
+ * claiming at least this value on chain.
+ *
+ * Channel reserve values greater than 30% could be considered highly unreasonable, since that
+ * amount can never be used for payments.
+ * Also, if our selected channel reserve for counterparty and counterparty's selected
+ * channel reserve for us sum up to equal or greater than channel value, channel negotiations
+ * will fail.
+ *
+ * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
+ * other than the default value.
*
- * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+ * Default value: 1% of channel value, i.e., configured as 10,000 millionths.
+ * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
+ * as 1000 sats instead, which is a safe implementation-specific lower bound.
+ * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
+ * instead, although channel negotiations will fail in that case.
*/
-bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
+uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr);
/**
- * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
- * supports it, they will then enforce the mutual-close output to us matches what we provided
- * at intialization, preventing us from closing to an alternate pubkey.
+ * The Proportion of the channel value to configure as counterparty's channel reserve,
+ * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
*
- * This is set to true by default to provide a slight increase in security, though ultimately
- * any attacker who is able to take control of a channel can just as easily send the funds via
- * lightning payments, so we never require that our counterparties support this option.
+ * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
+ * on their side, at all times.
+ * This ensures that if our counterparty broadcasts a revoked state, we can punish them by
+ * claiming at least this value on chain.
*
- * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
+ * Channel reserve values greater than 30% could be considered highly unreasonable, since that
+ * amount can never be used for payments.
+ * Also, if our selected channel reserve for counterparty and counterparty's selected
+ * channel reserve for us sum up to equal or greater than channel value, channel negotiations
+ * will fail.
*
- * Default value: true.
+ * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
+ * other than the default value.
*
- * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
+ * Default value: 1% of channel value, i.e., configured as 10,000 millionths.
+ * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
+ * as 1000 sats instead, which is a safe implementation-specific lower bound.
+ * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
+ * instead, although channel negotiations will fail in that case.
*/
-void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val);
+void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_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, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg);
+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, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg);
/**
* Creates a copy of the ChannelHandshakeConfig
struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height);
/**
- * Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
+ * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance
+ */
+struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t claimable_height);
+
+/**
+ * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance
+ */
+struct LDKBalance Balance_maybe_preimage_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t expiry_height);
+
+/**
+ * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance
*/
-struct LDKBalance Balance_maybe_claimable_htlcawaiting_timeout(uint64_t claimable_amount_satoshis, uint32_t claimable_height);
+struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t claimable_amount_satoshis);
/**
* Checks if two Balances contain equal inner contents.
* balance, or until our counterparty has claimed the balance and accrued several
* confirmations on the claim transaction.
*
- * Note that the balances available when you or your counterparty have broadcasted revoked
- * state(s) may not be fully captured here.
+ * Note that for `ChannelMonitors` which track a channel which went on-chain with versions of
+ * LDK prior to 0.0.111, balances may not be fully captured if our counterparty broadcasted
+ * a revoked state.
*
* See [`Balance`] for additional details on the types of claimable balances which
* may be returned here and their meanings.
MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params);
/**
- * Gets the current configuration applied to all new channels, as
+ * Gets the current configuration applied to all new channels.
*/
MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg);
*/
MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction);
-/**
- * Regenerates channel_announcements and generates a signed node_announcement from the given
- * arguments, providing them in corresponding events via
- * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
- * on-chain. This effectively re-broadcasts all channel announcements and sends our node
- * announcement to ensure that the lightning P2P network is aware of the channels we have and
- * our network addresses.
- *
- * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
- * node to humans. They carry no in-protocol meaning.
- *
- * `addresses` represent the set (possibly empty) of socket addresses on which this node
- * accepts incoming connections. These will be included in the node_announcement, publicly
- * tying these addresses together and to this node. If you wish to preserve user privacy,
- * addresses should likely contain only Tor Onion addresses.
- *
- * Panics if `addresses` is absurdly large (more than 100).
- *
- * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
- */
-void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses);
-
/**
* Atomically updates the [`ChannelConfig`] for the given channels.
*
*/
void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg);
+/**
+ * Gets a [`Future`] that completes when a persistable update is available. Note that
+ * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
+ * should instead register actions to be taken later.
+ */
+MUST_USE_RES struct LDKFuture ChannelManager_get_persistable_update_future(const struct LDKChannelManager *NONNULL_PTR this_arg);
+
/**
* Gets the latest best block which was connected either via the [`chain::Listen`] or
* [`chain::Confirm`] interfaces.
*/
struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig);
+/**
+ * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
+ */
+void OnionMessage_free(struct LDKOnionMessage this_obj);
+
+/**
+ * Used in decrypting the onion packet's payload.
+ */
+struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr);
+
+/**
+ * Used in decrypting the onion packet's payload.
+ */
+void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val);
+
+/**
+ * Creates a copy of the OnionMessage
+ */
+struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig);
+
/**
* Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
*/
*/
void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr);
+/**
+ * Calls the free function if one is set
+ */
+void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr);
+
/**
* Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
*/
*/
struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser);
+/**
+ * Read a OnionMessage from a byte array, created by OnionMessage_write
+ */
+struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser);
+
+/**
+ * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
+ */
+struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj);
+
/**
* Serialize the Ping object into a byte array which can be read by Ping_read
*/
*/
struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg);
+/**
+ * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is
+ */
+struct LDKOnionMessageProvider IgnoringMessageHandler_as_OnionMessageProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg);
+
+/**
+ * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is
+ */
+struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg);
+
/**
* Constructs a new CustomMessageReader which calls the relevant methods on this_arg.
* This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is
*/
void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val);
+/**
+ * A message handler which handles onion messages. For now, this can only be an
+ * [`IgnoringMessageHandler`].
+ */
+const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr);
+
+/**
+ * A message handler which handles onion messages. For now, this can only be an
+ * [`IgnoringMessageHandler`].
+ */
+void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler 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);
+MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg);
/**
* Creates a copy of a SocketDescriptor
* Constructs a new PeerManager with the given message handlers and node_id secret key
* ephemeral_random_data is used to derive per-connection ephemeral keys and must be
* cryptographically secure random bytes.
+ *
+ * `current_time` is used as an always-increasing counter that survives across restarts and is
+ * incremented irregularly internally. In general it is best to simply use the current UNIX
+ * timestamp, however if it is not available a persistent counter that increases once per
+ * minute should suffice.
*/
-MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler);
+MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, uint64_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler);
/**
* Get the list of node ids for peers which have completed the initial handshake.
*/
void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg);
+/**
+ * Generates a signed node_announcement from the given arguments, sending it to all connected
+ * peers. Note that peers will likely ignore this message unless we have at least one public
+ * channel which has at least six confirmations on-chain.
+ *
+ * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
+ * node to humans. They carry no in-protocol meaning.
+ *
+ * `addresses` represent the set (possibly empty) of socket addresses on which this node
+ * accepts incoming connections. These will be included in the node_announcement, publicly
+ * tying these addresses together and to this node. If you wish to preserve user privacy,
+ * addresses should likely contain only Tor Onion addresses.
+ *
+ * Panics if `addresses` is absurdly large (more than 100).
+ *
+ * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
+ */
+void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses);
+
/**
* Gets the weight for an HTLC-Success transaction.
*/
*/
void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj);
+/**
+ * Returns the set of known init features that are related to channels. At least some of
+ * these features are likely required for peers to talk to us.
+ */
+MUST_USE_RES struct LDKInitFeatures InitFeatures_known_channel_features(void);
+
+/**
+ * Returns the set of known node features that are related to channels.
+ */
+MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known_channel_features(void);
+
/**
* Create a blank Features with no features set
*/
*/
MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg);
+/**
+ * Set this feature as optional.
+ */
+void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Set this feature as required.
+ */
+void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Checks if this feature is supported.
+ */
+MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Set this feature as optional.
+ */
+void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Set this feature as required.
+ */
+void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Checks if this feature is supported.
+ */
+MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Checks if this feature is required.
+ */
+MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg);
+
+/**
+ * Checks if this feature is required.
+ */
+MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg);
+
/**
* Set this feature as optional.
*/
*/
MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id);
+/**
+ * Returns the list of channels in the graph
+ */
+MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg);
+
/**
* Returns information on a node with the given id.
*
*/
MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id);
+/**
+ * Returns the list of nodes in the graph
+ */
+MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg);
+
/**
* Get network addresses by node id.
* Returns None if the requested node is completely unknown,
*/
void LockableScore_free(struct LDKLockableScore this_ptr);
+/**
+ * Calls the free function if one is set
+ */
+void WriteableScore_free(struct LDKWriteableScore this_ptr);
+
/**
* Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL.
*/
void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj);
/**
- * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read
+ * Frees any resources used by the MultiThreadedScoreLock, if is_owned is set and inner is non-NULL.
+ */
+void MultiThreadedScoreLock_free(struct LDKMultiThreadedScoreLock this_obj);
+
+/**
+ * Constructs a new Score which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
+ */
+struct LDKScore MultiThreadedScoreLock_as_Score(const struct LDKMultiThreadedScoreLock *NONNULL_PTR this_arg);
+
+/**
+ * Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read
*/
-struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj);
+struct LDKCVec_u8Z MultiThreadedScoreLock_write(const struct LDKMultiThreadedScoreLock *NONNULL_PTR obj);
+
+/**
+ * Constructs a new LockableScore which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is
+ */
+struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg);
/**
* Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`].
*/
struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c);
+/**
+ * Frees any resources used by the BlindedRoute, if is_owned is set and inner is non-NULL.
+ */
+void BlindedRoute_free(struct LDKBlindedRoute this_obj);
+
+/**
+ * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL.
+ */
+void BlindedHop_free(struct LDKBlindedHop this_obj);
+
+/**
+ * Create a blinded route to be forwarded along `node_pks`. The last node pubkey in `node_pks`
+ * will be the destination node.
+ *
+ * Errors if less than two hops are provided or if `node_pk`(s) are invalid.
+ */
+MUST_USE_RES struct LDKCResult_BlindedRouteNoneZ BlindedRoute_new(struct LDKCVec_PublicKeyZ node_pks, const struct LDKKeysInterface *NONNULL_PTR keys_manager);
+
+/**
+ * Serialize the BlindedRoute object into a byte array which can be read by BlindedRoute_read
+ */
+struct LDKCVec_u8Z BlindedRoute_write(const struct LDKBlindedRoute *NONNULL_PTR obj);
+
+/**
+ * Read a BlindedRoute from a byte array, created by BlindedRoute_write
+ */
+struct LDKCResult_BlindedRouteDecodeErrorZ BlindedRoute_read(struct LDKu8slice ser);
+
+/**
+ * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
+ */
+struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj);
+
+/**
+ * Read a BlindedHop from a byte array, created by BlindedHop_write
+ */
+struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser);
+
+/**
+ * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL.
+ */
+void OnionMessenger_free(struct LDKOnionMessenger this_obj);
+
+/**
+ * Frees any resources used by the Destination
+ */
+void Destination_free(struct LDKDestination this_ptr);
+
+/**
+ * Utility method to constructs a new Node-variant Destination
+ */
+struct LDKDestination Destination_node(struct LDKPublicKey a);
+
+/**
+ * Utility method to constructs a new BlindedRoute-variant Destination
+ */
+struct LDKDestination Destination_blinded_route(struct LDKBlindedRoute a);
+
+/**
+ * Frees any resources used by the SendError
+ */
+void SendError_free(struct LDKSendError this_ptr);
+
+/**
+ * Creates a copy of the SendError
+ */
+struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new Secp256k1-variant SendError
+ */
+struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a);
+
+/**
+ * Utility method to constructs a new TooBigPacket-variant SendError
+ */
+struct LDKSendError SendError_too_big_packet(void);
+
+/**
+ * Utility method to constructs a new TooFewBlindedHops-variant SendError
+ */
+struct LDKSendError SendError_too_few_blinded_hops(void);
+
+/**
+ * Utility method to constructs a new InvalidFirstHop-variant SendError
+ */
+struct LDKSendError SendError_invalid_first_hop(void);
+
+/**
+ * Utility method to constructs a new BufferFull-variant SendError
+ */
+struct LDKSendError SendError_buffer_full(void);
+
+/**
+ * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to
+ * their respective handlers.
+ */
+MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKKeysInterface keys_manager, struct LDKLogger logger);
+
+/**
+ * Send an empty onion message to `destination`, routing it through `intermediate_nodes`.
+ * See [`OnionMessenger`] for example usage.
+ *
+ * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKCVec_PublicKeyZ intermediate_nodes, struct LDKDestination destination, struct LDKBlindedRoute reply_path);
+
+/**
+ * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is
+ */
+struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg);
+
+/**
+ * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is
+ */
+struct LDKOnionMessageProvider OnionMessenger_as_OnionMessageProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg);
+
/**
* Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL.
*/
* [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph
* [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph
* [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable
- *
- * Note that scorer (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
-MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKMultiThreadedLockableScore scorer);
+MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer);
/**
* Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting
*/
struct LDKInvoice Invoice_clone(const struct LDKInvoice *NONNULL_PTR orig);
+/**
+ * Checks if two Invoices contain equal inner contents.
+ */
+uint64_t Invoice_hash(const struct LDKInvoice *NONNULL_PTR o);
+
/**
* Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKSignedRawInvoice SignedRawInvoice_clone(const struct LDKSignedRawInvoice *NONNULL_PTR orig);
+/**
+ * Checks if two SignedRawInvoices contain equal inner contents.
+ */
+uint64_t SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR o);
+
/**
* Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKRawInvoice RawInvoice_clone(const struct LDKRawInvoice *NONNULL_PTR orig);
+/**
+ * Checks if two RawInvoices contain equal inner contents.
+ */
+uint64_t RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR o);
+
/**
* Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKRawDataPart RawDataPart_clone(const struct LDKRawDataPart *NONNULL_PTR orig);
+/**
+ * Checks if two RawDataParts contain equal inner contents.
+ */
+uint64_t RawDataPart_hash(const struct LDKRawDataPart *NONNULL_PTR o);
+
/**
* Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKPositiveTimestamp PositiveTimestamp_clone(const struct LDKPositiveTimestamp *NONNULL_PTR orig);
+/**
+ * Checks if two PositiveTimestamps contain equal inner contents.
+ */
+uint64_t PositiveTimestamp_hash(const struct LDKPositiveTimestamp *NONNULL_PTR o);
+
/**
* Creates a copy of the SiPrefix
*/
*/
bool SiPrefix_eq(const enum LDKSiPrefix *NONNULL_PTR a, const enum LDKSiPrefix *NONNULL_PTR b);
+/**
+ * Checks if two SiPrefixs contain equal inner contents.
+ */
+uint64_t SiPrefix_hash(const enum LDKSiPrefix *NONNULL_PTR o);
+
/**
* Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
* This is effectively 10^12 * the prefix multiplier
*/
struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig);
+/**
+ * Checks if two InvoiceSignatures contain equal inner contents.
+ */
+uint64_t InvoiceSignature_hash(const struct LDKInvoiceSignature *NONNULL_PTR o);
+
/**
* Checks if two InvoiceSignatures contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
/**
* The hash of the `RawInvoice` that was signed.
*/
-MUST_USE_RES const uint8_t (*SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32];
+MUST_USE_RES const uint8_t (*SignedRawInvoice_signable_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32];
/**
* InvoiceSignature for the invoice.
MUST_USE_RES bool SignedRawInvoice_check_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg);
/**
- * Calculate the hash of the encoded `RawInvoice`
+ * Calculate the hash of the encoded `RawInvoice` which should be signed.
*/
-MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg);
+MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_signable_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg);
/**
*
* Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once
* `retry` has been exceeded for a given [`Invoice`].
*/
-MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKMultiThreadedLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetry retry);
+MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetry retry);
/**
* Pays the given [`Invoice`], caching it for later use in case a retry is needed.
*/
struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer *NONNULL_PTR this_arg);
+/**
+ * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL.
+ */
+void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj);
+
+/**
+ * Returns liquidity in msat given the public key of the HTLC source, target, and short channel
+ * id.
+ */
+MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid);
+
+/**
+ * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
+ */
+struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj);
+
+/**
+ * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
+ */
+struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser);
+
/**
* Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\"
* See [`PhantomKeysManager`] for more information on phantom node payments.
* Creates a new router using the given [`NetworkGraph`], a [`Logger`], and a randomness source
* `random_seed_bytes`.
*/
-MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKThirtyTwoBytes random_seed_bytes);
+MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKThirtyTwoBytes random_seed_bytes, struct LDKLockableScore scorer);
/**
* Constructs a new Router which calls the relevant methods on this_arg.
namespace LDK {
// Forward declarations
class Str;
+class BlindedRoute;
+class BlindedHop;
class CounterpartyCommitmentSecrets;
class TxCreationKeys;
class ChannelPublicKeys;
class Event;
class MessageSendEvent;
class MessageSendEventsProvider;
+class OnionMessageProvider;
class EventsProvider;
class EventHandler;
class BestBlock;
class WatchedOutput;
class Score;
class LockableScore;
+class WriteableScore;
class MultiThreadedLockableScore;
+class MultiThreadedScoreLock;
class ChannelUsage;
class FixedPenaltyScorer;
class ProbabilisticScorer;
class Router;
class Retry;
class PaymentError;
+class InFlightHtlcs;
class ParseError;
class ParseOrSemanticError;
class Invoice;
class SocketDescriptor;
class PeerHandleError;
class PeerManager;
+class OnionMessenger;
+class Destination;
+class SendError;
class RapidGossipSync;
class Persister;
class DecodeError;
class ClosingSignedFeeRange;
class ClosingSigned;
class UpdateAddHTLC;
+class OnionMessage;
class UpdateFulfillHTLC;
class UpdateFailHTLC;
class UpdateFailMalformedHTLC;
class CommitmentUpdate;
class ChannelMessageHandler;
class RoutingMessageHandler;
+class OnionMessageHandler;
class GraphSyncError;
class DefaultRouter;
class Level;
class Record;
class Logger;
+class FutureCallback;
+class Future;
class MonitorUpdateId;
class Persist;
class LockedChannelMonitor;
class C2Tuple_SignatureCVec_SignatureZZ;
class CVec_C2Tuple_u32TxOutZZ;
class CResult_ChannelInfoDecodeErrorZ;
+class COption_WriteableScoreZ;
+class CResult_NoneSendErrorZ;
class CResult_FundingCreatedDecodeErrorZ;
class CResult_ChannelAnnouncementDecodeErrorZ;
-class CVec_OutPointZ;
class CResult_PositiveTimestampCreationErrorZ;
+class CVec_OutPointZ;
class CResult_CVec_u8ZPeerHandleErrorZ;
class CResult_InvoiceFeaturesDecodeErrorZ;
class COption_NetworkUpdateZ;
class CResult_RouteHintDecodeErrorZ;
class C2Tuple_PublicKeyTypeZ;
class CResult_NetAddressDecodeErrorZ;
+class COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
class CResult_ChannelReestablishDecodeErrorZ;
-class CResult_CommitmentSignedDecodeErrorZ;
class CVec_UpdateAddHTLCZ;
-class CResult_UnsignedNodeAnnouncementDecodeErrorZ;
+class CResult_CommitmentSignedDecodeErrorZ;
class COption_u32Z;
class CResult_InitFeaturesDecodeErrorZ;
class CResult_StaticPaymentOutputDescriptorDecodeErrorZ;
class CResult_PaymentIdPaymentSendFailureZ;
-class CResult_ReplyChannelRangeDecodeErrorZ;
+class CResult_OnionMessageDecodeErrorZ;
class CResult_CommitmentTransactionDecodeErrorZ;
-class COption_C2Tuple_usizeTransactionZZ;
class CResult_TransactionNoneZ;
class CResult_ClosingSignedFeeRangeDecodeErrorZ;
class CResult_PingDecodeErrorZ;
+class CResult_UnsignedNodeAnnouncementDecodeErrorZ;
+class CResult_ReplyChannelRangeDecodeErrorZ;
class CResult_GossipTimestampFilterDecodeErrorZ;
class CResult_InvoiceSignOrCreationErrorZ;
-class COption_FilterZ;
class CVec_TransactionOutputsZ;
class CResult_ErrorMessageDecodeErrorZ;
class CResult_OpenChannelDecodeErrorZ;
class CVec_CVec_u8ZZ;
+class COption_FilterZ;
class CResult_SecretKeyErrorZ;
class CResult_ShutdownScriptDecodeErrorZ;
class CResult_ProbabilisticScorerDecodeErrorZ;
class CResult_FundingSignedDecodeErrorZ;
class CResult_NetworkGraphDecodeErrorZ;
class CVec_RouteHopZ;
-class CResult_NonePaymentSendFailureZ;
class CResult_NodeInfoDecodeErrorZ;
+class CVec_NodeIdZ;
class CResult_RouteLightningErrorZ;
class CResult_ChannelPublicKeysDecodeErrorZ;
-class CVec_NodeIdZ;
class CVec_u8Z;
class CVec_C2Tuple_BlockHashChannelMonitorZZ;
+class CResult_NonePaymentSendFailureZ;
class CVec_ThirtyTwoBytesZ;
class CResult_ClosingSignedDecodeErrorZ;
-class CResult_HolderCommitmentTransactionDecodeErrorZ;
class CVec_CResult_NoneAPIErrorZZ;
+class CResult_HolderCommitmentTransactionDecodeErrorZ;
class CResult_CounterpartyCommitmentSecretsDecodeErrorZ;
class CResult_ChannelCounterpartyDecodeErrorZ;
class CResult_WarningMessageDecodeErrorZ;
class CResult_PaymentPurposeDecodeErrorZ;
class CResult_InitDecodeErrorZ;
class CResult_OutPointDecodeErrorZ;
+class CResult_BlindedRouteDecodeErrorZ;
class CVec_ChannelDetailsZ;
-class CResult_SignDecodeErrorZ;
class CVec_MessageSendEventZ;
+class CResult_SignDecodeErrorZ;
class COption_NetAddressZ;
class C2Tuple_OutPointScriptZ;
class CResult_RouteHintHopDecodeErrorZ;
class CResult_C2Tuple_SignatureSignatureZNoneZ;
-class CVec_NodeAnnouncementZ;
class CResult_UpdateFailMalformedHTLCDecodeErrorZ;
-class CResult_UnsignedChannelAnnouncementDecodeErrorZ;
+class CResult_SharedSecretNoneZ;
class CVec_TxidZ;
class COption_AccessZ;
class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
-class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ;
+class CResult_PongDecodeErrorZ;
class CResult_CVec_CVec_u8ZZNoneZ;
class C2Tuple_SignatureSignatureZ;
class C2Tuple_PaymentHashPaymentSecretZ;
class CResult_AcceptChannelDecodeErrorZ;
class CVec_SignatureZ;
class CVec_u64Z;
-class CResult_PongDecodeErrorZ;
+class CResult_UnsignedChannelAnnouncementDecodeErrorZ;
class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ;
class C2Tuple_PaymentHashPaymentIdZ;
class CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ;
class CResult_NoneErrorZ;
class CResult_COption_HTLCDestinationZDecodeErrorZ;
+class CResult_InFlightHtlcsDecodeErrorZ;
class CResult_StringErrorZ;
-class C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ;
class CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ;
class COption_EventZ;
+class C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ;
class CResult_ChannelTypeFeaturesDecodeErrorZ;
class CResult_SiPrefixParseErrorZ;
class CVec_RouteHintZ;
class COption_u16Z;
+class CResult_BlindedHopDecodeErrorZ;
class CVec_CVec_RouteHopZZ;
class CResult_TrustedCommitmentTransactionNoneZ;
class CResult_FixedPenaltyScorerDecodeErrorZ;
class CResult_PrivateRouteCreationErrorZ;
class CResult_boolPeerHandleErrorZ;
class CVec_UpdateFulfillHTLCZ;
+class CResult_BlindedRouteNoneZ;
class CResult_AnnouncementSignaturesDecodeErrorZ;
class CResult_UpdateFulfillHTLCDecodeErrorZ;
class CResult_ChannelUpdateDecodeErrorZ;
class CResult_InMemorySignerDecodeErrorZ;
class CResult_PaymentSecretAPIErrorZ;
class CResult_CounterpartyForwardingInfoDecodeErrorZ;
+class COption_ScalarZ;
class CResult_SignedRawInvoiceParseErrorZ;
-class C2Tuple_u32ScriptZ;
class CResult_RouteDecodeErrorZ;
class CResult_BuiltCommitmentTransactionDecodeErrorZ;
class COption_NoneZ;
-class CResult_ChannelUpdateInfoDecodeErrorZ;
class CVec_TxOutZ;
+class CResult_ChannelUpdateInfoDecodeErrorZ;
+class C2Tuple_u32ScriptZ;
class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ;
class CVec_UpdateFailHTLCZ;
class CResult_ReplyShortChannelIdsEndDecodeErrorZ;
const LDKStr* operator &() const { return &self; }
const LDKStr* operator ->() const { return &self; }
};
+class BlindedRoute {
+private:
+ LDKBlindedRoute self;
+public:
+ BlindedRoute(const BlindedRoute&) = delete;
+ BlindedRoute(BlindedRoute&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedRoute)); }
+ BlindedRoute(LDKBlindedRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedRoute)); }
+ operator LDKBlindedRoute() && { LDKBlindedRoute res = self; memset(&self, 0, sizeof(LDKBlindedRoute)); return res; }
+ ~BlindedRoute() { BlindedRoute_free(self); }
+ BlindedRoute& operator=(BlindedRoute&& o) { BlindedRoute_free(self); self = o.self; memset(&o, 0, sizeof(BlindedRoute)); return *this; }
+ LDKBlindedRoute* operator &() { return &self; }
+ LDKBlindedRoute* operator ->() { return &self; }
+ const LDKBlindedRoute* operator &() const { return &self; }
+ const LDKBlindedRoute* operator ->() const { return &self; }
+};
+class BlindedHop {
+private:
+ LDKBlindedHop self;
+public:
+ BlindedHop(const BlindedHop&) = delete;
+ BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); }
+ BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); }
+ operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; }
+ ~BlindedHop() { BlindedHop_free(self); }
+ BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; }
+ LDKBlindedHop* operator &() { return &self; }
+ LDKBlindedHop* operator ->() { return &self; }
+ const LDKBlindedHop* operator &() const { return &self; }
+ const LDKBlindedHop* operator ->() const { return &self; }
+};
class CounterpartyCommitmentSecrets {
private:
LDKCounterpartyCommitmentSecrets self;
*/
inline LDK::CVec_MessageSendEventZ get_and_clear_pending_msg_events();
};
+class OnionMessageProvider {
+private:
+ LDKOnionMessageProvider self;
+public:
+ OnionMessageProvider(const OnionMessageProvider&) = delete;
+ OnionMessageProvider(OnionMessageProvider&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageProvider)); }
+ OnionMessageProvider(LDKOnionMessageProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageProvider)); }
+ operator LDKOnionMessageProvider() && { LDKOnionMessageProvider res = self; memset(&self, 0, sizeof(LDKOnionMessageProvider)); return res; }
+ ~OnionMessageProvider() { OnionMessageProvider_free(self); }
+ OnionMessageProvider& operator=(OnionMessageProvider&& o) { OnionMessageProvider_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageProvider)); return *this; }
+ LDKOnionMessageProvider* operator &() { return &self; }
+ LDKOnionMessageProvider* operator ->() { return &self; }
+ const LDKOnionMessageProvider* operator &() const { return &self; }
+ const LDKOnionMessageProvider* operator ->() const { return &self; }
+ /**
+ * Gets the next pending onion message for the peer with the given node id.
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ inline LDK::OnionMessage next_onion_message_for_peer(struct LDKPublicKey peer_node_id);
+};
class EventsProvider {
private:
LDKEventsProvider self;
/**
* Processes any events generated since the last call using the given event handler.
*
- * Subsequent calls must only process new events. However, handlers must be capable of handling
- * duplicate events across process restarts. This may occur if the provider was recovered from
- * an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ * See the trait-level documentation for requirements.
*/
inline void process_pending_events(struct LDKEventHandler handler);
};
* in the event of a chain reorganization, it must not be called with a `header` that is no
* longer in the chain as of the last call to [`best_block_updated`].
*
- * [chain order]: Confirm#Order
+ * [chain order]: Confirm#order
* [`best_block_updated`]: Self::best_block_updated
*/
inline void transactions_confirmed(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height);
* Processes a transaction that is no longer confirmed as result of a chain reorganization.
*
* Should be called for any transaction returned by [`get_relevant_txids`] if it has been
- * reorganized out of the best chain. Once called, the given transaction should not be returned
- * by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`].
+ * reorganized out of the best chain. Once called, the given transaction will not be returned
+ * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`].
*
* [`get_relevant_txids`]: Self::get_relevant_txids
* [`transactions_confirmed`]: Self::transactions_confirmed
/**
* Returns transactions that should be monitored for reorganization out of the chain.
*
- * Should include any transactions passed to [`transactions_confirmed`] that have insufficient
- * confirmations to be safe from a chain reorganization. Should not include any transactions
- * passed to [`transaction_unconfirmed`] unless later reconfirmed.
+ * Will include any transactions passed to [`transactions_confirmed`] that have insufficient
+ * confirmations to be safe from a chain reorganization. Will not include any transactions
+ * passed to [`transaction_unconfirmed`], unless later reconfirmed.
*
* May be called to determine the subset of transactions that must still be monitored for
* reorganization. Will be idempotent between calls but may change as a result of calls to the
/**
* Registers interest in spends of a transaction output.
*
- * Optionally, when `output.block_hash` is set, should return any transaction spending the
- * output that is found in the corresponding block along with its index.
- *
- * This return value is useful for Electrum clients in order to supply in-block descendant
- * transactions which otherwise were not included. This is not necessary for other clients if
- * such descendant transactions were already included (e.g., when a BIP 157 client provides the
- * full block).
+ * Note that this method might be called during processing of a new block. You therefore need
+ * to ensure that also dependent output spents within an already connected block are correctly
+ * handled, e.g., by re-scanning the block in question whenever new outputs have been
+ * registered mid-processing.
*/
- inline LDK::COption_C2Tuple_usizeTransactionZZ register_output(struct LDKWatchedOutput output);
+ inline void register_output(struct LDKWatchedOutput output);
};
class WatchedOutput {
private:
*/
inline LDK::Score lock();
};
+class WriteableScore {
+private:
+ LDKWriteableScore self;
+public:
+ WriteableScore(const WriteableScore&) = delete;
+ WriteableScore(WriteableScore&& o) : self(o.self) { memset(&o, 0, sizeof(WriteableScore)); }
+ WriteableScore(LDKWriteableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWriteableScore)); }
+ operator LDKWriteableScore() && { LDKWriteableScore res = self; memset(&self, 0, sizeof(LDKWriteableScore)); return res; }
+ ~WriteableScore() { WriteableScore_free(self); }
+ WriteableScore& operator=(WriteableScore&& o) { WriteableScore_free(self); self = o.self; memset(&o, 0, sizeof(WriteableScore)); return *this; }
+ LDKWriteableScore* operator &() { return &self; }
+ LDKWriteableScore* operator ->() { return &self; }
+ const LDKWriteableScore* operator &() const { return &self; }
+ const LDKWriteableScore* operator ->() const { return &self; }
+};
class MultiThreadedLockableScore {
private:
LDKMultiThreadedLockableScore self;
const LDKMultiThreadedLockableScore* operator &() const { return &self; }
const LDKMultiThreadedLockableScore* operator ->() const { return &self; }
};
+class MultiThreadedScoreLock {
+private:
+ LDKMultiThreadedScoreLock self;
+public:
+ MultiThreadedScoreLock(const MultiThreadedScoreLock&) = delete;
+ MultiThreadedScoreLock(MultiThreadedScoreLock&& o) : self(o.self) { memset(&o, 0, sizeof(MultiThreadedScoreLock)); }
+ MultiThreadedScoreLock(LDKMultiThreadedScoreLock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMultiThreadedScoreLock)); }
+ operator LDKMultiThreadedScoreLock() && { LDKMultiThreadedScoreLock res = self; memset(&self, 0, sizeof(LDKMultiThreadedScoreLock)); return res; }
+ ~MultiThreadedScoreLock() { MultiThreadedScoreLock_free(self); }
+ MultiThreadedScoreLock& operator=(MultiThreadedScoreLock&& o) { MultiThreadedScoreLock_free(self); self = o.self; memset(&o, 0, sizeof(MultiThreadedScoreLock)); return *this; }
+ LDKMultiThreadedScoreLock* operator &() { return &self; }
+ LDKMultiThreadedScoreLock* operator ->() { return &self; }
+ const LDKMultiThreadedScoreLock* operator &() const { return &self; }
+ const LDKMultiThreadedScoreLock* operator ->() const { return &self; }
+};
class ChannelUsage {
private:
LDKChannelUsage self;
* parameter.
*/
inline LDK::CResult_SecretKeyNoneZ get_node_secret(enum LDKRecipient recipient);
+ /**
+ * Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if
+ * one is provided. Note that this tweak can be applied to `other_key` instead of our node
+ * secret, though this is less efficient.
+ *
+ * [`node secret`]: Self::get_node_secret
+ */
+ inline LDK::CResult_SharedSecretNoneZ ecdh(enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak);
/**
* Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
*
*
* Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- inline LDK::CResult_RouteLightningErrorZ find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer);
+ inline LDK::CResult_RouteLightningErrorZ find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs);
+ /**
+ * Lets the router know that payment through a specific path has failed.
+ */
+ inline void notify_payment_path_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
+ /**
+ * Lets the router know that payment through a specific path was successful.
+ */
+ inline void notify_payment_path_successful(struct LDKCVec_RouteHopZ path);
+ /**
+ * Lets the router know that a payment probe was successful.
+ */
+ inline void notify_payment_probe_successful(struct LDKCVec_RouteHopZ path);
+ /**
+ * Lets the router know that a payment probe failed.
+ */
+ inline void notify_payment_probe_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id);
};
class Retry {
private:
const LDKPaymentError* operator &() const { return &self; }
const LDKPaymentError* operator ->() const { return &self; }
};
+class InFlightHtlcs {
+private:
+ LDKInFlightHtlcs self;
+public:
+ InFlightHtlcs(const InFlightHtlcs&) = delete;
+ InFlightHtlcs(InFlightHtlcs&& o) : self(o.self) { memset(&o, 0, sizeof(InFlightHtlcs)); }
+ InFlightHtlcs(LDKInFlightHtlcs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInFlightHtlcs)); }
+ operator LDKInFlightHtlcs() && { LDKInFlightHtlcs res = self; memset(&self, 0, sizeof(LDKInFlightHtlcs)); return res; }
+ ~InFlightHtlcs() { InFlightHtlcs_free(self); }
+ InFlightHtlcs& operator=(InFlightHtlcs&& o) { InFlightHtlcs_free(self); self = o.self; memset(&o, 0, sizeof(InFlightHtlcs)); return *this; }
+ LDKInFlightHtlcs* operator &() { return &self; }
+ LDKInFlightHtlcs* operator ->() { return &self; }
+ const LDKInFlightHtlcs* operator &() const { return &self; }
+ const LDKInFlightHtlcs* operator ->() const { return &self; }
+};
class ParseError {
private:
LDKParseError self;
const LDKPeerManager* operator &() const { return &self; }
const LDKPeerManager* operator ->() const { return &self; }
};
+class OnionMessenger {
+private:
+ LDKOnionMessenger self;
+public:
+ OnionMessenger(const OnionMessenger&) = delete;
+ OnionMessenger(OnionMessenger&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessenger)); }
+ OnionMessenger(LDKOnionMessenger&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessenger)); }
+ operator LDKOnionMessenger() && { LDKOnionMessenger res = self; memset(&self, 0, sizeof(LDKOnionMessenger)); return res; }
+ ~OnionMessenger() { OnionMessenger_free(self); }
+ OnionMessenger& operator=(OnionMessenger&& o) { OnionMessenger_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessenger)); return *this; }
+ LDKOnionMessenger* operator &() { return &self; }
+ LDKOnionMessenger* operator ->() { return &self; }
+ const LDKOnionMessenger* operator &() const { return &self; }
+ const LDKOnionMessenger* operator ->() const { return &self; }
+};
+class Destination {
+private:
+ LDKDestination self;
+public:
+ Destination(const Destination&) = delete;
+ Destination(Destination&& o) : self(o.self) { memset(&o, 0, sizeof(Destination)); }
+ Destination(LDKDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDestination)); }
+ operator LDKDestination() && { LDKDestination res = self; memset(&self, 0, sizeof(LDKDestination)); return res; }
+ ~Destination() { Destination_free(self); }
+ Destination& operator=(Destination&& o) { Destination_free(self); self = o.self; memset(&o, 0, sizeof(Destination)); return *this; }
+ LDKDestination* operator &() { return &self; }
+ LDKDestination* operator ->() { return &self; }
+ const LDKDestination* operator &() const { return &self; }
+ const LDKDestination* operator ->() const { return &self; }
+};
+class SendError {
+private:
+ LDKSendError self;
+public:
+ SendError(const SendError&) = delete;
+ SendError(SendError&& o) : self(o.self) { memset(&o, 0, sizeof(SendError)); }
+ SendError(LDKSendError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSendError)); }
+ operator LDKSendError() && { LDKSendError res = self; memset(&self, 0, sizeof(LDKSendError)); return res; }
+ ~SendError() { SendError_free(self); }
+ SendError& operator=(SendError&& o) { SendError_free(self); self = o.self; memset(&o, 0, sizeof(SendError)); return *this; }
+ LDKSendError* operator &() { return &self; }
+ LDKSendError* operator ->() { return &self; }
+ const LDKSendError* operator &() const { return &self; }
+ const LDKSendError* operator ->() const { return &self; }
+};
class RapidGossipSync {
private:
LDKRapidGossipSync self;
*/
inline LDK::CResult_NoneErrorZ persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph);
/**
- * Persist the given [`MultiThreadedLockableScore`] to disk, returning an error if persistence failed.
+ * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
*/
- inline LDK::CResult_NoneErrorZ persist_scorer(const struct LDKMultiThreadedLockableScore *NONNULL_PTR scorer);
+ inline LDK::CResult_NoneErrorZ persist_scorer(const struct LDKWriteableScore *NONNULL_PTR scorer);
};
class DecodeError {
private:
const LDKUpdateAddHTLC* operator &() const { return &self; }
const LDKUpdateAddHTLC* operator ->() const { return &self; }
};
+class OnionMessage {
+private:
+ LDKOnionMessage self;
+public:
+ OnionMessage(const OnionMessage&) = delete;
+ OnionMessage(OnionMessage&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessage)); }
+ OnionMessage(LDKOnionMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessage)); }
+ operator LDKOnionMessage() && { LDKOnionMessage res = self; memset(&self, 0, sizeof(LDKOnionMessage)); return res; }
+ ~OnionMessage() { OnionMessage_free(self); }
+ OnionMessage& operator=(OnionMessage&& o) { OnionMessage_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessage)); return *this; }
+ LDKOnionMessage* operator &() { return &self; }
+ LDKOnionMessage* operator ->() { return &self; }
+ const LDKOnionMessage* operator &() const { return &self; }
+ const LDKOnionMessage* operator ->() const { return &self; }
+};
class UpdateFulfillHTLC {
private:
LDKUpdateFulfillHTLC self;
* Handle an incoming error message from the given peer.
*/
inline void handle_error(struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg);
+ /**
+ * Gets the node feature flags which this handler itself supports. All available handlers are
+ * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ * which are broadcasted in our [`NodeAnnouncement`] message.
+ */
+ inline LDK::NodeFeatures provided_node_features();
+ /**
+ * Gets the init feature flags which should be sent to the given peer. All available handlers
+ * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ * which are sent in our [`Init`] message.
+ *
+ * Note that this method is called before [`Self::peer_connected`].
+ */
+ inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id);
};
class RoutingMessageHandler {
private:
*/
inline LDK::CResult_boolLightningErrorZ handle_channel_update(const struct LDKChannelUpdate *NONNULL_PTR msg);
/**
- * Gets a subset of the channel announcements and updates required to dump our routing table
- * to a remote node, starting at the short_channel_id indicated by starting_point and
- * including the batch_amount entries immediately higher in numerical value than starting_point.
+ * Gets channel announcements and updates required to dump our routing table to a remote node,
+ * starting at the short_channel_id indicated by starting_point and including announcements
+ * for a single channel.
*/
- inline LDK::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements(uint64_t starting_point, uint8_t batch_amount);
+ inline LDK::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement(uint64_t starting_point);
/**
- * Gets a subset of the node announcements required to dump our routing table to a remote node,
- * starting at the node *after* the provided publickey and including batch_amount entries
- * immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
+ * Gets a node announcement required to dump our routing table to a remote node, starting at
+ * the node *after* the provided pubkey and including up to one announcement immediately
+ * higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
* If None is provided for starting_point, we start at the first node.
*
* Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
*/
- inline LDK::CVec_NodeAnnouncementZ get_next_node_announcements(struct LDKPublicKey starting_point, uint8_t batch_amount);
+ inline LDK::NodeAnnouncement get_next_node_announcement(struct LDKPublicKey starting_point);
/**
* Called when a connection is established with a peer. This can be used to
* perform routing table synchronization using a strategy defined by the
* list of short_channel_ids.
*/
inline LDK::CResult_NoneLightningErrorZ handle_query_short_channel_ids(struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg);
+ /**
+ * Gets the node feature flags which this handler itself supports. All available handlers are
+ * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ * which are broadcasted in our [`NodeAnnouncement`] message.
+ */
+ inline LDK::NodeFeatures provided_node_features();
+ /**
+ * Gets the init feature flags which should be sent to the given peer. All available handlers
+ * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ * which are sent in our [`Init`] message.
+ *
+ * Note that this method is called before [`Self::peer_connected`].
+ */
+ inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id);
+};
+class OnionMessageHandler {
+private:
+ LDKOnionMessageHandler self;
+public:
+ OnionMessageHandler(const OnionMessageHandler&) = delete;
+ OnionMessageHandler(OnionMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageHandler)); }
+ OnionMessageHandler(LDKOnionMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageHandler)); }
+ operator LDKOnionMessageHandler() && { LDKOnionMessageHandler res = self; memset(&self, 0, sizeof(LDKOnionMessageHandler)); return res; }
+ ~OnionMessageHandler() { OnionMessageHandler_free(self); }
+ OnionMessageHandler& operator=(OnionMessageHandler&& o) { OnionMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageHandler)); return *this; }
+ LDKOnionMessageHandler* operator &() { return &self; }
+ LDKOnionMessageHandler* operator ->() { return &self; }
+ const LDKOnionMessageHandler* operator &() const { return &self; }
+ const LDKOnionMessageHandler* operator ->() const { return &self; }
+ /**
+ * Handle an incoming onion_message message from the given peer.
+ */
+ inline void handle_onion_message(struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg);
+ /**
+ * Called when a connection is established with a peer. Can be used to track which peers
+ * advertise onion message support and are online.
+ */
+ inline void peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init);
+ /**
+ * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
+ * drop and refuse to forward onion messages to this peer.
+ */
+ inline void peer_disconnected(struct LDKPublicKey their_node_id, bool no_connection_possible);
+ /**
+ * Gets the node feature flags which this handler itself supports. All available handlers are
+ * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ * which are broadcasted in our [`NodeAnnouncement`] message.
+ */
+ inline LDK::NodeFeatures provided_node_features();
+ /**
+ * Gets the init feature flags which should be sent to the given peer. All available handlers
+ * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ * which are sent in our [`Init`] message.
+ *
+ * Note that this method is called before [`Self::peer_connected`].
+ */
+ inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id);
};
class GraphSyncError {
private:
*/
inline void log(const struct LDKRecord *NONNULL_PTR record);
};
+class FutureCallback {
+private:
+ LDKFutureCallback self;
+public:
+ FutureCallback(const FutureCallback&) = delete;
+ FutureCallback(FutureCallback&& o) : self(o.self) { memset(&o, 0, sizeof(FutureCallback)); }
+ FutureCallback(LDKFutureCallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFutureCallback)); }
+ operator LDKFutureCallback() && { LDKFutureCallback res = self; memset(&self, 0, sizeof(LDKFutureCallback)); return res; }
+ ~FutureCallback() { FutureCallback_free(self); }
+ FutureCallback& operator=(FutureCallback&& o) { FutureCallback_free(self); self = o.self; memset(&o, 0, sizeof(FutureCallback)); return *this; }
+ LDKFutureCallback* operator &() { return &self; }
+ LDKFutureCallback* operator ->() { return &self; }
+ const LDKFutureCallback* operator &() const { return &self; }
+ const LDKFutureCallback* operator ->() const { return &self; }
+ /**
+ * The method which is called.
+ */
+ inline void call();
+};
+class Future {
+private:
+ LDKFuture self;
+public:
+ Future(const Future&) = delete;
+ Future(Future&& o) : self(o.self) { memset(&o, 0, sizeof(Future)); }
+ Future(LDKFuture&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFuture)); }
+ operator LDKFuture() && { LDKFuture res = self; memset(&self, 0, sizeof(LDKFuture)); return res; }
+ ~Future() { Future_free(self); }
+ Future& operator=(Future&& o) { Future_free(self); self = o.self; memset(&o, 0, sizeof(Future)); return *this; }
+ LDKFuture* operator &() { return &self; }
+ LDKFuture* operator ->() { return &self; }
+ const LDKFuture* operator &() const { return &self; }
+ const LDKFuture* operator ->() const { return &self; }
+};
class MonitorUpdateId {
private:
LDKMonitorUpdateId self;
const LDKCResult_ChannelInfoDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ChannelInfoDecodeErrorZ* operator ->() const { return &self; }
};
+class COption_WriteableScoreZ {
+private:
+ LDKCOption_WriteableScoreZ self;
+public:
+ COption_WriteableScoreZ(const COption_WriteableScoreZ&) = delete;
+ COption_WriteableScoreZ(COption_WriteableScoreZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_WriteableScoreZ)); }
+ COption_WriteableScoreZ(LDKCOption_WriteableScoreZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_WriteableScoreZ)); }
+ operator LDKCOption_WriteableScoreZ() && { LDKCOption_WriteableScoreZ res = self; memset(&self, 0, sizeof(LDKCOption_WriteableScoreZ)); return res; }
+ ~COption_WriteableScoreZ() { COption_WriteableScoreZ_free(self); }
+ COption_WriteableScoreZ& operator=(COption_WriteableScoreZ&& o) { COption_WriteableScoreZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_WriteableScoreZ)); return *this; }
+ LDKCOption_WriteableScoreZ* operator &() { return &self; }
+ LDKCOption_WriteableScoreZ* operator ->() { return &self; }
+ const LDKCOption_WriteableScoreZ* operator &() const { return &self; }
+ const LDKCOption_WriteableScoreZ* operator ->() const { return &self; }
+};
+class CResult_NoneSendErrorZ {
+private:
+ LDKCResult_NoneSendErrorZ self;
+public:
+ CResult_NoneSendErrorZ(const CResult_NoneSendErrorZ&) = delete;
+ CResult_NoneSendErrorZ(CResult_NoneSendErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneSendErrorZ)); }
+ CResult_NoneSendErrorZ(LDKCResult_NoneSendErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneSendErrorZ)); }
+ operator LDKCResult_NoneSendErrorZ() && { LDKCResult_NoneSendErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneSendErrorZ)); return res; }
+ ~CResult_NoneSendErrorZ() { CResult_NoneSendErrorZ_free(self); }
+ CResult_NoneSendErrorZ& operator=(CResult_NoneSendErrorZ&& o) { CResult_NoneSendErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneSendErrorZ)); return *this; }
+ LDKCResult_NoneSendErrorZ* operator &() { return &self; }
+ LDKCResult_NoneSendErrorZ* operator ->() { return &self; }
+ const LDKCResult_NoneSendErrorZ* operator &() const { return &self; }
+ const LDKCResult_NoneSendErrorZ* operator ->() const { return &self; }
+};
class CResult_FundingCreatedDecodeErrorZ {
private:
LDKCResult_FundingCreatedDecodeErrorZ self;
const LDKCResult_ChannelAnnouncementDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; }
};
-class CVec_OutPointZ {
-private:
- LDKCVec_OutPointZ self;
-public:
- CVec_OutPointZ(const CVec_OutPointZ&) = delete;
- CVec_OutPointZ(CVec_OutPointZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_OutPointZ)); }
- CVec_OutPointZ(LDKCVec_OutPointZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_OutPointZ)); }
- operator LDKCVec_OutPointZ() && { LDKCVec_OutPointZ res = self; memset(&self, 0, sizeof(LDKCVec_OutPointZ)); return res; }
- ~CVec_OutPointZ() { CVec_OutPointZ_free(self); }
- CVec_OutPointZ& operator=(CVec_OutPointZ&& o) { CVec_OutPointZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_OutPointZ)); return *this; }
- LDKCVec_OutPointZ* operator &() { return &self; }
- LDKCVec_OutPointZ* operator ->() { return &self; }
- const LDKCVec_OutPointZ* operator &() const { return &self; }
- const LDKCVec_OutPointZ* operator ->() const { return &self; }
-};
class CResult_PositiveTimestampCreationErrorZ {
private:
LDKCResult_PositiveTimestampCreationErrorZ self;
const LDKCResult_PositiveTimestampCreationErrorZ* operator &() const { return &self; }
const LDKCResult_PositiveTimestampCreationErrorZ* operator ->() const { return &self; }
};
+class CVec_OutPointZ {
+private:
+ LDKCVec_OutPointZ self;
+public:
+ CVec_OutPointZ(const CVec_OutPointZ&) = delete;
+ CVec_OutPointZ(CVec_OutPointZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_OutPointZ)); }
+ CVec_OutPointZ(LDKCVec_OutPointZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_OutPointZ)); }
+ operator LDKCVec_OutPointZ() && { LDKCVec_OutPointZ res = self; memset(&self, 0, sizeof(LDKCVec_OutPointZ)); return res; }
+ ~CVec_OutPointZ() { CVec_OutPointZ_free(self); }
+ CVec_OutPointZ& operator=(CVec_OutPointZ&& o) { CVec_OutPointZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_OutPointZ)); return *this; }
+ LDKCVec_OutPointZ* operator &() { return &self; }
+ LDKCVec_OutPointZ* operator ->() { return &self; }
+ const LDKCVec_OutPointZ* operator &() const { return &self; }
+ const LDKCVec_OutPointZ* operator ->() const { return &self; }
+};
class CResult_CVec_u8ZPeerHandleErrorZ {
private:
LDKCResult_CVec_u8ZPeerHandleErrorZ self;
const LDKCResult_NetAddressDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_NetAddressDecodeErrorZ* operator ->() const { return &self; }
};
+class COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+private:
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self;
+public:
+ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete;
+ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
+ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
+ operator LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() && { LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; }
+ ~COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); }
+ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ& operator=(COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) { COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return *this; }
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; }
+ LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; }
+ const LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; }
+ const LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; }
+};
class CResult_ChannelReestablishDecodeErrorZ {
private:
LDKCResult_ChannelReestablishDecodeErrorZ self;
const LDKCResult_ChannelReestablishDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() const { return &self; }
};
-class CResult_CommitmentSignedDecodeErrorZ {
-private:
- LDKCResult_CommitmentSignedDecodeErrorZ self;
-public:
- CResult_CommitmentSignedDecodeErrorZ(const CResult_CommitmentSignedDecodeErrorZ&) = delete;
- CResult_CommitmentSignedDecodeErrorZ(CResult_CommitmentSignedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); }
- CResult_CommitmentSignedDecodeErrorZ(LDKCResult_CommitmentSignedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); }
- operator LDKCResult_CommitmentSignedDecodeErrorZ() && { LDKCResult_CommitmentSignedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); return res; }
- ~CResult_CommitmentSignedDecodeErrorZ() { CResult_CommitmentSignedDecodeErrorZ_free(self); }
- CResult_CommitmentSignedDecodeErrorZ& operator=(CResult_CommitmentSignedDecodeErrorZ&& o) { CResult_CommitmentSignedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); return *this; }
- LDKCResult_CommitmentSignedDecodeErrorZ* operator &() { return &self; }
- LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_CommitmentSignedDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() const { return &self; }
-};
class CVec_UpdateAddHTLCZ {
private:
LDKCVec_UpdateAddHTLCZ self;
const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; }
const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; }
};
-class CResult_UnsignedNodeAnnouncementDecodeErrorZ {
+class CResult_CommitmentSignedDecodeErrorZ {
private:
- LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ self;
+ LDKCResult_CommitmentSignedDecodeErrorZ self;
public:
- CResult_UnsignedNodeAnnouncementDecodeErrorZ(const CResult_UnsignedNodeAnnouncementDecodeErrorZ&) = delete;
- CResult_UnsignedNodeAnnouncementDecodeErrorZ(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); }
- CResult_UnsignedNodeAnnouncementDecodeErrorZ(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); }
- operator LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ() && { LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); return res; }
- ~CResult_UnsignedNodeAnnouncementDecodeErrorZ() { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); }
- CResult_UnsignedNodeAnnouncementDecodeErrorZ& operator=(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); return *this; }
- LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() { return &self; }
- LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; }
+ CResult_CommitmentSignedDecodeErrorZ(const CResult_CommitmentSignedDecodeErrorZ&) = delete;
+ CResult_CommitmentSignedDecodeErrorZ(CResult_CommitmentSignedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); }
+ CResult_CommitmentSignedDecodeErrorZ(LDKCResult_CommitmentSignedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); }
+ operator LDKCResult_CommitmentSignedDecodeErrorZ() && { LDKCResult_CommitmentSignedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); return res; }
+ ~CResult_CommitmentSignedDecodeErrorZ() { CResult_CommitmentSignedDecodeErrorZ_free(self); }
+ CResult_CommitmentSignedDecodeErrorZ& operator=(CResult_CommitmentSignedDecodeErrorZ&& o) { CResult_CommitmentSignedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); return *this; }
+ LDKCResult_CommitmentSignedDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_CommitmentSignedDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() const { return &self; }
};
class COption_u32Z {
private:
const LDKCResult_PaymentIdPaymentSendFailureZ* operator &() const { return &self; }
const LDKCResult_PaymentIdPaymentSendFailureZ* operator ->() const { return &self; }
};
-class CResult_ReplyChannelRangeDecodeErrorZ {
+class CResult_OnionMessageDecodeErrorZ {
private:
- LDKCResult_ReplyChannelRangeDecodeErrorZ self;
+ LDKCResult_OnionMessageDecodeErrorZ self;
public:
- CResult_ReplyChannelRangeDecodeErrorZ(const CResult_ReplyChannelRangeDecodeErrorZ&) = delete;
- CResult_ReplyChannelRangeDecodeErrorZ(CResult_ReplyChannelRangeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ReplyChannelRangeDecodeErrorZ)); }
- CResult_ReplyChannelRangeDecodeErrorZ(LDKCResult_ReplyChannelRangeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ)); }
- operator LDKCResult_ReplyChannelRangeDecodeErrorZ() && { LDKCResult_ReplyChannelRangeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ)); return res; }
- ~CResult_ReplyChannelRangeDecodeErrorZ() { CResult_ReplyChannelRangeDecodeErrorZ_free(self); }
- CResult_ReplyChannelRangeDecodeErrorZ& operator=(CResult_ReplyChannelRangeDecodeErrorZ&& o) { CResult_ReplyChannelRangeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ReplyChannelRangeDecodeErrorZ)); return *this; }
- LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() { return &self; }
- LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; }
+ CResult_OnionMessageDecodeErrorZ(const CResult_OnionMessageDecodeErrorZ&) = delete;
+ CResult_OnionMessageDecodeErrorZ(CResult_OnionMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionMessageDecodeErrorZ)); }
+ CResult_OnionMessageDecodeErrorZ(LDKCResult_OnionMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionMessageDecodeErrorZ)); }
+ operator LDKCResult_OnionMessageDecodeErrorZ() && { LDKCResult_OnionMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionMessageDecodeErrorZ)); return res; }
+ ~CResult_OnionMessageDecodeErrorZ() { CResult_OnionMessageDecodeErrorZ_free(self); }
+ CResult_OnionMessageDecodeErrorZ& operator=(CResult_OnionMessageDecodeErrorZ&& o) { CResult_OnionMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionMessageDecodeErrorZ)); return *this; }
+ LDKCResult_OnionMessageDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_OnionMessageDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_OnionMessageDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_OnionMessageDecodeErrorZ* operator ->() const { return &self; }
};
class CResult_CommitmentTransactionDecodeErrorZ {
private:
const LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() const { return &self; }
};
-class COption_C2Tuple_usizeTransactionZZ {
-private:
- LDKCOption_C2Tuple_usizeTransactionZZ self;
-public:
- COption_C2Tuple_usizeTransactionZZ(const COption_C2Tuple_usizeTransactionZZ&) = delete;
- COption_C2Tuple_usizeTransactionZZ(COption_C2Tuple_usizeTransactionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_usizeTransactionZZ)); }
- COption_C2Tuple_usizeTransactionZZ(LDKCOption_C2Tuple_usizeTransactionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_usizeTransactionZZ)); }
- operator LDKCOption_C2Tuple_usizeTransactionZZ() && { LDKCOption_C2Tuple_usizeTransactionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_usizeTransactionZZ)); return res; }
- ~COption_C2Tuple_usizeTransactionZZ() { COption_C2Tuple_usizeTransactionZZ_free(self); }
- COption_C2Tuple_usizeTransactionZZ& operator=(COption_C2Tuple_usizeTransactionZZ&& o) { COption_C2Tuple_usizeTransactionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_usizeTransactionZZ)); return *this; }
- LDKCOption_C2Tuple_usizeTransactionZZ* operator &() { return &self; }
- LDKCOption_C2Tuple_usizeTransactionZZ* operator ->() { return &self; }
- const LDKCOption_C2Tuple_usizeTransactionZZ* operator &() const { return &self; }
- const LDKCOption_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; }
-};
class CResult_TransactionNoneZ {
private:
LDKCResult_TransactionNoneZ self;
const LDKCResult_PingDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_PingDecodeErrorZ* operator ->() const { return &self; }
};
+class CResult_UnsignedNodeAnnouncementDecodeErrorZ {
+private:
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ self;
+public:
+ CResult_UnsignedNodeAnnouncementDecodeErrorZ(const CResult_UnsignedNodeAnnouncementDecodeErrorZ&) = delete;
+ CResult_UnsignedNodeAnnouncementDecodeErrorZ(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); }
+ CResult_UnsignedNodeAnnouncementDecodeErrorZ(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); }
+ operator LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ() && { LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); return res; }
+ ~CResult_UnsignedNodeAnnouncementDecodeErrorZ() { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); }
+ CResult_UnsignedNodeAnnouncementDecodeErrorZ& operator=(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); return *this; }
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; }
+};
+class CResult_ReplyChannelRangeDecodeErrorZ {
+private:
+ LDKCResult_ReplyChannelRangeDecodeErrorZ self;
+public:
+ CResult_ReplyChannelRangeDecodeErrorZ(const CResult_ReplyChannelRangeDecodeErrorZ&) = delete;
+ CResult_ReplyChannelRangeDecodeErrorZ(CResult_ReplyChannelRangeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ReplyChannelRangeDecodeErrorZ)); }
+ CResult_ReplyChannelRangeDecodeErrorZ(LDKCResult_ReplyChannelRangeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ)); }
+ operator LDKCResult_ReplyChannelRangeDecodeErrorZ() && { LDKCResult_ReplyChannelRangeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ)); return res; }
+ ~CResult_ReplyChannelRangeDecodeErrorZ() { CResult_ReplyChannelRangeDecodeErrorZ_free(self); }
+ CResult_ReplyChannelRangeDecodeErrorZ& operator=(CResult_ReplyChannelRangeDecodeErrorZ&& o) { CResult_ReplyChannelRangeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ReplyChannelRangeDecodeErrorZ)); return *this; }
+ LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_GossipTimestampFilterDecodeErrorZ {
private:
LDKCResult_GossipTimestampFilterDecodeErrorZ self;
const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; }
const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; }
};
-class COption_FilterZ {
-private:
- LDKCOption_FilterZ self;
-public:
- COption_FilterZ(const COption_FilterZ&) = delete;
- COption_FilterZ(COption_FilterZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_FilterZ)); }
- COption_FilterZ(LDKCOption_FilterZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_FilterZ)); }
- operator LDKCOption_FilterZ() && { LDKCOption_FilterZ res = self; memset(&self, 0, sizeof(LDKCOption_FilterZ)); return res; }
- ~COption_FilterZ() { COption_FilterZ_free(self); }
- COption_FilterZ& operator=(COption_FilterZ&& o) { COption_FilterZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_FilterZ)); return *this; }
- LDKCOption_FilterZ* operator &() { return &self; }
- LDKCOption_FilterZ* operator ->() { return &self; }
- const LDKCOption_FilterZ* operator &() const { return &self; }
- const LDKCOption_FilterZ* operator ->() const { return &self; }
-};
class CVec_TransactionOutputsZ {
private:
LDKCVec_TransactionOutputsZ self;
const LDKCVec_CVec_u8ZZ* operator &() const { return &self; }
const LDKCVec_CVec_u8ZZ* operator ->() const { return &self; }
};
+class COption_FilterZ {
+private:
+ LDKCOption_FilterZ self;
+public:
+ COption_FilterZ(const COption_FilterZ&) = delete;
+ COption_FilterZ(COption_FilterZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_FilterZ)); }
+ COption_FilterZ(LDKCOption_FilterZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_FilterZ)); }
+ operator LDKCOption_FilterZ() && { LDKCOption_FilterZ res = self; memset(&self, 0, sizeof(LDKCOption_FilterZ)); return res; }
+ ~COption_FilterZ() { COption_FilterZ_free(self); }
+ COption_FilterZ& operator=(COption_FilterZ&& o) { COption_FilterZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_FilterZ)); return *this; }
+ LDKCOption_FilterZ* operator &() { return &self; }
+ LDKCOption_FilterZ* operator ->() { return &self; }
+ const LDKCOption_FilterZ* operator &() const { return &self; }
+ const LDKCOption_FilterZ* operator ->() const { return &self; }
+};
class CResult_SecretKeyErrorZ {
private:
LDKCResult_SecretKeyErrorZ self;
const LDKCVec_RouteHopZ* operator &() const { return &self; }
const LDKCVec_RouteHopZ* operator ->() const { return &self; }
};
-class CResult_NonePaymentSendFailureZ {
+class CResult_NodeInfoDecodeErrorZ {
private:
- LDKCResult_NonePaymentSendFailureZ self;
-public:
- CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete;
- CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); }
- CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); }
- operator LDKCResult_NonePaymentSendFailureZ() && { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; }
- ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); }
- CResult_NonePaymentSendFailureZ& operator=(CResult_NonePaymentSendFailureZ&& o) { CResult_NonePaymentSendFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); return *this; }
- LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; }
- LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; }
- const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; }
- const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; }
-};
-class CResult_NodeInfoDecodeErrorZ {
-private:
- LDKCResult_NodeInfoDecodeErrorZ self;
+ LDKCResult_NodeInfoDecodeErrorZ self;
public:
CResult_NodeInfoDecodeErrorZ(const CResult_NodeInfoDecodeErrorZ&) = delete;
CResult_NodeInfoDecodeErrorZ(CResult_NodeInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NodeInfoDecodeErrorZ)); }
const LDKCResult_NodeInfoDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_NodeInfoDecodeErrorZ* operator ->() const { return &self; }
};
+class CVec_NodeIdZ {
+private:
+ LDKCVec_NodeIdZ self;
+public:
+ CVec_NodeIdZ(const CVec_NodeIdZ&) = delete;
+ CVec_NodeIdZ(CVec_NodeIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NodeIdZ)); }
+ CVec_NodeIdZ(LDKCVec_NodeIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NodeIdZ)); }
+ operator LDKCVec_NodeIdZ() && { LDKCVec_NodeIdZ res = self; memset(&self, 0, sizeof(LDKCVec_NodeIdZ)); return res; }
+ ~CVec_NodeIdZ() { CVec_NodeIdZ_free(self); }
+ CVec_NodeIdZ& operator=(CVec_NodeIdZ&& o) { CVec_NodeIdZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_NodeIdZ)); return *this; }
+ LDKCVec_NodeIdZ* operator &() { return &self; }
+ LDKCVec_NodeIdZ* operator ->() { return &self; }
+ const LDKCVec_NodeIdZ* operator &() const { return &self; }
+ const LDKCVec_NodeIdZ* operator ->() const { return &self; }
+};
class CResult_RouteLightningErrorZ {
private:
LDKCResult_RouteLightningErrorZ self;
const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() const { return &self; }
};
-class CVec_NodeIdZ {
-private:
- LDKCVec_NodeIdZ self;
-public:
- CVec_NodeIdZ(const CVec_NodeIdZ&) = delete;
- CVec_NodeIdZ(CVec_NodeIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NodeIdZ)); }
- CVec_NodeIdZ(LDKCVec_NodeIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NodeIdZ)); }
- operator LDKCVec_NodeIdZ() && { LDKCVec_NodeIdZ res = self; memset(&self, 0, sizeof(LDKCVec_NodeIdZ)); return res; }
- ~CVec_NodeIdZ() { CVec_NodeIdZ_free(self); }
- CVec_NodeIdZ& operator=(CVec_NodeIdZ&& o) { CVec_NodeIdZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_NodeIdZ)); return *this; }
- LDKCVec_NodeIdZ* operator &() { return &self; }
- LDKCVec_NodeIdZ* operator ->() { return &self; }
- const LDKCVec_NodeIdZ* operator &() const { return &self; }
- const LDKCVec_NodeIdZ* operator ->() const { return &self; }
-};
class CVec_u8Z {
private:
LDKCVec_u8Z self;
const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator &() const { return &self; }
const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator ->() const { return &self; }
};
+class CResult_NonePaymentSendFailureZ {
+private:
+ LDKCResult_NonePaymentSendFailureZ self;
+public:
+ CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete;
+ CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); }
+ CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); }
+ operator LDKCResult_NonePaymentSendFailureZ() && { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; }
+ ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); }
+ CResult_NonePaymentSendFailureZ& operator=(CResult_NonePaymentSendFailureZ&& o) { CResult_NonePaymentSendFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); return *this; }
+ LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; }
+ LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; }
+ const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; }
+ const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; }
+};
class CVec_ThirtyTwoBytesZ {
private:
LDKCVec_ThirtyTwoBytesZ self;
const LDKCResult_ClosingSignedDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ClosingSignedDecodeErrorZ* operator ->() const { return &self; }
};
-class CResult_HolderCommitmentTransactionDecodeErrorZ {
-private:
- LDKCResult_HolderCommitmentTransactionDecodeErrorZ self;
-public:
- CResult_HolderCommitmentTransactionDecodeErrorZ(const CResult_HolderCommitmentTransactionDecodeErrorZ&) = delete;
- CResult_HolderCommitmentTransactionDecodeErrorZ(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); }
- CResult_HolderCommitmentTransactionDecodeErrorZ(LDKCResult_HolderCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); }
- operator LDKCResult_HolderCommitmentTransactionDecodeErrorZ() && { LDKCResult_HolderCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); return res; }
- ~CResult_HolderCommitmentTransactionDecodeErrorZ() { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); }
- CResult_HolderCommitmentTransactionDecodeErrorZ& operator=(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); return *this; }
- LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() { return &self; }
- LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; }
-};
class CVec_CResult_NoneAPIErrorZZ {
private:
LDKCVec_CResult_NoneAPIErrorZZ self;
const LDKCVec_CResult_NoneAPIErrorZZ* operator &() const { return &self; }
const LDKCVec_CResult_NoneAPIErrorZZ* operator ->() const { return &self; }
};
+class CResult_HolderCommitmentTransactionDecodeErrorZ {
+private:
+ LDKCResult_HolderCommitmentTransactionDecodeErrorZ self;
+public:
+ CResult_HolderCommitmentTransactionDecodeErrorZ(const CResult_HolderCommitmentTransactionDecodeErrorZ&) = delete;
+ CResult_HolderCommitmentTransactionDecodeErrorZ(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); }
+ CResult_HolderCommitmentTransactionDecodeErrorZ(LDKCResult_HolderCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); }
+ operator LDKCResult_HolderCommitmentTransactionDecodeErrorZ() && { LDKCResult_HolderCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); return res; }
+ ~CResult_HolderCommitmentTransactionDecodeErrorZ() { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); }
+ CResult_HolderCommitmentTransactionDecodeErrorZ& operator=(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); return *this; }
+ LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_CounterpartyCommitmentSecretsDecodeErrorZ {
private:
LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ self;
const LDKCResult_OutPointDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_OutPointDecodeErrorZ* operator ->() const { return &self; }
};
+class CResult_BlindedRouteDecodeErrorZ {
+private:
+ LDKCResult_BlindedRouteDecodeErrorZ self;
+public:
+ CResult_BlindedRouteDecodeErrorZ(const CResult_BlindedRouteDecodeErrorZ&) = delete;
+ CResult_BlindedRouteDecodeErrorZ(CResult_BlindedRouteDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedRouteDecodeErrorZ)); }
+ CResult_BlindedRouteDecodeErrorZ(LDKCResult_BlindedRouteDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedRouteDecodeErrorZ)); }
+ operator LDKCResult_BlindedRouteDecodeErrorZ() && { LDKCResult_BlindedRouteDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedRouteDecodeErrorZ)); return res; }
+ ~CResult_BlindedRouteDecodeErrorZ() { CResult_BlindedRouteDecodeErrorZ_free(self); }
+ CResult_BlindedRouteDecodeErrorZ& operator=(CResult_BlindedRouteDecodeErrorZ&& o) { CResult_BlindedRouteDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedRouteDecodeErrorZ)); return *this; }
+ LDKCResult_BlindedRouteDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_BlindedRouteDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_BlindedRouteDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_BlindedRouteDecodeErrorZ* operator ->() const { return &self; }
+};
class CVec_ChannelDetailsZ {
private:
LDKCVec_ChannelDetailsZ self;
const LDKCVec_ChannelDetailsZ* operator &() const { return &self; }
const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; }
};
-class CResult_SignDecodeErrorZ {
-private:
- LDKCResult_SignDecodeErrorZ self;
-public:
- CResult_SignDecodeErrorZ(const CResult_SignDecodeErrorZ&) = delete;
- CResult_SignDecodeErrorZ(CResult_SignDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); }
- CResult_SignDecodeErrorZ(LDKCResult_SignDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); }
- operator LDKCResult_SignDecodeErrorZ() && { LDKCResult_SignDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); return res; }
- ~CResult_SignDecodeErrorZ() { CResult_SignDecodeErrorZ_free(self); }
- CResult_SignDecodeErrorZ& operator=(CResult_SignDecodeErrorZ&& o) { CResult_SignDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); return *this; }
- LDKCResult_SignDecodeErrorZ* operator &() { return &self; }
- LDKCResult_SignDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_SignDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_SignDecodeErrorZ* operator ->() const { return &self; }
-};
class CVec_MessageSendEventZ {
private:
LDKCVec_MessageSendEventZ self;
const LDKCVec_MessageSendEventZ* operator &() const { return &self; }
const LDKCVec_MessageSendEventZ* operator ->() const { return &self; }
};
+class CResult_SignDecodeErrorZ {
+private:
+ LDKCResult_SignDecodeErrorZ self;
+public:
+ CResult_SignDecodeErrorZ(const CResult_SignDecodeErrorZ&) = delete;
+ CResult_SignDecodeErrorZ(CResult_SignDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); }
+ CResult_SignDecodeErrorZ(LDKCResult_SignDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); }
+ operator LDKCResult_SignDecodeErrorZ() && { LDKCResult_SignDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); return res; }
+ ~CResult_SignDecodeErrorZ() { CResult_SignDecodeErrorZ_free(self); }
+ CResult_SignDecodeErrorZ& operator=(CResult_SignDecodeErrorZ&& o) { CResult_SignDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); return *this; }
+ LDKCResult_SignDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_SignDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_SignDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_SignDecodeErrorZ* operator ->() const { return &self; }
+};
class COption_NetAddressZ {
private:
LDKCOption_NetAddressZ self;
const LDKCResult_C2Tuple_SignatureSignatureZNoneZ* operator &() const { return &self; }
const LDKCResult_C2Tuple_SignatureSignatureZNoneZ* operator ->() const { return &self; }
};
-class CVec_NodeAnnouncementZ {
-private:
- LDKCVec_NodeAnnouncementZ self;
-public:
- CVec_NodeAnnouncementZ(const CVec_NodeAnnouncementZ&) = delete;
- CVec_NodeAnnouncementZ(CVec_NodeAnnouncementZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NodeAnnouncementZ)); }
- CVec_NodeAnnouncementZ(LDKCVec_NodeAnnouncementZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); }
- operator LDKCVec_NodeAnnouncementZ() && { LDKCVec_NodeAnnouncementZ res = self; memset(&self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); return res; }
- ~CVec_NodeAnnouncementZ() { CVec_NodeAnnouncementZ_free(self); }
- CVec_NodeAnnouncementZ& operator=(CVec_NodeAnnouncementZ&& o) { CVec_NodeAnnouncementZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_NodeAnnouncementZ)); return *this; }
- LDKCVec_NodeAnnouncementZ* operator &() { return &self; }
- LDKCVec_NodeAnnouncementZ* operator ->() { return &self; }
- const LDKCVec_NodeAnnouncementZ* operator &() const { return &self; }
- const LDKCVec_NodeAnnouncementZ* operator ->() const { return &self; }
-};
class CResult_UpdateFailMalformedHTLCDecodeErrorZ {
private:
LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ self;
const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator ->() const { return &self; }
};
-class CResult_UnsignedChannelAnnouncementDecodeErrorZ {
+class CResult_SharedSecretNoneZ {
private:
- LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ self;
+ LDKCResult_SharedSecretNoneZ self;
public:
- CResult_UnsignedChannelAnnouncementDecodeErrorZ(const CResult_UnsignedChannelAnnouncementDecodeErrorZ&) = delete;
- CResult_UnsignedChannelAnnouncementDecodeErrorZ(CResult_UnsignedChannelAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedChannelAnnouncementDecodeErrorZ)); }
- CResult_UnsignedChannelAnnouncementDecodeErrorZ(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ)); }
- operator LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ() && { LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ)); return res; }
- ~CResult_UnsignedChannelAnnouncementDecodeErrorZ() { CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(self); }
- CResult_UnsignedChannelAnnouncementDecodeErrorZ& operator=(CResult_UnsignedChannelAnnouncementDecodeErrorZ&& o) { CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedChannelAnnouncementDecodeErrorZ)); return *this; }
- LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() { return &self; }
- LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; }
+ CResult_SharedSecretNoneZ(const CResult_SharedSecretNoneZ&) = delete;
+ CResult_SharedSecretNoneZ(CResult_SharedSecretNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SharedSecretNoneZ)); }
+ CResult_SharedSecretNoneZ(LDKCResult_SharedSecretNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SharedSecretNoneZ)); }
+ operator LDKCResult_SharedSecretNoneZ() && { LDKCResult_SharedSecretNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_SharedSecretNoneZ)); return res; }
+ ~CResult_SharedSecretNoneZ() { CResult_SharedSecretNoneZ_free(self); }
+ CResult_SharedSecretNoneZ& operator=(CResult_SharedSecretNoneZ&& o) { CResult_SharedSecretNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SharedSecretNoneZ)); return *this; }
+ LDKCResult_SharedSecretNoneZ* operator &() { return &self; }
+ LDKCResult_SharedSecretNoneZ* operator ->() { return &self; }
+ const LDKCResult_SharedSecretNoneZ* operator &() const { return &self; }
+ const LDKCResult_SharedSecretNoneZ* operator ->() const { return &self; }
};
class CVec_TxidZ {
private:
const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; }
const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; }
};
-class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
-private:
- LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self;
-public:
- CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete;
- CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
- CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
- operator LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() && { LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; }
- ~CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); }
- CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ& operator=(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return *this; }
- LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; }
- LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; }
- const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; }
- const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; }
-};
class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
private:
LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ self;
const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() const { return &self; }
};
+class CResult_PongDecodeErrorZ {
+private:
+ LDKCResult_PongDecodeErrorZ self;
+public:
+ CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete;
+ CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); }
+ CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); }
+ operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; }
+ ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); }
+ CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; }
+ LDKCResult_PongDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_PongDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_CVec_CVec_u8ZZNoneZ {
private:
LDKCResult_CVec_CVec_u8ZZNoneZ self;
const LDKCVec_u64Z* operator &() const { return &self; }
const LDKCVec_u64Z* operator ->() const { return &self; }
};
-class CResult_PongDecodeErrorZ {
+class CResult_UnsignedChannelAnnouncementDecodeErrorZ {
private:
- LDKCResult_PongDecodeErrorZ self;
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ self;
public:
- CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete;
- CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); }
- CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); }
- operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; }
- ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); }
- CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; }
- LDKCResult_PongDecodeErrorZ* operator &() { return &self; }
- LDKCResult_PongDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; }
+ CResult_UnsignedChannelAnnouncementDecodeErrorZ(const CResult_UnsignedChannelAnnouncementDecodeErrorZ&) = delete;
+ CResult_UnsignedChannelAnnouncementDecodeErrorZ(CResult_UnsignedChannelAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedChannelAnnouncementDecodeErrorZ)); }
+ CResult_UnsignedChannelAnnouncementDecodeErrorZ(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ)); }
+ operator LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ() && { LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ)); return res; }
+ ~CResult_UnsignedChannelAnnouncementDecodeErrorZ() { CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(self); }
+ CResult_UnsignedChannelAnnouncementDecodeErrorZ& operator=(CResult_UnsignedChannelAnnouncementDecodeErrorZ&& o) { CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedChannelAnnouncementDecodeErrorZ)); return *this; }
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; }
};
class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ {
private:
const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator ->() const { return &self; }
};
+class CResult_InFlightHtlcsDecodeErrorZ {
+private:
+ LDKCResult_InFlightHtlcsDecodeErrorZ self;
+public:
+ CResult_InFlightHtlcsDecodeErrorZ(const CResult_InFlightHtlcsDecodeErrorZ&) = delete;
+ CResult_InFlightHtlcsDecodeErrorZ(CResult_InFlightHtlcsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InFlightHtlcsDecodeErrorZ)); }
+ CResult_InFlightHtlcsDecodeErrorZ(LDKCResult_InFlightHtlcsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ)); }
+ operator LDKCResult_InFlightHtlcsDecodeErrorZ() && { LDKCResult_InFlightHtlcsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ)); return res; }
+ ~CResult_InFlightHtlcsDecodeErrorZ() { CResult_InFlightHtlcsDecodeErrorZ_free(self); }
+ CResult_InFlightHtlcsDecodeErrorZ& operator=(CResult_InFlightHtlcsDecodeErrorZ&& o) { CResult_InFlightHtlcsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InFlightHtlcsDecodeErrorZ)); return *this; }
+ LDKCResult_InFlightHtlcsDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_InFlightHtlcsDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_InFlightHtlcsDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_InFlightHtlcsDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_StringErrorZ {
private:
LDKCResult_StringErrorZ self;
const LDKCResult_StringErrorZ* operator &() const { return &self; }
const LDKCResult_StringErrorZ* 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 CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ {
private:
LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ self;
const LDKCOption_EventZ* operator &() const { return &self; }
const LDKCOption_EventZ* 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 CResult_ChannelTypeFeaturesDecodeErrorZ {
private:
LDKCResult_ChannelTypeFeaturesDecodeErrorZ self;
const LDKCOption_u16Z* operator &() const { return &self; }
const LDKCOption_u16Z* operator ->() const { return &self; }
};
+class CResult_BlindedHopDecodeErrorZ {
+private:
+ LDKCResult_BlindedHopDecodeErrorZ self;
+public:
+ CResult_BlindedHopDecodeErrorZ(const CResult_BlindedHopDecodeErrorZ&) = delete;
+ CResult_BlindedHopDecodeErrorZ(CResult_BlindedHopDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedHopDecodeErrorZ)); }
+ CResult_BlindedHopDecodeErrorZ(LDKCResult_BlindedHopDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedHopDecodeErrorZ)); }
+ operator LDKCResult_BlindedHopDecodeErrorZ() && { LDKCResult_BlindedHopDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedHopDecodeErrorZ)); return res; }
+ ~CResult_BlindedHopDecodeErrorZ() { CResult_BlindedHopDecodeErrorZ_free(self); }
+ CResult_BlindedHopDecodeErrorZ& operator=(CResult_BlindedHopDecodeErrorZ&& o) { CResult_BlindedHopDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedHopDecodeErrorZ)); return *this; }
+ LDKCResult_BlindedHopDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_BlindedHopDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_BlindedHopDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_BlindedHopDecodeErrorZ* operator ->() const { return &self; }
+};
class CVec_CVec_RouteHopZZ {
private:
LDKCVec_CVec_RouteHopZZ self;
const LDKCVec_UpdateFulfillHTLCZ* operator &() const { return &self; }
const LDKCVec_UpdateFulfillHTLCZ* operator ->() const { return &self; }
};
+class CResult_BlindedRouteNoneZ {
+private:
+ LDKCResult_BlindedRouteNoneZ self;
+public:
+ CResult_BlindedRouteNoneZ(const CResult_BlindedRouteNoneZ&) = delete;
+ CResult_BlindedRouteNoneZ(CResult_BlindedRouteNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedRouteNoneZ)); }
+ CResult_BlindedRouteNoneZ(LDKCResult_BlindedRouteNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedRouteNoneZ)); }
+ operator LDKCResult_BlindedRouteNoneZ() && { LDKCResult_BlindedRouteNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedRouteNoneZ)); return res; }
+ ~CResult_BlindedRouteNoneZ() { CResult_BlindedRouteNoneZ_free(self); }
+ CResult_BlindedRouteNoneZ& operator=(CResult_BlindedRouteNoneZ&& o) { CResult_BlindedRouteNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedRouteNoneZ)); return *this; }
+ LDKCResult_BlindedRouteNoneZ* operator &() { return &self; }
+ LDKCResult_BlindedRouteNoneZ* operator ->() { return &self; }
+ const LDKCResult_BlindedRouteNoneZ* operator &() const { return &self; }
+ const LDKCResult_BlindedRouteNoneZ* operator ->() const { return &self; }
+};
class CResult_AnnouncementSignaturesDecodeErrorZ {
private:
LDKCResult_AnnouncementSignaturesDecodeErrorZ self;
const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() const { return &self; }
};
+class COption_ScalarZ {
+private:
+ LDKCOption_ScalarZ self;
+public:
+ COption_ScalarZ(const COption_ScalarZ&) = delete;
+ COption_ScalarZ(COption_ScalarZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_ScalarZ)); }
+ COption_ScalarZ(LDKCOption_ScalarZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_ScalarZ)); }
+ operator LDKCOption_ScalarZ() && { LDKCOption_ScalarZ res = self; memset(&self, 0, sizeof(LDKCOption_ScalarZ)); return res; }
+ ~COption_ScalarZ() { COption_ScalarZ_free(self); }
+ COption_ScalarZ& operator=(COption_ScalarZ&& o) { COption_ScalarZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_ScalarZ)); return *this; }
+ LDKCOption_ScalarZ* operator &() { return &self; }
+ LDKCOption_ScalarZ* operator ->() { return &self; }
+ const LDKCOption_ScalarZ* operator &() const { return &self; }
+ const LDKCOption_ScalarZ* operator ->() const { return &self; }
+};
class CResult_SignedRawInvoiceParseErrorZ {
private:
LDKCResult_SignedRawInvoiceParseErrorZ self;
const LDKCResult_SignedRawInvoiceParseErrorZ* operator &() const { return &self; }
const LDKCResult_SignedRawInvoiceParseErrorZ* 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_RouteDecodeErrorZ {
private:
LDKCResult_RouteDecodeErrorZ self;
const LDKCOption_NoneZ* operator &() const { return &self; }
const LDKCOption_NoneZ* operator ->() const { return &self; }
};
+class CVec_TxOutZ {
+private:
+ LDKCVec_TxOutZ self;
+public:
+ CVec_TxOutZ(const CVec_TxOutZ&) = delete;
+ CVec_TxOutZ(CVec_TxOutZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TxOutZ)); }
+ CVec_TxOutZ(LDKCVec_TxOutZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TxOutZ)); }
+ operator LDKCVec_TxOutZ() && { LDKCVec_TxOutZ res = self; memset(&self, 0, sizeof(LDKCVec_TxOutZ)); return res; }
+ ~CVec_TxOutZ() { CVec_TxOutZ_free(self); }
+ CVec_TxOutZ& operator=(CVec_TxOutZ&& o) { CVec_TxOutZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TxOutZ)); return *this; }
+ LDKCVec_TxOutZ* operator &() { return &self; }
+ LDKCVec_TxOutZ* operator ->() { return &self; }
+ const LDKCVec_TxOutZ* operator &() const { return &self; }
+ const LDKCVec_TxOutZ* operator ->() const { return &self; }
+};
class CResult_ChannelUpdateInfoDecodeErrorZ {
private:
LDKCResult_ChannelUpdateInfoDecodeErrorZ self;
const LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator ->() const { return &self; }
};
-class CVec_TxOutZ {
+class C2Tuple_u32ScriptZ {
private:
- LDKCVec_TxOutZ self;
+ LDKC2Tuple_u32ScriptZ self;
public:
- CVec_TxOutZ(const CVec_TxOutZ&) = delete;
- CVec_TxOutZ(CVec_TxOutZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TxOutZ)); }
- CVec_TxOutZ(LDKCVec_TxOutZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TxOutZ)); }
- operator LDKCVec_TxOutZ() && { LDKCVec_TxOutZ res = self; memset(&self, 0, sizeof(LDKCVec_TxOutZ)); return res; }
- ~CVec_TxOutZ() { CVec_TxOutZ_free(self); }
- CVec_TxOutZ& operator=(CVec_TxOutZ&& o) { CVec_TxOutZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TxOutZ)); return *this; }
- LDKCVec_TxOutZ* operator &() { return &self; }
- LDKCVec_TxOutZ* operator ->() { return &self; }
- const LDKCVec_TxOutZ* operator &() const { return &self; }
- const LDKCVec_TxOutZ* operator ->() const { return &self; }
+ 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_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
private:
LDK::CVec_MessageSendEventZ ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
return ret;
}
+inline LDK::OnionMessage OnionMessageProvider::next_onion_message_for_peer(struct LDKPublicKey peer_node_id) {
+ LDK::OnionMessage ret = (self.next_onion_message_for_peer)(self.this_arg, peer_node_id);
+ return ret;
+}
inline void EventsProvider::process_pending_events(struct LDKEventHandler handler) {
(self.process_pending_events)(self.this_arg, handler);
}
inline void Filter::register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey) {
(self.register_tx)(self.this_arg, txid, script_pubkey);
}
-inline LDK::COption_C2Tuple_usizeTransactionZZ Filter::register_output(struct LDKWatchedOutput output) {
- LDK::COption_C2Tuple_usizeTransactionZZ ret = (self.register_output)(self.this_arg, output);
- return ret;
+inline void Filter::register_output(struct LDKWatchedOutput output) {
+ (self.register_output)(self.this_arg, output);
}
inline uint64_t Score::channel_penalty_msat(uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage) {
uint64_t ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, source, target, usage);
LDK::CResult_SecretKeyNoneZ ret = (self.get_node_secret)(self.this_arg, recipient);
return ret;
}
+inline LDK::CResult_SharedSecretNoneZ KeysInterface::ecdh(enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak) {
+ LDK::CResult_SharedSecretNoneZ ret = (self.ecdh)(self.this_arg, recipient, other_key, tweak);
+ return ret;
+}
inline LDK::CVec_u8Z KeysInterface::get_destination_script() {
LDK::CVec_u8Z ret = (self.get_destination_script)(self.this_arg);
return ret;
inline void Payer::abandon_payment(struct LDKThirtyTwoBytes payment_id) {
(self.abandon_payment)(self.this_arg, payment_id);
}
-inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer) {
- LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, payment_hash, first_hops, scorer);
+inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs) {
+ LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, payment_hash, first_hops, inflight_htlcs);
return ret;
}
+inline void Router::notify_payment_path_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+ (self.notify_payment_path_failed)(self.this_arg, path, short_channel_id);
+}
+inline void Router::notify_payment_path_successful(struct LDKCVec_RouteHopZ path) {
+ (self.notify_payment_path_successful)(self.this_arg, path);
+}
+inline void Router::notify_payment_probe_successful(struct LDKCVec_RouteHopZ path) {
+ (self.notify_payment_probe_successful)(self.this_arg, path);
+}
+inline void Router::notify_payment_probe_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
+ (self.notify_payment_probe_failed)(self.this_arg, path, short_channel_id);
+}
inline LDK::CResult_NoneLightningErrorZ CustomMessageHandler::handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id) {
LDK::CResult_NoneLightningErrorZ ret = (self.handle_custom_message)(self.this_arg, msg, sender_node_id);
return ret;
LDK::CResult_NoneErrorZ ret = (self.persist_graph)(self.this_arg, network_graph);
return ret;
}
-inline LDK::CResult_NoneErrorZ Persister::persist_scorer(const struct LDKMultiThreadedLockableScore *NONNULL_PTR scorer) {
+inline LDK::CResult_NoneErrorZ Persister::persist_scorer(const struct LDKWriteableScore *NONNULL_PTR scorer) {
LDK::CResult_NoneErrorZ ret = (self.persist_scorer)(self.this_arg, scorer);
return ret;
}
inline void ChannelMessageHandler::handle_error(struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg) {
(self.handle_error)(self.this_arg, their_node_id, msg);
}
+inline LDK::NodeFeatures ChannelMessageHandler::provided_node_features() {
+ LDK::NodeFeatures ret = (self.provided_node_features)(self.this_arg);
+ return ret;
+}
+inline LDK::InitFeatures ChannelMessageHandler::provided_init_features(struct LDKPublicKey their_node_id) {
+ LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id);
+ return ret;
+}
inline LDK::CResult_boolLightningErrorZ RoutingMessageHandler::handle_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg) {
LDK::CResult_boolLightningErrorZ ret = (self.handle_node_announcement)(self.this_arg, msg);
return ret;
LDK::CResult_boolLightningErrorZ ret = (self.handle_channel_update)(self.this_arg, msg);
return ret;
}
-inline LDK::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ RoutingMessageHandler::get_next_channel_announcements(uint64_t starting_point, uint8_t batch_amount) {
- LDK::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
+inline LDK::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ RoutingMessageHandler::get_next_channel_announcement(uint64_t starting_point) {
+ LDK::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
return ret;
}
-inline LDK::CVec_NodeAnnouncementZ RoutingMessageHandler::get_next_node_announcements(struct LDKPublicKey starting_point, uint8_t batch_amount) {
- LDK::CVec_NodeAnnouncementZ ret = (self.get_next_node_announcements)(self.this_arg, starting_point, batch_amount);
+inline LDK::NodeAnnouncement RoutingMessageHandler::get_next_node_announcement(struct LDKPublicKey starting_point) {
+ LDK::NodeAnnouncement ret = (self.get_next_node_announcement)(self.this_arg, starting_point);
return ret;
}
inline void RoutingMessageHandler::peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init) {
LDK::CResult_NoneLightningErrorZ ret = (self.handle_query_short_channel_ids)(self.this_arg, their_node_id, msg);
return ret;
}
+inline LDK::NodeFeatures RoutingMessageHandler::provided_node_features() {
+ LDK::NodeFeatures ret = (self.provided_node_features)(self.this_arg);
+ return ret;
+}
+inline LDK::InitFeatures RoutingMessageHandler::provided_init_features(struct LDKPublicKey their_node_id) {
+ LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id);
+ return ret;
+}
+inline void OnionMessageHandler::handle_onion_message(struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg) {
+ (self.handle_onion_message)(self.this_arg, peer_node_id, msg);
+}
+inline void OnionMessageHandler::peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init) {
+ (self.peer_connected)(self.this_arg, their_node_id, init);
+}
+inline void OnionMessageHandler::peer_disconnected(struct LDKPublicKey their_node_id, bool no_connection_possible) {
+ (self.peer_disconnected)(self.this_arg, their_node_id, no_connection_possible);
+}
+inline LDK::NodeFeatures OnionMessageHandler::provided_node_features() {
+ LDK::NodeFeatures ret = (self.provided_node_features)(self.this_arg);
+ return ret;
+}
+inline LDK::InitFeatures OnionMessageHandler::provided_init_features(struct LDKPublicKey their_node_id) {
+ LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id);
+ return ret;
+}
inline void Logger::log(const struct LDKRecord *NONNULL_PTR record) {
(self.log)(self.this_arg, record);
}
+inline void FutureCallback::call() {
+ (self.call)(self.this_arg);
+}
inline LDK::CResult_NoneChannelMonitorUpdateErrZ Persist::persist_new_channel(struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id) {
LDK::CResult_NoneChannelMonitorUpdateErrZ ret = (self.persist_new_channel)(self.this_arg, channel_id, data, update_id);
return ret;
#[cfg(feature="no-std")]
use alloc::{vec::Vec, boxed::Box};
+#[repr(C)]
+/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size.
+/// This corresponds to std::vector in C++
+pub struct CVec_PublicKeyZ {
+ /// The elements in the array.
+ /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+ pub data: *mut crate::c_types::PublicKey,
+ /// The number of elements pointed to by `data`.
+ pub datalen: usize
+}
+impl CVec_PublicKeyZ {
+ #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::PublicKey> {
+ if self.datalen == 0 { return Vec::new(); }
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
+ self.datalen = 0;
+ ret
+ }
+ #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] {
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
+ }
+}
+impl From<Vec<crate::c_types::PublicKey>> for CVec_PublicKeyZ {
+ fn from(v: Vec<crate::c_types::PublicKey>) -> Self {
+ let datalen = v.len();
+ let data = Box::into_raw(v.into_boxed_slice());
+ Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
+ }
+}
+#[no_mangle]
+/// Frees the buffer pointed to by `data` if `datalen` is non-0.
+pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { }
+impl Drop for CVec_PublicKeyZ {
+ fn drop(&mut self) {
+ if self.datalen == 0 { return; }
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ }
+}
+impl Clone for CVec_PublicKeyZ {
+ fn clone(&self) -> Self {
+ let mut res = Vec::new();
+ if self.datalen == 0 { return Self::from(res); }
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
+ Self::from(res)
+ }
+}
+#[repr(C)]
+/// The contents of CResult_BlindedRouteNoneZ
+pub union CResult_BlindedRouteNoneZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning::onion_message::blinded_route::BlindedRoute,
+ /// Note that this value is always NULL, as there are no contents in the Err variant
+ pub err: *mut core::ffi::c_void,
+}
+#[repr(C)]
+/// A CResult_BlindedRouteNoneZ represents the result of a fallible operation,
+/// containing a crate::lightning::onion_message::blinded_route::BlindedRoute on success and a () on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_BlindedRouteNoneZ {
+ /// The contents of this CResult_BlindedRouteNoneZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_BlindedRouteNoneZPtr,
+ /// Whether this CResult_BlindedRouteNoneZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_BlindedRouteNoneZ in the success state.
+pub extern "C" fn CResult_BlindedRouteNoneZ_ok(o: crate::lightning::onion_message::blinded_route::BlindedRoute) -> CResult_BlindedRouteNoneZ {
+ CResult_BlindedRouteNoneZ {
+ contents: CResult_BlindedRouteNoneZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_BlindedRouteNoneZ in the error state.
+pub extern "C" fn CResult_BlindedRouteNoneZ_err() -> CResult_BlindedRouteNoneZ {
+ CResult_BlindedRouteNoneZ {
+ contents: CResult_BlindedRouteNoneZPtr {
+ err: core::ptr::null_mut(),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_BlindedRouteNoneZ_is_ok(o: &CResult_BlindedRouteNoneZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_BlindedRouteNoneZ.
+pub extern "C" fn CResult_BlindedRouteNoneZ_free(_res: CResult_BlindedRouteNoneZ) { }
+impl Drop for CResult_BlindedRouteNoneZ {
+ 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 {
+ }
+ }
+}
+impl From<crate::c_types::CResultTempl<crate::lightning::onion_message::blinded_route::BlindedRoute, ()>> for CResult_BlindedRouteNoneZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning::onion_message::blinded_route::BlindedRoute, ()>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_BlindedRouteNoneZPtr { result }
+ } else {
+ let _ = unsafe { Box::from_raw(o.contents.err) };
+ o.contents.err = core::ptr::null_mut();
+ CResult_BlindedRouteNoneZPtr { err: core::ptr::null_mut() }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+#[repr(C)]
+/// The contents of CResult_BlindedRouteDecodeErrorZ
+pub union CResult_BlindedRouteDecodeErrorZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning::onion_message::blinded_route::BlindedRoute,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::ln::msgs::DecodeError,
+}
+#[repr(C)]
+/// A CResult_BlindedRouteDecodeErrorZ represents the result of a fallible operation,
+/// containing a crate::lightning::onion_message::blinded_route::BlindedRoute on success and a crate::lightning::ln::msgs::DecodeError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_BlindedRouteDecodeErrorZ {
+ /// The contents of this CResult_BlindedRouteDecodeErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_BlindedRouteDecodeErrorZPtr,
+ /// Whether this CResult_BlindedRouteDecodeErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_BlindedRouteDecodeErrorZ in the success state.
+pub extern "C" fn CResult_BlindedRouteDecodeErrorZ_ok(o: crate::lightning::onion_message::blinded_route::BlindedRoute) -> CResult_BlindedRouteDecodeErrorZ {
+ CResult_BlindedRouteDecodeErrorZ {
+ contents: CResult_BlindedRouteDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_BlindedRouteDecodeErrorZ in the error state.
+pub extern "C" fn CResult_BlindedRouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedRouteDecodeErrorZ {
+ CResult_BlindedRouteDecodeErrorZ {
+ contents: CResult_BlindedRouteDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_BlindedRouteDecodeErrorZ_is_ok(o: &CResult_BlindedRouteDecodeErrorZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_BlindedRouteDecodeErrorZ.
+pub extern "C" fn CResult_BlindedRouteDecodeErrorZ_free(_res: CResult_BlindedRouteDecodeErrorZ) { }
+impl Drop for CResult_BlindedRouteDecodeErrorZ {
+ 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<crate::c_types::CResultTempl<crate::lightning::onion_message::blinded_route::BlindedRoute, crate::lightning::ln::msgs::DecodeError>> for CResult_BlindedRouteDecodeErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning::onion_message::blinded_route::BlindedRoute, crate::lightning::ln::msgs::DecodeError>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_BlindedRouteDecodeErrorZPtr { result }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = core::ptr::null_mut(); }
+ CResult_BlindedRouteDecodeErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+#[repr(C)]
+/// The contents of CResult_BlindedHopDecodeErrorZ
+pub union CResult_BlindedHopDecodeErrorZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning::onion_message::blinded_route::BlindedHop,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::ln::msgs::DecodeError,
+}
+#[repr(C)]
+/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation,
+/// containing a crate::lightning::onion_message::blinded_route::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_BlindedHopDecodeErrorZ {
+ /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_BlindedHopDecodeErrorZPtr,
+ /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state.
+pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::onion_message::blinded_route::BlindedHop) -> CResult_BlindedHopDecodeErrorZ {
+ CResult_BlindedHopDecodeErrorZ {
+ contents: CResult_BlindedHopDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state.
+pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ {
+ CResult_BlindedHopDecodeErrorZ {
+ contents: CResult_BlindedHopDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ.
+pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { }
+impl Drop for CResult_BlindedHopDecodeErrorZ {
+ 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<crate::c_types::CResultTempl<crate::lightning::onion_message::blinded_route::BlindedHop, crate::lightning::ln::msgs::DecodeError>> for CResult_BlindedHopDecodeErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning::onion_message::blinded_route::BlindedHop, crate::lightning::ln::msgs::DecodeError>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_BlindedHopDecodeErrorZPtr { result }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = core::ptr::null_mut(); }
+ CResult_BlindedHopDecodeErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
#[repr(C)]
/// The contents of CResult_NoneNoneZ
pub union CResult_NoneNoneZPtr {
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) }
#[repr(C)]
+/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not
+pub enum COption_WriteableScoreZ {
+ /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore
+ Some(crate::lightning::routing::scoring::WriteableScore),
+ /// When we're in this state, this COption_WriteableScoreZ contains nothing
+ None
+}
+impl COption_WriteableScoreZ {
+ #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
+ if let Self::None = self { false } else { true }
+ }
+ #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+ !self.is_some()
+ }
+ #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore {
+ if let Self::Some(v) = self { v } else { unreachable!() }
+ }
+}
+#[no_mangle]
+/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore
+pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ {
+ COption_WriteableScoreZ::Some(o)
+}
+#[no_mangle]
+/// Constructs a new COption_WriteableScoreZ containing nothing
+pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ {
+ COption_WriteableScoreZ::None
+}
+#[no_mangle]
+/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state
+pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { }
+#[repr(C)]
/// The contents of CResult_NoneErrorZ
pub union CResult_NoneErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) }
#[repr(C)]
-/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size.
-/// This corresponds to std::vector in C++
-pub struct CVec_PublicKeyZ {
- /// The elements in the array.
- /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- pub data: *mut crate::c_types::PublicKey,
- /// The number of elements pointed to by `data`.
- pub datalen: usize
-}
-impl CVec_PublicKeyZ {
- #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::PublicKey> {
- if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = core::ptr::null_mut();
- self.datalen = 0;
- ret
- }
- #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] {
- unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
- }
-}
-impl From<Vec<crate::c_types::PublicKey>> for CVec_PublicKeyZ {
- fn from(v: Vec<crate::c_types::PublicKey>) -> Self {
- let datalen = v.len();
- let data = Box::into_raw(v.into_boxed_slice());
- Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
- }
-}
-#[no_mangle]
-/// Frees the buffer pointed to by `data` if `datalen` is non-0.
-pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { }
-impl Drop for CVec_PublicKeyZ {
- fn drop(&mut self) {
- if self.datalen == 0 { return; }
- unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
- }
-}
-impl Clone for CVec_PublicKeyZ {
- fn clone(&self) -> Self {
- let mut res = Vec::new();
- if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
- Self::from(res)
- }
-}
-#[repr(C)]
/// The contents of CResult_PaymentPurposeDecodeErrorZ
pub union CResult_PaymentPurposeDecodeErrorZPtr {
/// A pointer to the contents in the success state.
}
}
#[repr(C)]
-#[derive(Clone)]
-/// An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not
-pub enum COption_C2Tuple_usizeTransactionZZ {
- /// When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ
- Some(crate::c_types::derived::C2Tuple_usizeTransactionZ),
- /// When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing
- None
-}
-impl COption_C2Tuple_usizeTransactionZZ {
- #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
- if let Self::None = self { false } else { true }
- }
- #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
- !self.is_some()
- }
- #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_usizeTransactionZ {
- if let Self::Some(v) = self { v } else { unreachable!() }
- }
-}
-#[no_mangle]
-/// Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ
-pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_some(o: crate::c_types::derived::C2Tuple_usizeTransactionZ) -> COption_C2Tuple_usizeTransactionZZ {
- COption_C2Tuple_usizeTransactionZZ::Some(o)
-}
-#[no_mangle]
-/// Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing
-pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_none() -> COption_C2Tuple_usizeTransactionZZ {
- COption_C2Tuple_usizeTransactionZZ::None
-}
-#[no_mangle]
-/// Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state
-pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_free(_res: COption_C2Tuple_usizeTransactionZZ) { }
-#[no_mangle]
-/// Creates a new COption_C2Tuple_usizeTransactionZZ which has the same data as `orig`
-/// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_clone(orig: &COption_C2Tuple_usizeTransactionZZ) -> COption_C2Tuple_usizeTransactionZZ { Clone::clone(&orig) }
-#[repr(C)]
/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ
pub union CResult_FixedPenaltyScorerDecodeErrorZPtr {
/// A pointer to the contents in the success state.
/// Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ.
pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) { }
#[repr(C)]
-/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size.
-/// This corresponds to std::vector in C++
-pub struct CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- /// The elements in the array.
- /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- pub data: *mut crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ,
- /// The number of elements pointed to by `data`.
- pub datalen: usize
-}
-impl CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ> {
- if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = core::ptr::null_mut();
- self.datalen = 0;
- ret
- }
- #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] {
- unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
- }
-}
-impl From<Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ>> for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- fn from(v: Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ>) -> Self {
- let datalen = v.len();
- let data = Box::into_raw(v.into_boxed_slice());
- Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
- }
-}
-#[no_mangle]
-/// Frees the buffer pointed to by `data` if `datalen` is non-0.
-pub extern "C" fn CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { }
-impl Drop for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- fn drop(&mut self) {
- if self.datalen == 0 { return; }
- unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
- }
-}
-impl Clone for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- fn clone(&self) -> Self {
- let mut res = Vec::new();
- if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
- Self::from(res)
- }
-}
-#[repr(C)]
-/// A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size.
-/// This corresponds to std::vector in C++
-pub struct CVec_NodeAnnouncementZ {
- /// The elements in the array.
- /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
- pub data: *mut crate::lightning::ln::msgs::NodeAnnouncement,
- /// The number of elements pointed to by `data`.
- pub datalen: usize
+#[derive(Clone)]
+/// An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not
+pub enum COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ /// When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ
+ Some(crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ),
+ /// When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing
+ None
}
-impl CVec_NodeAnnouncementZ {
- #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::NodeAnnouncement> {
- if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = core::ptr::null_mut();
- self.datalen = 0;
- ret
+impl COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
+ if let Self::None = self { false } else { true }
}
- #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::NodeAnnouncement] {
- unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
+ #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+ !self.is_some()
}
-}
-impl From<Vec<crate::lightning::ln::msgs::NodeAnnouncement>> for CVec_NodeAnnouncementZ {
- fn from(v: Vec<crate::lightning::ln::msgs::NodeAnnouncement>) -> Self {
- let datalen = v.len();
- let data = Box::into_raw(v.into_boxed_slice());
- Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
+ #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
+ if let Self::Some(v) = self { v } else { unreachable!() }
}
}
#[no_mangle]
-/// Frees the buffer pointed to by `data` if `datalen` is non-0.
-pub extern "C" fn CVec_NodeAnnouncementZ_free(_res: CVec_NodeAnnouncementZ) { }
-impl Drop for CVec_NodeAnnouncementZ {
- fn drop(&mut self) {
- if self.datalen == 0 { return; }
- unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
- }
-}
-impl Clone for CVec_NodeAnnouncementZ {
- fn clone(&self) -> Self {
- let mut res = Vec::new();
- if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
- Self::from(res)
- }
+/// Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ
+pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o: crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some(o)
}
+#[no_mangle]
+/// Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing
+pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none() -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None
+}
+#[no_mangle]
+/// Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state
+pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { }
+#[no_mangle]
+/// Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig: &COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { Clone::clone(&orig) }
#[repr(C)]
/// The contents of CResult_NoneLightningErrorZ
pub union CResult_NoneLightningErrorZPtr {
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_SecretKeyNoneZ_clone(orig: &CResult_SecretKeyNoneZ) -> CResult_SecretKeyNoneZ { Clone::clone(&orig) }
#[repr(C)]
+/// An enum which can either contain a crate::c_types::BigEndianScalar or not
+pub enum COption_ScalarZ {
+ /// When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar
+ Some(crate::c_types::BigEndianScalar),
+ /// When we're in this state, this COption_ScalarZ contains nothing
+ None
+}
+impl COption_ScalarZ {
+ #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
+ if let Self::None = self { false } else { true }
+ }
+ #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+ !self.is_some()
+ }
+ #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar {
+ if let Self::Some(v) = self { v } else { unreachable!() }
+ }
+}
+#[no_mangle]
+/// Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar
+pub extern "C" fn COption_ScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_ScalarZ {
+ COption_ScalarZ::Some(o)
+}
+#[no_mangle]
+/// Constructs a new COption_ScalarZ containing nothing
+pub extern "C" fn COption_ScalarZ_none() -> COption_ScalarZ {
+ COption_ScalarZ::None
+}
+#[no_mangle]
+/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state
+pub extern "C" fn COption_ScalarZ_free(_res: COption_ScalarZ) { }
+#[repr(C)]
+/// The contents of CResult_SharedSecretNoneZ
+pub union CResult_SharedSecretNoneZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::c_types::ThirtyTwoBytes,
+ /// Note that this value is always NULL, as there are no contents in the Err variant
+ pub err: *mut core::ffi::c_void,
+}
+#[repr(C)]
+/// A CResult_SharedSecretNoneZ represents the result of a fallible operation,
+/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_SharedSecretNoneZ {
+ /// The contents of this CResult_SharedSecretNoneZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_SharedSecretNoneZPtr,
+ /// Whether this CResult_SharedSecretNoneZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_SharedSecretNoneZ in the success state.
+pub extern "C" fn CResult_SharedSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_SharedSecretNoneZ {
+ CResult_SharedSecretNoneZ {
+ contents: CResult_SharedSecretNoneZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_SharedSecretNoneZ in the error state.
+pub extern "C" fn CResult_SharedSecretNoneZ_err() -> CResult_SharedSecretNoneZ {
+ CResult_SharedSecretNoneZ {
+ contents: CResult_SharedSecretNoneZPtr {
+ err: core::ptr::null_mut(),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_SharedSecretNoneZ_is_ok(o: &CResult_SharedSecretNoneZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_SharedSecretNoneZ.
+pub extern "C" fn CResult_SharedSecretNoneZ_free(_res: CResult_SharedSecretNoneZ) { }
+impl Drop for CResult_SharedSecretNoneZ {
+ 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 {
+ }
+ }
+}
+impl From<crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, ()>> for CResult_SharedSecretNoneZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, ()>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_SharedSecretNoneZPtr { result }
+ } else {
+ let _ = unsafe { Box::from_raw(o.contents.err) };
+ o.contents.err = core::ptr::null_mut();
+ CResult_SharedSecretNoneZPtr { err: core::ptr::null_mut() }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+impl Clone for CResult_SharedSecretNoneZ {
+ fn clone(&self) -> Self {
+ if self.result_ok {
+ Self { result_ok: true, contents: CResult_SharedSecretNoneZPtr {
+ result: Box::into_raw(Box::new(<crate::c_types::ThirtyTwoBytes>::clone(unsafe { &*self.contents.result })))
+ } }
+ } else {
+ Self { result_ok: false, contents: CResult_SharedSecretNoneZPtr {
+ err: core::ptr::null_mut()
+ } }
+ }
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_SharedSecretNoneZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_SharedSecretNoneZ_clone(orig: &CResult_SharedSecretNoneZ) -> CResult_SharedSecretNoneZ { Clone::clone(&orig) }
+#[repr(C)]
/// The contents of CResult_SignDecodeErrorZ
pub union CResult_SignDecodeErrorZPtr {
/// A pointer to the contents in the success state.
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_PaymentIdPaymentErrorZ_clone(orig: &CResult_PaymentIdPaymentErrorZ) -> CResult_PaymentIdPaymentErrorZ { Clone::clone(&orig) }
#[repr(C)]
+/// The contents of CResult_InFlightHtlcsDecodeErrorZ
+pub union CResult_InFlightHtlcsDecodeErrorZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning_invoice::payment::InFlightHtlcs,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::ln::msgs::DecodeError,
+}
+#[repr(C)]
+/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation,
+/// containing a crate::lightning_invoice::payment::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_InFlightHtlcsDecodeErrorZ {
+ /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_InFlightHtlcsDecodeErrorZPtr,
+ /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state.
+pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning_invoice::payment::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ {
+ CResult_InFlightHtlcsDecodeErrorZ {
+ contents: CResult_InFlightHtlcsDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state.
+pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ {
+ CResult_InFlightHtlcsDecodeErrorZ {
+ contents: CResult_InFlightHtlcsDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ.
+pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { }
+impl Drop for CResult_InFlightHtlcsDecodeErrorZ {
+ 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<crate::c_types::CResultTempl<crate::lightning_invoice::payment::InFlightHtlcs, crate::lightning::ln::msgs::DecodeError>> for CResult_InFlightHtlcsDecodeErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::payment::InFlightHtlcs, crate::lightning::ln::msgs::DecodeError>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_InFlightHtlcsDecodeErrorZPtr { result }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = core::ptr::null_mut(); }
+ CResult_InFlightHtlcsDecodeErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+#[repr(C)]
/// The contents of CResult_SiPrefixParseErrorZ
pub union CResult_SiPrefixParseErrorZPtr {
/// A pointer to the contents in the success state.
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) }
#[repr(C)]
+/// The contents of CResult_NoneSendErrorZ
+pub union CResult_NoneSendErrorZPtr {
+ /// Note that this value is always NULL, as there are no contents in the OK variant
+ pub result: *mut core::ffi::c_void,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::onion_message::messenger::SendError,
+}
+#[repr(C)]
+/// A CResult_NoneSendErrorZ represents the result of a fallible operation,
+/// containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_NoneSendErrorZ {
+ /// The contents of this CResult_NoneSendErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_NoneSendErrorZPtr,
+ /// Whether this CResult_NoneSendErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_NoneSendErrorZ in the success state.
+pub extern "C" fn CResult_NoneSendErrorZ_ok() -> CResult_NoneSendErrorZ {
+ CResult_NoneSendErrorZ {
+ contents: CResult_NoneSendErrorZPtr {
+ result: core::ptr::null_mut(),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_NoneSendErrorZ in the error state.
+pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_NoneSendErrorZ {
+ CResult_NoneSendErrorZ {
+ contents: CResult_NoneSendErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_NoneSendErrorZ.
+pub extern "C" fn CResult_NoneSendErrorZ_free(_res: CResult_NoneSendErrorZ) { }
+impl Drop for CResult_NoneSendErrorZ {
+ fn drop(&mut self) {
+ if self.result_ok {
+ } else {
+ if unsafe { !(self.contents.err as *mut ()).is_null() } {
+ let _ = unsafe { Box::from_raw(self.contents.err) };
+ }
+ }
+ }
+}
+impl From<crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>> for CResult_NoneSendErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self {
+ let contents = if o.result_ok {
+ let _ = unsafe { Box::from_raw(o.contents.result) };
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = core::ptr::null_mut(); }
+ CResult_NoneSendErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+#[repr(C)]
/// The contents of CResult_u32GraphSyncErrorZ
pub union CResult_u32GraphSyncErrorZPtr {
/// A pointer to the contents in the success state.
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) }
#[repr(C)]
+/// The contents of CResult_OnionMessageDecodeErrorZ
+pub union CResult_OnionMessageDecodeErrorZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning::ln::msgs::OnionMessage,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::ln::msgs::DecodeError,
+}
+#[repr(C)]
+/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation,
+/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_OnionMessageDecodeErrorZ {
+ /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_OnionMessageDecodeErrorZPtr,
+ /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state.
+pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ {
+ CResult_OnionMessageDecodeErrorZ {
+ contents: CResult_OnionMessageDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state.
+pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ {
+ CResult_OnionMessageDecodeErrorZ {
+ contents: CResult_OnionMessageDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ.
+pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { }
+impl Drop for CResult_OnionMessageDecodeErrorZ {
+ 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<crate::c_types::CResultTempl<crate::lightning::ln::msgs::OnionMessage, crate::lightning::ln::msgs::DecodeError>> for CResult_OnionMessageDecodeErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::OnionMessage, crate::lightning::ln::msgs::DecodeError>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_OnionMessageDecodeErrorZPtr { result }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = core::ptr::null_mut(); }
+ CResult_OnionMessageDecodeErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+impl Clone for CResult_OnionMessageDecodeErrorZ {
+ fn clone(&self) -> Self {
+ if self.result_ok {
+ Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(<crate::lightning::ln::msgs::OnionMessage>::clone(unsafe { &*self.contents.result })))
+ } }
+ } else {
+ Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
+ } }
+ }
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) }
+#[repr(C)]
/// The contents of CResult_PingDecodeErrorZ
pub union CResult_PingDecodeErrorZPtr {
/// A pointer to the contents in the success state.
}
#[must_use]
-extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint, mut monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ {
- let mut ret = <nativeChainMonitor as lightning::chain::Watch<_>>::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_outpoint.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) });
+extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ {
+ let mut ret = <nativeChainMonitor as lightning::chain::Watch<_>>::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::chain::ChannelMonitorUpdateErr::native_into(e) }).into() };
local_ret
}
use lightning::chain::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
pub(crate) type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
-/// An update generated by the underlying Channel itself which contains some new information the
-/// ChannelMonitor should be made aware of.
+/// An update generated by the underlying channel itself which contains some new information the
+/// [`ChannelMonitor`] should be made aware of.
+///
+/// Because this represents only a small number of updates to the underlying state, it is generally
+/// much smaller than a full [`ChannelMonitor`]. However, for large single commitment transaction
+/// updates (e.g. ones during which there are hundreds of HTLCs pending on the commitment
+/// transaction), a single update may reach upwards of 1 MiB in serialized size.
#[must_use]
#[repr(C)]
pub struct ChannelMonitorUpdate {
/// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
/// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
/// likely to be claimed by our counterparty before we do.
- MaybeClaimableHTLCAwaitingTimeout {
- /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
- /// required to do so.
+ MaybeTimeoutClaimableHTLC {
+ /// The amount potentially available to claim, in satoshis, excluding the on-chain fees
+ /// which will be required to do so.
claimable_amount_satoshis: u64,
/// The height at which we will be able to claim the balance if our counterparty has not
/// done so.
claimable_height: u32,
},
+ /// HTLCs which we received from our counterparty which are claimable with a preimage which we
+ /// do not currently have. This will only be claimable if we receive the preimage from the node
+ /// to which we forwarded this HTLC before the timeout.
+ MaybePreimageClaimableHTLC {
+ /// The amount potentially available to claim, in satoshis, excluding the on-chain fees
+ /// which will be required to do so.
+ claimable_amount_satoshis: u64,
+ /// The height at which our counterparty will be able to claim the balance if we have not
+ /// yet received the preimage and claimed it ourselves.
+ expiry_height: u32,
+ },
+ /// The channel has been closed, and our counterparty broadcasted a revoked commitment
+ /// transaction.
+ ///
+ /// Thus, we're able to claim all outputs in the commitment transaction, one of which has the
+ /// following amount.
+ CounterpartyRevokedOutputClaimable {
+ /// The amount, in satoshis, of the output which we can claim.
+ ///
+ /// Note that for outputs from HTLC balances this may be excluding some on-chain fees that
+ /// were already spent.
+ claimable_amount_satoshis: u64,
+ },
}
use lightning::chain::channelmonitor::Balance as BalanceImport;
pub(crate) type nativeBalance = BalanceImport;
timeout_height: timeout_height_nonref,
}
},
- Balance::MaybeClaimableHTLCAwaitingTimeout {ref claimable_amount_satoshis, ref claimable_height, } => {
+ Balance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, } => {
let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
let mut claimable_height_nonref = (*claimable_height).clone();
- nativeBalance::MaybeClaimableHTLCAwaitingTimeout {
+ nativeBalance::MaybeTimeoutClaimableHTLC {
claimable_amount_satoshis: claimable_amount_satoshis_nonref,
claimable_height: claimable_height_nonref,
}
},
+ Balance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, } => {
+ let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+ let mut expiry_height_nonref = (*expiry_height).clone();
+ nativeBalance::MaybePreimageClaimableHTLC {
+ claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+ expiry_height: expiry_height_nonref,
+ }
+ },
+ Balance::CounterpartyRevokedOutputClaimable {ref claimable_amount_satoshis, } => {
+ let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+ nativeBalance::CounterpartyRevokedOutputClaimable {
+ claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+ }
+ },
}
}
#[allow(unused)]
timeout_height: timeout_height,
}
},
- Balance::MaybeClaimableHTLCAwaitingTimeout {mut claimable_amount_satoshis, mut claimable_height, } => {
- nativeBalance::MaybeClaimableHTLCAwaitingTimeout {
+ Balance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, } => {
+ nativeBalance::MaybeTimeoutClaimableHTLC {
claimable_amount_satoshis: claimable_amount_satoshis,
claimable_height: claimable_height,
}
},
+ Balance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, } => {
+ nativeBalance::MaybePreimageClaimableHTLC {
+ claimable_amount_satoshis: claimable_amount_satoshis,
+ expiry_height: expiry_height,
+ }
+ },
+ Balance::CounterpartyRevokedOutputClaimable {mut claimable_amount_satoshis, } => {
+ nativeBalance::CounterpartyRevokedOutputClaimable {
+ claimable_amount_satoshis: claimable_amount_satoshis,
+ }
+ },
}
}
#[allow(unused)]
timeout_height: timeout_height_nonref,
}
},
- nativeBalance::MaybeClaimableHTLCAwaitingTimeout {ref claimable_amount_satoshis, ref claimable_height, } => {
+ nativeBalance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, } => {
let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
let mut claimable_height_nonref = (*claimable_height).clone();
- Balance::MaybeClaimableHTLCAwaitingTimeout {
+ Balance::MaybeTimeoutClaimableHTLC {
claimable_amount_satoshis: claimable_amount_satoshis_nonref,
claimable_height: claimable_height_nonref,
}
},
+ nativeBalance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, } => {
+ let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+ let mut expiry_height_nonref = (*expiry_height).clone();
+ Balance::MaybePreimageClaimableHTLC {
+ claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+ expiry_height: expiry_height_nonref,
+ }
+ },
+ nativeBalance::CounterpartyRevokedOutputClaimable {ref claimable_amount_satoshis, } => {
+ let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+ Balance::CounterpartyRevokedOutputClaimable {
+ claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+ }
+ },
}
}
#[allow(unused)]
timeout_height: timeout_height,
}
},
- nativeBalance::MaybeClaimableHTLCAwaitingTimeout {mut claimable_amount_satoshis, mut claimable_height, } => {
- Balance::MaybeClaimableHTLCAwaitingTimeout {
+ nativeBalance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, } => {
+ Balance::MaybeTimeoutClaimableHTLC {
claimable_amount_satoshis: claimable_amount_satoshis,
claimable_height: claimable_height,
}
},
+ nativeBalance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, } => {
+ Balance::MaybePreimageClaimableHTLC {
+ claimable_amount_satoshis: claimable_amount_satoshis,
+ expiry_height: expiry_height,
+ }
+ },
+ nativeBalance::CounterpartyRevokedOutputClaimable {mut claimable_amount_satoshis, } => {
+ Balance::CounterpartyRevokedOutputClaimable {
+ claimable_amount_satoshis: claimable_amount_satoshis,
+ }
+ },
}
}
}
}
}
#[no_mangle]
-/// Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
-pub extern "C" fn Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis: u64, claimable_height: u32) -> Balance {
- Balance::MaybeClaimableHTLCAwaitingTimeout {
+/// Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance
+pub extern "C" fn Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis: u64, claimable_height: u32) -> Balance {
+ Balance::MaybeTimeoutClaimableHTLC {
claimable_amount_satoshis,
claimable_height,
}
}
+#[no_mangle]
+/// Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance
+pub extern "C" fn Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis: u64, expiry_height: u32) -> Balance {
+ Balance::MaybePreimageClaimableHTLC {
+ claimable_amount_satoshis,
+ expiry_height,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance
+pub extern "C" fn Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis: u64) -> Balance {
+ Balance::CounterpartyRevokedOutputClaimable {
+ claimable_amount_satoshis,
+ }
+}
/// Checks if two Balances contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
#[no_mangle]
/// balance, or until our counterparty has claimed the balance and accrued several
/// confirmations on the claim transaction.
///
-/// Note that the balances available when you or your counterparty have broadcasted revoked
-/// state(s) may not be fully captured here.
+/// Note that for `ChannelMonitors` which track a channel which went on-chain with versions of
+/// LDK prior to 0.0.111, balances may not be fully captured if our counterparty broadcasted
+/// a revoked state.
///
/// See [`Balance`] for additional details on the types of claimable balances which
/// may be returned here and their meanings.
/// parameter.
#[must_use]
pub get_node_secret: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_SecretKeyNoneZ,
+ /// Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if
+ /// one is provided. Note that this tweak can be applied to `other_key` instead of our node
+ /// secret, though this is less efficient.
+ ///
+ /// [`node secret`]: Self::get_node_secret
+ #[must_use]
+ pub ecdh: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient, other_key: crate::c_types::PublicKey, tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ,
/// Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
///
/// This method should return a different value each time it is called, to avoid linking
KeysInterface {
this_arg: orig.this_arg,
get_node_secret: Clone::clone(&orig.get_node_secret),
+ ecdh: Clone::clone(&orig.ecdh),
get_destination_script: Clone::clone(&orig.get_destination_script),
get_shutdown_scriptpubkey: Clone::clone(&orig.get_shutdown_scriptpubkey),
get_channel_signer: Clone::clone(&orig.get_channel_signer),
let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
local_ret
}
+ fn ecdh(&self, mut recipient: lightning::chain::keysinterface::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result<bitcoin::secp256k1::ecdh::SharedSecret, ()> {
+ let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_ScalarZ::None } else { crate::c_types::derived::COption_ScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(tweak.clone().unwrap()) }) };
+ let mut ret = (self.ecdh)(self.this_arg, crate::lightning::chain::keysinterface::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak);
+ let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
+ local_ret
+ }
fn get_destination_script(&self) -> bitcoin::blockdata::script::Script {
let mut ret = (self.get_destination_script)(self.this_arg);
::bitcoin::blockdata::script::Script::from(ret.into_rust())
crate::c_types::ThirtyTwoBytes { data: ret }
}
#[must_use]
-extern "C" fn InMemorySigner_BaseSign_validate_holder_commitment(this_arg: *const c_void, _holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut _preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ {
- let mut local__preimages = Vec::new(); for mut item in _preimages.into_rust().drain(..) { local__preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); };
- let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, _holder_tx.get_native_ref(), local__preimages);
+extern "C" fn InMemorySigner_BaseSign_validate_holder_commitment(this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ {
+ let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); };
+ let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_preimages);
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
local_ret
}
crate::c_types::ThirtyTwoBytes { data: ret }
}
#[must_use]
-extern "C" fn InMemorySigner_BaseSign_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut _preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
- let mut local__preimages = Vec::new(); for mut item in _preimages.into_rust().drain(..) { local__preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); };
- let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local__preimages, secp256k1::global::SECP256K1);
+extern "C" fn InMemorySigner_BaseSign_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+ let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); };
+ let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_preimages, secp256k1::global::SECP256K1);
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
local_ret
}
#[must_use]
-extern "C" fn InMemorySigner_BaseSign_validate_counterparty_revocation(this_arg: *const c_void, mut _idx: u64, _secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ {
- let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, _idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *_secret}[..]).unwrap());
+extern "C" fn InMemorySigner_BaseSign_validate_counterparty_revocation(this_arg: *const c_void, mut idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ {
+ let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
local_ret
}
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
get_node_secret: KeysManager_KeysInterface_get_node_secret,
+ ecdh: KeysManager_KeysInterface_ecdh,
get_destination_script: KeysManager_KeysInterface_get_destination_script,
get_shutdown_scriptpubkey: KeysManager_KeysInterface_get_shutdown_scriptpubkey,
get_channel_signer: KeysManager_KeysInterface_get_channel_signer,
local_ret
}
#[must_use]
+extern "C" fn KeysManager_KeysInterface_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ {
+ let mut local_tweak_base = { /* tweak*/ let tweak_opt = tweak; { } if tweak_opt.is_none() { None } else { Some({ tweak_opt.take().into_rust() }) } }; let mut local_tweak = local_tweak_base.as_ref();
+ let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
+ local_ret
+}
+#[must_use]
extern "C" fn KeysManager_KeysInterface_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z {
let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, );
ret.into_bytes().into()
crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
#[must_use]
-extern "C" fn KeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign {
- let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::get_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, _inbound, channel_value_satoshis);
+extern "C" fn KeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign {
+ let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::get_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis);
Into::into(ret)
}
#[must_use]
local_ret
}
#[must_use]
-extern "C" fn KeysManager_KeysInterface_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_u5Z, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ {
+extern "C" fn KeysManager_KeysInterface_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_u5Z, mut receipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ {
let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); };
- let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native());
+ let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], receipient.into_native());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
local_ret
}
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
get_node_secret: PhantomKeysManager_KeysInterface_get_node_secret,
+ ecdh: PhantomKeysManager_KeysInterface_ecdh,
get_destination_script: PhantomKeysManager_KeysInterface_get_destination_script,
get_shutdown_scriptpubkey: PhantomKeysManager_KeysInterface_get_shutdown_scriptpubkey,
get_channel_signer: PhantomKeysManager_KeysInterface_get_channel_signer,
local_ret
}
#[must_use]
+extern "C" fn PhantomKeysManager_KeysInterface_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ {
+ let mut local_tweak_base = { /* tweak*/ let tweak_opt = tweak; { } if tweak_opt.is_none() { None } else { Some({ tweak_opt.take().into_rust() }) } }; let mut local_tweak = local_tweak_base.as_ref();
+ let mut ret = <nativePhantomKeysManager as lightning::chain::keysinterface::KeysInterface<>>::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
+ local_ret
+}
+#[must_use]
extern "C" fn PhantomKeysManager_KeysInterface_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z {
let mut ret = <nativePhantomKeysManager as lightning::chain::keysinterface::KeysInterface<>>::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, );
ret.into_bytes().into()
local_ret
}
#[must_use]
-extern "C" fn PhantomKeysManager_KeysInterface_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_u5Z, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ {
+extern "C" fn PhantomKeysManager_KeysInterface_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_u5Z, mut receipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ {
let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); };
- let mut ret = <nativePhantomKeysManager as lightning::chain::keysinterface::KeysInterface<>>::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native());
+ let mut ret = <nativePhantomKeysManager as lightning::chain::keysinterface::KeysInterface<>>::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], receipient.into_native());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
local_ret
}
/// in the event of a chain reorganization, it must not be called with a `header` that is no
/// longer in the chain as of the last call to [`best_block_updated`].
///
- /// [chain order]: Confirm#Order
+ /// [chain order]: Confirm#order
/// [`best_block_updated`]: Self::best_block_updated
pub transactions_confirmed: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, height: u32),
/// Processes a transaction that is no longer confirmed as result of a chain reorganization.
///
/// Should be called for any transaction returned by [`get_relevant_txids`] if it has been
- /// reorganized out of the best chain. Once called, the given transaction should not be returned
- /// by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`].
+ /// reorganized out of the best chain. Once called, the given transaction will not be returned
+ /// by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`].
///
/// [`get_relevant_txids`]: Self::get_relevant_txids
/// [`transactions_confirmed`]: Self::transactions_confirmed
pub best_block_updated: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32),
/// Returns transactions that should be monitored for reorganization out of the chain.
///
- /// Should include any transactions passed to [`transactions_confirmed`] that have insufficient
- /// confirmations to be safe from a chain reorganization. Should not include any transactions
- /// passed to [`transaction_unconfirmed`] unless later reconfirmed.
+ /// Will include any transactions passed to [`transactions_confirmed`] that have insufficient
+ /// confirmations to be safe from a chain reorganization. Will not include any transactions
+ /// passed to [`transaction_unconfirmed`], unless later reconfirmed.
///
/// May be called to determine the subset of transactions that must still be monitored for
/// reorganization. Will be idempotent between calls but may change as a result of calls to the
pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice),
/// Registers interest in spends of a transaction output.
///
- /// Optionally, when `output.block_hash` is set, should return any transaction spending the
- /// output that is found in the corresponding block along with its index.
- ///
- /// This return value is useful for Electrum clients in order to supply in-block descendant
- /// transactions which otherwise were not included. This is not necessary for other clients if
- /// such descendant transactions were already included (e.g., when a BIP 157 client provides the
- /// full block).
- #[must_use]
- pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::lightning::chain::WatchedOutput) -> crate::c_types::derived::COption_C2Tuple_usizeTransactionZZ,
+ /// Note that this method might be called during processing of a new block. You therefore need
+ /// to ensure that also dependent output spents within an already connected block are correctly
+ /// handled, e.g., by re-scanning the block in question whenever new outputs have been
+ /// registered mid-processing.
+ pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::lightning::chain::WatchedOutput),
/// 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<extern "C" fn(this_arg: *mut c_void)>,
fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::blockdata::script::Script) {
(self.register_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pubkey[..]))
}
- fn register_output(&self, mut output: lightning::chain::WatchedOutput) -> Option<(usize, bitcoin::blockdata::transaction::Transaction)> {
- let mut ret = (self.register_output)(self.this_arg, crate::lightning::chain::WatchedOutput { inner: ObjOps::heap_alloc(output), is_owned: true });
- let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_bitcoin()); local_ret_0 }) } else { None };
- local_ret
+ fn register_output(&self, mut output: lightning::chain::WatchedOutput) {
+ (self.register_output)(self.this_arg, crate::lightning::chain::WatchedOutput { inner: ObjOps::heap_alloc(output), is_owned: true })
}
}
///
/// Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
/// spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
-/// the return value of [`Filter::register_output`].
+/// [`Confirm::transactions_confirmed`].
///
/// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
/// may have been spent there. See [`Filter::register_output`] for details.
crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
-/// Gets the current configuration applied to all new channels, as
+/// Gets the current configuration applied to all new channels.
#[must_use]
#[no_mangle]
pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::config::UserConfig {
local_ret
}
-/// Regenerates channel_announcements and generates a signed node_announcement from the given
-/// arguments, providing them in corresponding events via
-/// [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
-/// on-chain. This effectively re-broadcasts all channel announcements and sends our node
-/// announcement to ensure that the lightning P2P network is aware of the channels we have and
-/// our network addresses.
-///
-/// `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
-/// node to humans. They carry no in-protocol meaning.
-///
-/// `addresses` represent the set (possibly empty) of socket addresses on which this node
-/// accepts incoming connections. These will be included in the node_announcement, publicly
-/// tying these addresses together and to this node. If you wish to preserve user privacy,
-/// addresses should likely contain only Tor Onion addresses.
-///
-/// Panics if `addresses` is absurdly large (more than 100).
-///
-/// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
-#[no_mangle]
-pub extern "C" fn ChannelManager_broadcast_node_announcement(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut rgb: crate::c_types::ThreeBytes, mut alias: crate::c_types::ThirtyTwoBytes, mut addresses: crate::c_types::derived::CVec_NetAddressZ) {
- let mut local_addresses = Vec::new(); for mut item in addresses.into_rust().drain(..) { local_addresses.push( { item.into_native() }); };
- unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.broadcast_node_announcement(rgb.data, alias.data, local_addresses)
-}
-
/// Atomically updates the [`ChannelConfig`] for the given channels.
///
/// Once the updates are applied, each eligible channel (advertised with a known short channel
unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update()
}
+/// Gets a [`Future`] that completes when a persistable update is available. Note that
+/// callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
+/// should instead register actions to be taken later.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_get_persistable_update_future(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::wakers::Future {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_persistable_update_future();
+ crate::lightning::util::wakers::Future { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
/// Gets the latest best block which was connected either via the [`chain::Listen`] or
/// [`chain::Confirm`] interfaces.
#[must_use]
handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update,
handle_error: ChannelManager_ChannelMessageHandler_handle_error,
+ provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features,
+ provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features,
MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
}
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_ready(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_ready(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), their_features.get_native_ref(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), their_features.get_native_ref(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), no_connection_possible)
+extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), no_connection_possible)
}
-extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), init_msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) {
- <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref())
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) {
+ <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
+}
+#[must_use]
+extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+#[must_use]
+extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust());
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
#[no_mangle]
//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information).
//! - `BasicMPP` - requires/supports that a node can receive basic multi-part payments
//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#basic-multi-part-payments) for more information).
+//! - `Wumbo` - requires/supports that a node create large channels. Called `option_support_large_channel` in the spec.
+//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information).
//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown`
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
+//! - `OnionMessages` - requires/supports forwarding onion messages
+//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information).
+//! TODO: update link
//! - `ChannelType` - node supports the channel_type field in open/accept
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
//! - `SCIDPrivacy` - supply channel aliases for routing
ret
}
+/// Set this feature as optional.
+#[no_mangle]
+pub extern "C" fn InitFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) {
+ unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_onion_messages_optional()
+}
+
+/// Set this feature as required.
+#[no_mangle]
+pub extern "C" fn InitFeatures_set_onion_messages_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) {
+ unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_onion_messages_required()
+}
+
+/// Checks if this feature is supported.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InitFeatures_supports_onion_messages(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages();
+ ret
+}
+
+/// Set this feature as optional.
+#[no_mangle]
+pub extern "C" fn NodeFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) {
+ unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_onion_messages_optional()
+}
+
+/// Set this feature as required.
+#[no_mangle]
+pub extern "C" fn NodeFeatures_set_onion_messages_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) {
+ unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_onion_messages_required()
+}
+
+/// Checks if this feature is supported.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeFeatures_supports_onion_messages(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages();
+ ret
+}
+
+/// Checks if this feature is required.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InitFeatures_requires_onion_messages(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages();
+ ret
+}
+
+/// Checks if this feature is required.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeFeatures_requires_onion_messages(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages();
+ ret
+}
+
/// Set this feature as optional.
#[no_mangle]
pub extern "C" fn InitFeatures_set_channel_type_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) {
ret
}
}
+/// Returns the set of known init features that are related to channels. At least some of
+/// these features are likely required for peers to talk to us.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InitFeatures_known_channel_features() -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = lightning::ln::features::InitFeatures::known_channel_features();
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// Returns the set of known node features that are related to channels.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeFeatures_known_channel_features() -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = lightning::ln::features::NodeFeatures::known_channel_features();
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
/// Create a blank Features with no features set
#[must_use]
#[no_mangle]
orig.clone()
}
+use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
+pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
+
+/// An onion message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct OnionMessage {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeOnionMessage,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 OnionMessage {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOnionMessage); }
+}
+#[allow(unused)]
+impl OnionMessage {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Used in decrypting the onion packet's payload.
+#[no_mangle]
+pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
+ crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// Used in decrypting the onion packet's payload.
+#[no_mangle]
+pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
+}
+impl Clone for OnionMessage {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(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 OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the OnionMessage
+pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
+ orig.clone()
+}
+
use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate),
/// Handle an incoming error message from the given peer.
pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
+ /// Gets the node feature flags which this handler itself supports. All available handlers are
+ /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ /// which are broadcasted in our [`NodeAnnouncement`] message.
+ #[must_use]
+ pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
+ /// Gets the init feature flags which should be sent to the given peer. All available handlers
+ /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ /// which are sent in our [`Init`] message.
+ ///
+ /// Note that this method is called before [`Self::peer_connected`].
+ #[must_use]
+ pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
/// Implementation of MessageSendEventsProvider for this object.
pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
/// Frees any resources associated with this object given its this_arg pointer.
handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
handle_channel_update: Clone::clone(&orig.handle_channel_update),
handle_error: Clone::clone(&orig.handle_error),
+ provided_node_features: Clone::clone(&orig.provided_node_features),
+ provided_init_features: Clone::clone(&orig.provided_init_features),
MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
free: Clone::clone(&orig.free),
}
fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
(self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false })
}
+ fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
+ let mut ret = (self.provided_node_features)(self.this_arg);
+ *unsafe { Box::from_raw(ret.take_inner()) }
+ }
+ fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
+ let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
+ *unsafe { Box::from_raw(ret.take_inner()) }
+ }
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
/// false or returning an Err otherwise.
#[must_use]
pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
- /// Gets a subset of the channel announcements and updates required to dump our routing table
- /// to a remote node, starting at the short_channel_id indicated by starting_point and
- /// including the batch_amount entries immediately higher in numerical value than starting_point.
+ /// Gets channel announcements and updates required to dump our routing table to a remote node,
+ /// starting at the short_channel_id indicated by starting_point and including announcements
+ /// for a single channel.
#[must_use]
- pub get_next_channel_announcements: extern "C" fn (this_arg: *const c_void, starting_point: u64, batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
- /// Gets a subset of the node announcements required to dump our routing table to a remote node,
- /// starting at the node *after* the provided publickey and including batch_amount entries
- /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
+ pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
+ /// Gets a node announcement required to dump our routing table to a remote node, starting at
+ /// the node *after* the provided pubkey and including up to one announcement immediately
+ /// higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
/// If None is provided for starting_point, we start at the first node.
///
/// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
+ /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
- pub get_next_node_announcements: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey, batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ,
+ pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::NodeAnnouncement,
/// Called when a connection is established with a peer. This can be used to
/// perform routing table synchronization using a strategy defined by the
/// implementor.
/// list of short_channel_ids.
#[must_use]
pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
+ /// Gets the node feature flags which this handler itself supports. All available handlers are
+ /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ /// which are broadcasted in our [`NodeAnnouncement`] message.
+ #[must_use]
+ pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
+ /// Gets the init feature flags which should be sent to the given peer. All available handlers
+ /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ /// which are sent in our [`Init`] message.
+ ///
+ /// Note that this method is called before [`Self::peer_connected`].
+ #[must_use]
+ pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
/// Implementation of MessageSendEventsProvider for this object.
pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
/// Frees any resources associated with this object given its this_arg pointer.
handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
handle_channel_update: Clone::clone(&orig.handle_channel_update),
- get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
- get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
+ get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
+ get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
peer_connected: Clone::clone(&orig.peer_connected),
handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
+ provided_node_features: Clone::clone(&orig.provided_node_features),
+ provided_init_features: Clone::clone(&orig.provided_init_features),
MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
free: Clone::clone(&orig.free),
}
let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
local_ret
}
- fn get_next_channel_announcements(&self, mut starting_point: u64, mut batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
- let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); };
+ fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
+ let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
+ let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None };
local_ret
}
- fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
+ fn get_next_node_announcement(&self, mut starting_point: Option<&bitcoin::secp256k1::PublicKey>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
let mut local_starting_point = if starting_point.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(starting_point.unwrap())) } };
- let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
+ let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
local_ret
}
fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) {
let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
local_ret
}
+ fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
+ let mut ret = (self.provided_node_features)(self.this_arg);
+ *unsafe { Box::from_raw(ret.take_inner()) }
+ }
+ fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
+ let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
+ *unsafe { Box::from_raw(ret.take_inner()) }
+ }
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
}
}
}
+/// A trait to describe an object that can receive onion messages.
+#[repr(C)]
+pub struct OnionMessageHandler {
+ /// 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 onion_message message from the given peer.
+ pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage),
+ /// Called when a connection is established with a peer. Can be used to track which peers
+ /// advertise onion message support and are online.
+ pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
+ /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
+ /// drop and refuse to forward onion messages to this peer.
+ pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
+ /// Gets the node feature flags which this handler itself supports. All available handlers are
+ /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
+ /// which are broadcasted in our [`NodeAnnouncement`] message.
+ #[must_use]
+ pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
+ /// Gets the init feature flags which should be sent to the given peer. All available handlers
+ /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
+ /// which are sent in our [`Init`] message.
+ ///
+ /// Note that this method is called before [`Self::peer_connected`].
+ #[must_use]
+ pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
+ /// Implementation of OnionMessageProvider for this object.
+ pub OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider,
+ /// 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for OnionMessageHandler {}
+unsafe impl Sync for OnionMessageHandler {}
+#[no_mangle]
+pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
+ OnionMessageHandler {
+ this_arg: orig.this_arg,
+ handle_onion_message: Clone::clone(&orig.handle_onion_message),
+ peer_connected: Clone::clone(&orig.peer_connected),
+ peer_disconnected: Clone::clone(&orig.peer_disconnected),
+ provided_node_features: Clone::clone(&orig.provided_node_features),
+ provided_init_features: Clone::clone(&orig.provided_init_features),
+ OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
+ free: Clone::clone(&orig.free),
+ }
+}
+impl lightning::util::events::OnionMessageProvider for OnionMessageHandler {
+ fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
+ let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
+ let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
+ local_ret
+ }
+}
+
+use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
+impl rustOnionMessageHandler for OnionMessageHandler {
+ fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
+ (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false })
+ }
+ fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) {
+ (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false })
+ }
+ fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut no_connection_possible: bool) {
+ (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
+ }
+ fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
+ let mut ret = (self.provided_node_features)(self.this_arg);
+ *unsafe { Box::from_raw(ret.take_inner()) }
+ }
+ fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
+ let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
+ *unsafe { Box::from_raw(ret.take_inner()) }
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for OnionMessageHandler {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
+impl Drop for OnionMessageHandler {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
mod fuzzy_internal_msgs {
use alloc::str::FromStr;
local_res
}
#[no_mangle]
+/// Read a OnionMessage from a byte array, created by OnionMessage_write
+pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
+ let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
+#[no_mangle]
+/// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
+pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
+}
+#[no_mangle]
/// Serialize the Ping object into a byte array which can be read by Ping_read
pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
handle_node_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement,
handle_channel_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement,
handle_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update,
- get_next_channel_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements,
- get_next_node_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcements,
+ get_next_channel_announcement: IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcement,
+ get_next_node_announcement: IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcement,
peer_connected: IgnoringMessageHandler_RoutingMessageHandler_peer_connected,
handle_reply_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range,
handle_reply_short_channel_ids_end: IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end,
handle_query_channel_range: IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range,
handle_query_short_channel_ids: IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids,
+ provided_node_features: IgnoringMessageHandler_RoutingMessageHandler_provided_node_features,
+ provided_init_features: IgnoringMessageHandler_RoutingMessageHandler_provided_init_features,
MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, _msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _msg.get_native_ref());
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, _msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _msg.get_native_ref());
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, _msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _msg.get_native_ref());
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut _starting_point: u64, mut _batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _starting_point, _batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
- local_ret.into()
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcement(this_arg: *const c_void, mut starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, starting_point);
+ let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None } else { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = (ret.unwrap()); let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }) };
+ local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcements(this_arg: *const c_void, mut _starting_point: crate::c_types::PublicKey, mut _batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ {
- let mut local__starting_point_base = if _starting_point.is_null() { None } else { Some( { _starting_point.into_rust() }) }; let mut local__starting_point = local__starting_point_base.as_ref();
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, local__starting_point, _batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
- local_ret.into()
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcement(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::NodeAnnouncement {
+ let mut local_starting_point_base = if starting_point.is_null() { None } else { Some( { starting_point.into_rust() }) }; let mut local_starting_point = local_starting_point_base.as_ref();
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, local_starting_point);
+ let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
+ local_ret
}
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _init: &crate::lightning::ln::msgs::Init) {
- <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), _init.get_native_ref())
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) {
+ <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), init.get_native_ref())
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
+#[must_use]
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, );
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+#[must_use]
+extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust());
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+impl From<nativeIgnoringMessageHandler> for crate::lightning::util::events::OnionMessageProvider {
+ fn from(obj: nativeIgnoringMessageHandler) -> Self {
+ let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = IgnoringMessageHandler_as_OnionMessageProvider(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(IgnoringMessageHandler_free_void);
+ ret
+ }
+}
+/// Constructs a new OnionMessageProvider which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn IgnoringMessageHandler_as_OnionMessageProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::util::events::OnionMessageProvider {
+ crate::lightning::util::events::OnionMessageProvider {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ next_onion_message_for_peer: IgnoringMessageHandler_OnionMessageProvider_next_onion_message_for_peer,
+ }
+}
+
+#[must_use]
+extern "C" fn IgnoringMessageHandler_OnionMessageProvider_next_onion_message_for_peer(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::util::events::OnionMessageProvider<>>::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, peer_node_id.into_rust());
+ let mut local_ret = crate::lightning::ln::msgs::OnionMessage { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
+ local_ret
+}
+
+impl From<nativeIgnoringMessageHandler> for crate::lightning::ln::msgs::OnionMessageHandler {
+ fn from(obj: nativeIgnoringMessageHandler) -> Self {
+ let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = IgnoringMessageHandler_as_OnionMessageHandler(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(IgnoringMessageHandler_free_void);
+ ret
+ }
+}
+/// Constructs a new OnionMessageHandler which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn IgnoringMessageHandler_as_OnionMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::ln::msgs::OnionMessageHandler {
+ crate::lightning::ln::msgs::OnionMessageHandler {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ handle_onion_message: IgnoringMessageHandler_OnionMessageHandler_handle_onion_message,
+ peer_connected: IgnoringMessageHandler_OnionMessageHandler_peer_connected,
+ peer_disconnected: IgnoringMessageHandler_OnionMessageHandler_peer_disconnected,
+ provided_node_features: IgnoringMessageHandler_OnionMessageHandler_provided_node_features,
+ provided_init_features: IgnoringMessageHandler_OnionMessageHandler_provided_init_features,
+ OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ next_onion_message_for_peer: IgnoringMessageHandler_OnionMessageProvider_next_onion_message_for_peer,
+ },
+ }
+}
+
+extern "C" fn IgnoringMessageHandler_OnionMessageHandler_handle_onion_message(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage) {
+ <nativeIgnoringMessageHandler as lightning::ln::msgs::OnionMessageHandler<>>::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &peer_node_id.into_rust(), msg.get_native_ref())
+}
+extern "C" fn IgnoringMessageHandler_OnionMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) {
+ <nativeIgnoringMessageHandler as lightning::ln::msgs::OnionMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), init.get_native_ref())
+}
+extern "C" fn IgnoringMessageHandler_OnionMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
+ <nativeIgnoringMessageHandler as lightning::ln::msgs::OnionMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), no_connection_possible)
+}
+#[must_use]
+extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::OnionMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, );
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+#[must_use]
+extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::OnionMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust());
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
use core::convert::Infallible as nativeInfallible;
impl From<nativeInfallible> for crate::lightning::ln::wire::Type {
}
#[must_use]
-extern "C" fn IgnoringMessageHandler_CustomMessageReader_read(this_arg: *const c_void, mut _message_type: u16, mut _buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_TypeZDecodeErrorZ {
- let mut ret = <nativeIgnoringMessageHandler as lightning::ln::wire::CustomMessageReader<>>::read(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _message_type, &mut _buffer.to_reader());
+extern "C" fn IgnoringMessageHandler_CustomMessageReader_read(this_arg: *const c_void, mut message_type: u16, mut buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_TypeZDecodeErrorZ {
+ let mut ret = <nativeIgnoringMessageHandler as lightning::ln::wire::CustomMessageReader<>>::read(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message_type, &mut buffer.to_reader());
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = if o.is_none() { crate::c_types::derived::COption_TypeZ::None } else { crate::c_types::derived::COption_TypeZ::Some( { Into::into(o.unwrap()) }) }; local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
handle_channel_reestablish: ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish,
handle_channel_update: ErroringMessageHandler_ChannelMessageHandler_handle_channel_update,
handle_error: ErroringMessageHandler_ChannelMessageHandler_handle_error,
+ provided_node_features: ErroringMessageHandler_ChannelMessageHandler_provided_node_features,
+ provided_init_features: ErroringMessageHandler_ChannelMessageHandler_provided_init_features,
MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
}
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut _their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(_their_features.take_inner()) }, msg.get_native_ref())
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut _their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(_their_features.take_inner()) }, msg.get_native_ref())
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
}
extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) {
<nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_ready(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady) {
<nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, _their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), _their_features.get_native_ref(), msg.get_native_ref())
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), their_features.get_native_ref(), msg.get_native_ref())
}
extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) {
<nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) {
<nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _no_connection_possible: bool) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _no_connection_possible)
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), no_connection_possible)
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::lightning::ln::msgs::Init) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _msg.get_native_ref())
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
}
extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) {
<nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::lightning::ln::msgs::ChannelUpdate) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _msg.get_native_ref())
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
}
-extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, _msg: &crate::lightning::ln::msgs::ErrorMessage) {
- <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &_their_node_id.into_rust(), _msg.get_native_ref())
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) {
+ <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref())
+}
+#[must_use]
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, );
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+#[must_use]
+extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = <nativeErroringMessageHandler as lightning::ln::msgs::ChannelMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust());
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport;
-pub(crate) type nativeMessageHandler = nativeMessageHandlerImport<crate::lightning::ln::msgs::ChannelMessageHandler, crate::lightning::ln::msgs::RoutingMessageHandler>;
+pub(crate) type nativeMessageHandler = nativeMessageHandlerImport<crate::lightning::ln::msgs::ChannelMessageHandler, crate::lightning::ln::msgs::RoutingMessageHandler, crate::lightning::ln::msgs::OnionMessageHandler>;
/// Provides references to trait impls which handle different types of messages.
#[must_use]
pub extern "C" fn MessageHandler_set_route_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::RoutingMessageHandler) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_handler = val;
}
+/// A message handler which handles onion messages. For now, this can only be an
+/// [`IgnoringMessageHandler`].
+#[no_mangle]
+pub extern "C" fn MessageHandler_get_onion_message_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::msgs::OnionMessageHandler {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_message_handler;
+ inner_val
+}
+/// A message handler which handles onion messages. For now, this can only be an
+/// [`IgnoringMessageHandler`].
+#[no_mangle]
+pub extern "C" fn MessageHandler_set_onion_message_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::OnionMessageHandler) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_message_handler = val;
+}
/// Constructs a new MessageHandler given each field
#[must_use]
#[no_mangle]
-pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::ln::msgs::RoutingMessageHandler) -> MessageHandler {
+pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::ln::msgs::RoutingMessageHandler, mut onion_message_handler_arg: crate::lightning::ln::msgs::OnionMessageHandler) -> MessageHandler {
MessageHandler { inner: ObjOps::heap_alloc(nativeMessageHandler {
chan_handler: chan_handler_arg,
route_handler: route_handler_arg,
+ onion_message_handler: onion_message_handler_arg,
}), is_owned: true }
}
/// Provides an object which can be used to send data to and which uniquely identifies a connection
}
use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport;
-pub(crate) type nativePeerManager = nativePeerManagerImport<crate::lightning::ln::peer_handler::SocketDescriptor, crate::lightning::ln::msgs::ChannelMessageHandler, crate::lightning::ln::msgs::RoutingMessageHandler, crate::lightning::util::logger::Logger, crate::lightning::ln::peer_handler::CustomMessageHandler>;
+pub(crate) type nativePeerManager = nativePeerManagerImport<crate::lightning::ln::peer_handler::SocketDescriptor, crate::lightning::ln::msgs::ChannelMessageHandler, crate::lightning::ln::msgs::RoutingMessageHandler, crate::lightning::ln::msgs::OnionMessageHandler, crate::lightning::util::logger::Logger, crate::lightning::ln::peer_handler::CustomMessageHandler>;
/// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls
/// socket events into messages which it passes on to its [`MessageHandler`].
/// Constructs a new PeerManager with the given message handlers and node_id secret key
/// ephemeral_random_data is used to derive per-connection ephemeral keys and must be
/// cryptographically secure random bytes.
+///
+/// `current_time` is used as an always-increasing counter that survives across restarts and is
+/// incremented irregularly internally. In general it is best to simply use the current UNIX
+/// timestamp, however if it is not available a persistent counter that increases once per
+/// minute should suffice.
#[must_use]
#[no_mangle]
-pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut custom_message_handler: crate::lightning::ln::peer_handler::CustomMessageHandler) -> crate::lightning::ln::peer_handler::PeerManager {
- let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, our_node_secret.into_rust(), unsafe { &*ephemeral_random_data}, logger, custom_message_handler);
+pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, mut current_time: u64, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut custom_message_handler: crate::lightning::ln::peer_handler::CustomMessageHandler) -> crate::lightning::ln::peer_handler::PeerManager {
+ let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, our_node_secret.into_rust(), current_time, unsafe { &*ephemeral_random_data}, logger, custom_message_handler);
crate::lightning::ln::peer_handler::PeerManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timer_tick_occurred()
}
+/// Generates a signed node_announcement from the given arguments, sending it to all connected
+/// peers. Note that peers will likely ignore this message unless we have at least one public
+/// channel which has at least six confirmations on-chain.
+///
+/// `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
+/// node to humans. They carry no in-protocol meaning.
+///
+/// `addresses` represent the set (possibly empty) of socket addresses on which this node
+/// accepts incoming connections. These will be included in the node_announcement, publicly
+/// tying these addresses together and to this node. If you wish to preserve user privacy,
+/// addresses should likely contain only Tor Onion addresses.
+///
+/// Panics if `addresses` is absurdly large (more than 100).
+///
+/// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
+#[no_mangle]
+pub extern "C" fn PeerManager_broadcast_node_announcement(this_arg: &crate::lightning::ln::peer_handler::PeerManager, mut rgb: crate::c_types::ThreeBytes, mut alias: crate::c_types::ThirtyTwoBytes, mut addresses: crate::c_types::derived::CVec_NetAddressZ) {
+ let mut local_addresses = Vec::new(); for mut item in addresses.into_rust().drain(..) { local_addresses.push( { item.into_native() }); };
+ unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.broadcast_node_announcement(rgb.data, alias.data, local_addresses)
+}
+
//! Wire encoding/decoding for Lightning messages according to [BOLT #1], and for
//! custom message through the [`CustomMessageReader`] trait.
-//!
+//!
//! [BOLT #1]: https://github.com/lightning/bolts/blob/master/01-messaging.md
use alloc::str::FromStr;
//! figure out how best to make networking happen/timers fire/things get written to disk/keys get
//! generated/etc. This makes it a good candidate for tight integration into an existing wallet
//! instead of having a rather-separate lightning appendage to a wallet.
-//!
+//!
//! `default` features are:
//!
//! * `std` - enables functionalities which require `std`, including `std::io` trait implementations and things which utilize time
pub mod chain;
pub mod ln;
pub mod routing;
+pub mod onion_message;
mod io_extras {
use alloc::str::FromStr;
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history and in the source files from which this was generated.
+//
+// This file is licensed under the license available in the LICENSE or LICENSE.md
+// file in the root of this repository or, if no such file exists, the same
+// license as that which applies to the original source files from which this
+// source was automatically generated.
+
+//! Creating blinded routes and related utilities live here.
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+
+use lightning::onion_message::blinded_route::BlindedRoute as nativeBlindedRouteImport;
+pub(crate) type nativeBlindedRoute = nativeBlindedRouteImport;
+
+/// Onion messages can be sent and received to blinded routes, which serve to hide the identity of
+/// the recipient.
+#[must_use]
+#[repr(C)]
+pub struct BlindedRoute {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeBlindedRoute,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 BlindedRoute {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeBlindedRoute>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the BlindedRoute, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn BlindedRoute_free(this_obj: BlindedRoute) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn BlindedRoute_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBlindedRoute); }
+}
+#[allow(unused)]
+impl BlindedRoute {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedRoute {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedRoute {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeBlindedRoute {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::onion_message::blinded_route::BlindedHop as nativeBlindedHopImport;
+pub(crate) type nativeBlindedHop = nativeBlindedHopImport;
+
+/// Used to construct the blinded hops portion of a blinded route. These hops cannot be identified
+/// by outside observers and thus can be used to hide the identity of the recipient.
+#[must_use]
+#[repr(C)]
+pub struct BlindedHop {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeBlindedHop,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 BlindedHop {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeBlindedHop>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn BlindedHop_free(this_obj: BlindedHop) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn BlindedHop_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBlindedHop); }
+}
+#[allow(unused)]
+impl BlindedHop {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHop {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHop {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeBlindedHop {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Create a blinded route to be forwarded along `node_pks`. The last node pubkey in `node_pks`
+/// will be the destination node.
+///
+/// Errors if less than two hops are provided or if `node_pk`(s) are invalid.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BlindedRoute_new(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, keys_manager: &crate::lightning::chain::keysinterface::KeysInterface) -> crate::c_types::derived::CResult_BlindedRouteNoneZ {
+ let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); };
+ let mut ret = lightning::onion_message::blinded_route::BlindedRoute::new(&local_node_pks[..], keys_manager, secp256k1::global::SECP256K1);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::blinded_route::BlindedRoute { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
+ local_ret
+}
+
+#[no_mangle]
+/// Serialize the BlindedRoute object into a byte array which can be read by BlindedRoute_read
+pub extern "C" fn BlindedRoute_write(obj: &crate::lightning::onion_message::blinded_route::BlindedRoute) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn BlindedRoute_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedRoute) })
+}
+#[no_mangle]
+/// Read a BlindedRoute from a byte array, created by BlindedRoute_write
+pub extern "C" fn BlindedRoute_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedRouteDecodeErrorZ {
+ let res: Result<lightning::onion_message::blinded_route::BlindedRoute, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::blinded_route::BlindedRoute { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
+#[no_mangle]
+/// Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
+pub extern "C" fn BlindedHop_write(obj: &crate::lightning::onion_message::blinded_route::BlindedHop) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn BlindedHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHop) })
+}
+#[no_mangle]
+/// Read a BlindedHop from a byte array, created by BlindedHop_write
+pub extern "C" fn BlindedHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedHopDecodeErrorZ {
+ let res: Result<lightning::onion_message::blinded_route::BlindedHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::blinded_route::BlindedHop { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history and in the source files from which this was generated.
+//
+// This file is licensed under the license available in the LICENSE or LICENSE.md
+// file in the root of this repository or, if no such file exists, the same
+// license as that which applies to the original source files from which this
+// source was automatically generated.
+
+//! LDK sends, receives, and forwards onion messages via the [`OnionMessenger`]. See its docs for
+//! more information.
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+
+use lightning::onion_message::messenger::OnionMessenger as nativeOnionMessengerImport;
+pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::util::logger::Logger>;
+
+/// A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be
+/// used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending
+/// and receiving empty onion messages is supported.
+///
+/// # Example
+///
+/// ```
+/// # extern crate bitcoin;
+/// # use bitcoin::hashes::_export::_core::time::Duration;
+/// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
+/// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
+/// # use lightning::onion_message::messenger::{Destination, OnionMessenger};
+/// # use lightning::onion_message::blinded_route::BlindedRoute;
+/// # use lightning::util::logger::{Logger, Record};
+/// # use std::sync::Arc;
+/// # struct FakeLogger {};
+/// # impl Logger for FakeLogger {
+/// # fn log(&self, record: &Record) { unimplemented!() }
+/// # }
+/// # let seed = [42u8; 32];
+/// # let time = Duration::from_secs(123456);
+/// # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos());
+/// # let logger = Arc::new(FakeLogger {});
+/// # let node_secret = SecretKey::from_slice(&hex::decode(\"0101010101010101010101010101010101010101010101010101010101010101\").unwrap()[..]).unwrap();
+/// # let secp_ctx = Secp256k1::new();
+/// # let hop_node_id1 = PublicKey::from_secret_key(&secp_ctx, &node_secret);
+/// # let (hop_node_id2, hop_node_id3, hop_node_id4) = (hop_node_id1, hop_node_id1,
+/// hop_node_id1);
+/// # let destination_node_id = hop_node_id1;
+/// #
+/// // Create the onion messenger. This must use the same `keys_manager` as is passed to your
+/// // ChannelManager.
+/// let onion_messenger = OnionMessenger::new(&keys_manager, logger);
+///
+/// // Send an empty onion message to a node id.
+/// let intermediate_hops = [hop_node_id1, hop_node_id2];
+/// let reply_path = None;
+/// onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), reply_path);
+///
+/// // Create a blinded route to yourself, for someone to send an onion message to.
+/// # let your_node_id = hop_node_id1;
+/// let hops = [hop_node_id3, hop_node_id4, your_node_id];
+/// let blinded_route = BlindedRoute::new(&hops, &keys_manager, &secp_ctx).unwrap();
+///
+/// // Send an empty onion message to a blinded route.
+/// # let intermediate_hops = [hop_node_id1, hop_node_id2];
+/// let reply_path = None;
+/// onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedRoute(blinded_route), reply_path);
+/// ```
+///
+/// [offers]: <https://github.com/lightning/bolts/pull/798>
+/// [`OnionMessenger`]: crate::onion_message::OnionMessenger
+#[must_use]
+#[repr(C)]
+pub struct OnionMessenger {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeOnionMessenger,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 OnionMessenger {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeOnionMessenger>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn OnionMessenger_free(this_obj: OnionMessenger) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn OnionMessenger_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOnionMessenger); }
+}
+#[allow(unused)]
+impl OnionMessenger {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessenger {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessenger {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessenger {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The destination of an onion message.
+#[must_use]
+#[repr(C)]
+pub enum Destination {
+ /// We're sending this onion message to a node.
+ Node(
+ crate::c_types::PublicKey),
+ /// We're sending this onion message to a blinded route.
+ BlindedRoute(
+ crate::lightning::onion_message::blinded_route::BlindedRoute),
+}
+use lightning::onion_message::messenger::Destination as DestinationImport;
+pub(crate) type nativeDestination = DestinationImport;
+
+impl Destination {
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeDestination {
+ match self {
+ Destination::Node (mut a, ) => {
+ nativeDestination::Node (
+ a.into_rust(),
+ )
+ },
+ Destination::BlindedRoute (mut a, ) => {
+ nativeDestination::BlindedRoute (
+ *unsafe { Box::from_raw(a.take_inner()) },
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeDestination) -> Self {
+ match native {
+ nativeDestination::Node (mut a, ) => {
+ Destination::Node (
+ crate::c_types::PublicKey::from_rust(&a),
+ )
+ },
+ nativeDestination::BlindedRoute (mut a, ) => {
+ Destination::BlindedRoute (
+ crate::lightning::onion_message::blinded_route::BlindedRoute { inner: ObjOps::heap_alloc(a), is_owned: true },
+ )
+ },
+ }
+ }
+}
+/// Frees any resources used by the Destination
+#[no_mangle]
+pub extern "C" fn Destination_free(this_ptr: Destination) { }
+#[no_mangle]
+/// Utility method to constructs a new Node-variant Destination
+pub extern "C" fn Destination_node(a: crate::c_types::PublicKey) -> Destination {
+ Destination::Node(a, )
+}
+#[no_mangle]
+/// Utility method to constructs a new BlindedRoute-variant Destination
+pub extern "C" fn Destination_blinded_route(a: crate::lightning::onion_message::blinded_route::BlindedRoute) -> Destination {
+ Destination::BlindedRoute(a, )
+}
+/// Errors that may occur when [sending an onion message].
+///
+/// [sending an onion message]: OnionMessenger::send_onion_message
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum SendError {
+ /// Errored computing onion message packet keys.
+ Secp256k1(
+ crate::c_types::Secp256k1Error),
+ /// Because implementations such as Eclair will drop onion messages where the message packet
+ /// exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size.
+ TooBigPacket,
+ /// The provided [`Destination`] was an invalid [`BlindedRoute`], due to having fewer than two
+ /// blinded hops.
+ TooFewBlindedHops,
+ /// Our next-hop peer was offline or does not support onion message forwarding.
+ InvalidFirstHop,
+ /// Our next-hop peer's buffer was full or our total outbound buffer was full.
+ BufferFull,
+}
+use lightning::onion_message::messenger::SendError as SendErrorImport;
+pub(crate) type nativeSendError = SendErrorImport;
+
+impl SendError {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeSendError {
+ match self {
+ SendError::Secp256k1 (ref a, ) => {
+ let mut a_nonref = (*a).clone();
+ nativeSendError::Secp256k1 (
+ a_nonref.into_rust(),
+ )
+ },
+ SendError::TooBigPacket => nativeSendError::TooBigPacket,
+ SendError::TooFewBlindedHops => nativeSendError::TooFewBlindedHops,
+ SendError::InvalidFirstHop => nativeSendError::InvalidFirstHop,
+ SendError::BufferFull => nativeSendError::BufferFull,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeSendError {
+ match self {
+ SendError::Secp256k1 (mut a, ) => {
+ nativeSendError::Secp256k1 (
+ a.into_rust(),
+ )
+ },
+ SendError::TooBigPacket => nativeSendError::TooBigPacket,
+ SendError::TooFewBlindedHops => nativeSendError::TooFewBlindedHops,
+ SendError::InvalidFirstHop => nativeSendError::InvalidFirstHop,
+ SendError::BufferFull => nativeSendError::BufferFull,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeSendError) -> Self {
+ match native {
+ nativeSendError::Secp256k1 (ref a, ) => {
+ let mut a_nonref = (*a).clone();
+ SendError::Secp256k1 (
+ crate::c_types::Secp256k1Error::from_rust(a_nonref),
+ )
+ },
+ nativeSendError::TooBigPacket => SendError::TooBigPacket,
+ nativeSendError::TooFewBlindedHops => SendError::TooFewBlindedHops,
+ nativeSendError::InvalidFirstHop => SendError::InvalidFirstHop,
+ nativeSendError::BufferFull => SendError::BufferFull,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeSendError) -> Self {
+ match native {
+ nativeSendError::Secp256k1 (mut a, ) => {
+ SendError::Secp256k1 (
+ crate::c_types::Secp256k1Error::from_rust(a),
+ )
+ },
+ nativeSendError::TooBigPacket => SendError::TooBigPacket,
+ nativeSendError::TooFewBlindedHops => SendError::TooFewBlindedHops,
+ nativeSendError::InvalidFirstHop => SendError::InvalidFirstHop,
+ nativeSendError::BufferFull => SendError::BufferFull,
+ }
+ }
+}
+/// Frees any resources used by the SendError
+#[no_mangle]
+pub extern "C" fn SendError_free(this_ptr: SendError) { }
+/// Creates a copy of the SendError
+#[no_mangle]
+pub extern "C" fn SendError_clone(orig: &SendError) -> SendError {
+ orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new Secp256k1-variant SendError
+pub extern "C" fn SendError_secp256k1(a: crate::c_types::Secp256k1Error) -> SendError {
+ SendError::Secp256k1(a, )
+}
+#[no_mangle]
+/// Utility method to constructs a new TooBigPacket-variant SendError
+pub extern "C" fn SendError_too_big_packet() -> SendError {
+ SendError::TooBigPacket}
+#[no_mangle]
+/// Utility method to constructs a new TooFewBlindedHops-variant SendError
+pub extern "C" fn SendError_too_few_blinded_hops() -> SendError {
+ SendError::TooFewBlindedHops}
+#[no_mangle]
+/// Utility method to constructs a new InvalidFirstHop-variant SendError
+pub extern "C" fn SendError_invalid_first_hop() -> SendError {
+ SendError::InvalidFirstHop}
+#[no_mangle]
+/// Utility method to constructs a new BufferFull-variant SendError
+pub extern "C" fn SendError_buffer_full() -> SendError {
+ SendError::BufferFull}
+/// Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to
+/// their respective handlers.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn OnionMessenger_new(mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::onion_message::messenger::OnionMessenger {
+ let mut ret = lightning::onion_message::messenger::OnionMessenger::new(keys_manager, logger);
+ crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// Send an empty onion message to `destination`, routing it through `intermediate_nodes`.
+/// See [`OnionMessenger`] for example usage.
+///
+/// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut intermediate_nodes: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination, mut reply_path: crate::lightning::onion_message::blinded_route::BlindedRoute) -> crate::c_types::derived::CResult_NoneSendErrorZ {
+ let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { item.into_rust() }); };
+ let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(&local_intermediate_nodes[..], destination.into_native(), local_reply_path);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() };
+ local_ret
+}
+
+impl From<nativeOnionMessenger> for crate::lightning::ln::msgs::OnionMessageHandler {
+ fn from(obj: nativeOnionMessenger) -> Self {
+ let mut rust_obj = OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = OnionMessenger_as_OnionMessageHandler(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(OnionMessenger_free_void);
+ ret
+ }
+}
+/// Constructs a new OnionMessageHandler which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn OnionMessenger_as_OnionMessageHandler(this_arg: &OnionMessenger) -> crate::lightning::ln::msgs::OnionMessageHandler {
+ crate::lightning::ln::msgs::OnionMessageHandler {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ handle_onion_message: OnionMessenger_OnionMessageHandler_handle_onion_message,
+ peer_connected: OnionMessenger_OnionMessageHandler_peer_connected,
+ peer_disconnected: OnionMessenger_OnionMessageHandler_peer_disconnected,
+ provided_node_features: OnionMessenger_OnionMessageHandler_provided_node_features,
+ provided_init_features: OnionMessenger_OnionMessageHandler_provided_init_features,
+ OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ next_onion_message_for_peer: OnionMessenger_OnionMessageProvider_next_onion_message_for_peer,
+ },
+ }
+}
+
+extern "C" fn OnionMessenger_OnionMessageHandler_handle_onion_message(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage) {
+ <nativeOnionMessenger as lightning::ln::msgs::OnionMessageHandler<>>::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &peer_node_id.into_rust(), msg.get_native_ref())
+}
+extern "C" fn OnionMessenger_OnionMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) {
+ <nativeOnionMessenger as lightning::ln::msgs::OnionMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust(), init.get_native_ref())
+}
+extern "C" fn OnionMessenger_OnionMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
+ <nativeOnionMessenger as lightning::ln::msgs::OnionMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust(), no_connection_possible)
+}
+#[must_use]
+extern "C" fn OnionMessenger_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = <nativeOnionMessenger as lightning::ln::msgs::OnionMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, );
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+#[must_use]
+extern "C" fn OnionMessenger_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = <nativeOnionMessenger as lightning::ln::msgs::OnionMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust());
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+impl From<nativeOnionMessenger> for crate::lightning::util::events::OnionMessageProvider {
+ fn from(obj: nativeOnionMessenger) -> Self {
+ let mut rust_obj = OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = OnionMessenger_as_OnionMessageProvider(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(OnionMessenger_free_void);
+ ret
+ }
+}
+/// Constructs a new OnionMessageProvider which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn OnionMessenger_as_OnionMessageProvider(this_arg: &OnionMessenger) -> crate::lightning::util::events::OnionMessageProvider {
+ crate::lightning::util::events::OnionMessageProvider {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ next_onion_message_for_peer: OnionMessenger_OnionMessageProvider_next_onion_message_for_peer,
+ }
+}
+
+#[must_use]
+extern "C" fn OnionMessenger_OnionMessageProvider_next_onion_message_for_peer(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage {
+ let mut ret = <nativeOnionMessenger as lightning::util::events::OnionMessageProvider<>>::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, peer_node_id.into_rust());
+ let mut local_ret = crate::lightning::ln::msgs::OnionMessage { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
+ local_ret
+}
+
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history and in the source files from which this was generated.
+//
+// This file is licensed under the license available in the LICENSE or LICENSE.md
+// file in the root of this repository or, if no such file exists, the same
+// license as that which applies to the original source files from which this
+// source was automatically generated.
+
+//! Onion Messages: sending, receiving, forwarding, and ancillary utilities live here
+//!
+//! Onion messages are multi-purpose messages sent between peers over the lightning network. In the
+//! near future, they will be used to communicate invoices for [offers], unlocking use cases such as
+//! static invoices, refunds and proof of payer. Further, you will be able to accept payments
+//! without revealing your node id through the use of [blinded routes].
+//!
+//! LDK sends and receives onion messages via the [`OnionMessenger`]. See its documentation for more
+//! information on its usage.
+//!
+//! [offers]: <https://github.com/lightning/bolts/pull/798>
+//! [blinded routes]: crate::onion_message::blinded_route::BlindedRoute
+//! [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+pub mod blinded_route;
+pub mod messenger;
+pub mod packet;
+mod utils {
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history and in the source files from which this was generated.
+//
+// This file is licensed under the license available in the LICENSE or LICENSE.md
+// file in the root of this repository or, if no such file exists, the same
+// license as that which applies to the original source files from which this
+// source was automatically generated.
+
+//! Structs and enums useful for constructing and reading an onion message packet.
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
handle_node_announcement: P2PGossipSync_RoutingMessageHandler_handle_node_announcement,
handle_channel_announcement: P2PGossipSync_RoutingMessageHandler_handle_channel_announcement,
handle_channel_update: P2PGossipSync_RoutingMessageHandler_handle_channel_update,
- get_next_channel_announcements: P2PGossipSync_RoutingMessageHandler_get_next_channel_announcements,
- get_next_node_announcements: P2PGossipSync_RoutingMessageHandler_get_next_node_announcements,
+ get_next_channel_announcement: P2PGossipSync_RoutingMessageHandler_get_next_channel_announcement,
+ get_next_node_announcement: P2PGossipSync_RoutingMessageHandler_get_next_node_announcement,
peer_connected: P2PGossipSync_RoutingMessageHandler_peer_connected,
handle_reply_channel_range: P2PGossipSync_RoutingMessageHandler_handle_reply_channel_range,
handle_reply_short_channel_ids_end: P2PGossipSync_RoutingMessageHandler_handle_reply_short_channel_ids_end,
handle_query_channel_range: P2PGossipSync_RoutingMessageHandler_handle_query_channel_range,
handle_query_short_channel_ids: P2PGossipSync_RoutingMessageHandler_handle_query_short_channel_ids,
+ provided_node_features: P2PGossipSync_RoutingMessageHandler_provided_node_features,
+ provided_init_features: P2PGossipSync_RoutingMessageHandler_provided_init_features,
MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
local_ret
}
#[must_use]
-extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut starting_point: u64, mut batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
- let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, starting_point, batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
- local_ret.into()
+extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_channel_announcement(this_arg: *const c_void, mut starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, starting_point);
+ let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None } else { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = (ret.unwrap()); let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }) };
+ local_ret
}
#[must_use]
-extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_node_announcements(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey, mut batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ {
+extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_node_announcement(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::NodeAnnouncement {
let mut local_starting_point_base = if starting_point.is_null() { None } else { Some( { starting_point.into_rust() }) }; let mut local_starting_point = local_starting_point_base.as_ref();
- let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_node_announcements(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, local_starting_point, batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
- local_ret.into()
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, local_starting_point);
+ let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
+ local_ret
}
-extern "C" fn P2PGossipSync_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
- <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init_msg.get_native_ref())
+extern "C" fn P2PGossipSync_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) {
+ <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init.get_native_ref())
}
#[must_use]
-extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
#[must_use]
-extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
local_ret
}
#[must_use]
-extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
- let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) });
+extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
+#[must_use]
+extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, );
+ crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+#[must_use]
+extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
+ let mut ret = <nativeP2PGossipSync as lightning::ln::msgs::RoutingMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust());
+ crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
impl From<nativeP2PGossipSync> for crate::lightning::util::events::MessageSendEventsProvider {
fn from(obj: nativeP2PGossipSync) -> Self {
local_ret
}
+/// Returns the list of channels in the graph
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ReadOnlyNetworkGraph_list_channels(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::c_types::derived::CVec_u64Z {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels();
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); };
+ local_ret.into()
+}
+
/// Returns information on a node with the given id.
///
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
local_ret
}
+/// Returns the list of nodes in the graph
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ReadOnlyNetworkGraph_list_nodes(this_arg: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::c_types::derived::CVec_NodeIdZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_nodes();
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ local_ret.into()
+}
+
/// Get network addresses by node id.
/// Returns None if the requested node is completely unknown,
/// or if node announcement for the node was never received.
}
}
}
+/// Refers to a scorer that is accessible under lock and also writeable to disk
+///
+/// We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to
+/// use the Persister to persist it.
+#[repr(C)]
+pub struct WriteableScore {
+ /// An opaque pointer which is passed to your function implementations as an argument.
+ /// This has no meaning in the LDK, and can be NULL or any other value.
+ pub this_arg: *mut c_void,
+ /// Implementation of LockableScore for this object.
+ pub LockableScore: crate::lightning::routing::scoring::LockableScore,
+ /// 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for WriteableScore {}
+unsafe impl Sync for WriteableScore {}
+#[no_mangle]
+pub(crate) extern "C" fn WriteableScore_clone_fields(orig: &WriteableScore) -> WriteableScore {
+ WriteableScore {
+ this_arg: orig.this_arg,
+ LockableScore: crate::lightning::routing::scoring::LockableScore_clone_fields(&orig.LockableScore),
+ write: Clone::clone(&orig.write),
+ free: Clone::clone(&orig.free),
+ }
+}
+impl<'a> lightning::routing::scoring::LockableScore<'a> for WriteableScore {
+ type Locked = crate::lightning::routing::scoring::Score;
+ fn lock(&'a self) -> crate::lightning::routing::scoring::Score {
+ let mut ret = (self.LockableScore.lock)(self.LockableScore.this_arg);
+ ret
+ }
+}
+impl lightning::util::ser::Writeable for WriteableScore {
+ fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {
+ let vec = (self.write)(self.this_arg);
+ w.write_all(vec.as_slice())
+ }
+}
+
+use lightning::routing::scoring::WriteableScore as rustWriteableScore;
+impl<'a> rustWriteableScore<'a> for WriteableScore {
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for WriteableScore {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn WriteableScore_free(this_ptr: WriteableScore) { }
+impl Drop for WriteableScore {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
use lightning::routing::scoring::MultiThreadedLockableScore as nativeMultiThreadedLockableScoreImport;
pub(crate) type nativeMultiThreadedLockableScore = nativeMultiThreadedLockableScoreImport<crate::lightning::routing::scoring::Score>;
ret
}
}
+
+use lightning::routing::scoring::MultiThreadedScoreLock as nativeMultiThreadedScoreLockImport;
+pub(crate) type nativeMultiThreadedScoreLock = nativeMultiThreadedScoreLockImport<'static, crate::lightning::routing::scoring::Score>;
+
+/// A locked `MultiThreadedLockableScore`.
+#[must_use]
+#[repr(C)]
+pub struct MultiThreadedScoreLock {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeMultiThreadedScoreLock,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 MultiThreadedScoreLock {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeMultiThreadedScoreLock>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the MultiThreadedScoreLock, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn MultiThreadedScoreLock_free(this_obj: MultiThreadedScoreLock) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn MultiThreadedScoreLock_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMultiThreadedScoreLock); }
+}
+#[allow(unused)]
+impl MultiThreadedScoreLock {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeMultiThreadedScoreLock {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMultiThreadedScoreLock {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeMultiThreadedScoreLock {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+impl From<nativeMultiThreadedScoreLock> for crate::lightning::routing::scoring::Score {
+ fn from(obj: nativeMultiThreadedScoreLock) -> Self {
+ let mut rust_obj = MultiThreadedScoreLock { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = MultiThreadedScoreLock_as_Score(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(MultiThreadedScoreLock_free_void);
+ ret
+ }
+}
+/// Constructs a new Score which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn MultiThreadedScoreLock_as_Score(this_arg: &MultiThreadedScoreLock) -> crate::lightning::routing::scoring::Score {
+ crate::lightning::routing::scoring::Score {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ channel_penalty_msat: MultiThreadedScoreLock_Score_channel_penalty_msat,
+ payment_path_failed: MultiThreadedScoreLock_Score_payment_path_failed,
+ payment_path_successful: MultiThreadedScoreLock_Score_payment_path_successful,
+ probe_failed: MultiThreadedScoreLock_Score_probe_failed,
+ probe_successful: MultiThreadedScoreLock_Score_probe_successful,
+ write: MultiThreadedScoreLock_write_void,
+ }
+}
+
+#[must_use]
+extern "C" fn MultiThreadedScoreLock_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 {
+ let mut ret = <nativeMultiThreadedScoreLock as lightning::routing::scoring::Score<>>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) });
+ ret
+}
+extern "C" fn MultiThreadedScoreLock_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeMultiThreadedScoreLock as lightning::routing::scoring::Score<>>::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..], short_channel_id)
+}
+extern "C" fn MultiThreadedScoreLock_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeMultiThreadedScoreLock as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..])
+}
+extern "C" fn MultiThreadedScoreLock_Score_probe_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeMultiThreadedScoreLock as lightning::routing::scoring::Score<>>::probe_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..], short_channel_id)
+}
+extern "C" fn MultiThreadedScoreLock_Score_probe_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeMultiThreadedScoreLock as lightning::routing::scoring::Score<>>::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..])
+}
+
#[no_mangle]
-/// Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read
-pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::c_types::derived::CVec_u8Z {
+/// Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read
+pub extern "C" fn MultiThreadedScoreLock_write(obj: &crate::lightning::routing::scoring::MultiThreadedScoreLock) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
}
#[no_mangle]
-pub(crate) extern "C" fn MultiThreadedLockableScore_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
- crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedLockableScore) })
+pub(crate) extern "C" fn MultiThreadedScoreLock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLock) })
}
+impl From<nativeMultiThreadedLockableScore> for crate::lightning::routing::scoring::LockableScore {
+ fn from(obj: nativeMultiThreadedLockableScore) -> Self {
+ let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = MultiThreadedLockableScore_as_LockableScore(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(MultiThreadedLockableScore_free_void);
+ ret
+ }
+}
+/// Constructs a new LockableScore which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn MultiThreadedLockableScore_as_LockableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::LockableScore {
+ crate::lightning::routing::scoring::LockableScore {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ lock: MultiThreadedLockableScore_LockableScore_lock,
+ }
+}
+
+#[must_use]
+extern "C" fn MultiThreadedLockableScore_LockableScore_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::Score {
+ let mut ret = <nativeMultiThreadedLockableScore as lightning::routing::scoring::LockableScore<>>::lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, );
+ Into::into(ret)
+}
+
/// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`].
#[must_use]
#[no_mangle]
}
#[must_use]
-extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, unused_0: u64, unused_1: &crate::lightning::routing::gossip::NodeId, unused_2: &crate::lightning::routing::gossip::NodeId, unused_3: crate::lightning::routing::scoring::ChannelUsage) -> u64 {
- let mut ret = <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, unused_0, unused_1.get_native_ref(), unused_2.get_native_ref(), *unsafe { Box::from_raw(unused_3.take_inner()) });
+extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 {
+ let mut ret = <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) });
ret
}
-extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ, mut _short_channel_id: u64) {
- let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); };
- <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..], _short_channel_id)
+extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..], short_channel_id)
}
-extern "C" fn FixedPenaltyScorer_Score_payment_path_successful(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ) {
- let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); };
- <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..])
+extern "C" fn FixedPenaltyScorer_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..])
}
-extern "C" fn FixedPenaltyScorer_Score_probe_failed(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ, mut _short_channel_id: u64) {
- let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); };
- <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::probe_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..], _short_channel_id)
+extern "C" fn FixedPenaltyScorer_Score_probe_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::probe_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..], short_channel_id)
}
-extern "C" fn FixedPenaltyScorer_Score_probe_successful(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ) {
- let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); };
- <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::probe_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..])
+extern "C" fn FixedPenaltyScorer_Score_probe_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeFixedPenaltyScorer as lightning::routing::scoring::Score<>>::probe_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..])
}
#[no_mangle]
pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val;
}
+/// The Proportion of the channel value to configure as counterparty's channel reserve,
+/// i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
+///
+/// `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
+/// on their side, at all times.
+/// This ensures that if our counterparty broadcasts a revoked state, we can punish them by
+/// claiming at least this value on chain.
+///
+/// Channel reserve values greater than 30% could be considered highly unreasonable, since that
+/// amount can never be used for payments.
+/// Also, if our selected channel reserve for counterparty and counterparty's selected
+/// channel reserve for us sum up to equal or greater than channel value, channel negotiations
+/// will fail.
+///
+/// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
+/// other than the default value.
+///
+/// Default value: 1% of channel value, i.e., configured as 10,000 millionths.
+/// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
+/// as 1000 sats instead, which is a safe implementation-specific lower bound.
+/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
+/// instead, although channel negotiations will fail in that case.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this_ptr: &ChannelHandshakeConfig) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().their_channel_reserve_proportional_millionths;
+ *inner_val
+}
+/// The Proportion of the channel value to configure as counterparty's channel reserve,
+/// i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
+///
+/// `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
+/// on their side, at all times.
+/// This ensures that if our counterparty broadcasts a revoked state, we can punish them by
+/// claiming at least this value on chain.
+///
+/// Channel reserve values greater than 30% could be considered highly unreasonable, since that
+/// amount can never be used for payments.
+/// Also, if our selected channel reserve for counterparty and counterparty's selected
+/// channel reserve for us sum up to equal or greater than channel value, channel negotiations
+/// will fail.
+///
+/// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
+/// other than the default value.
+///
+/// Default value: 1% of channel value, i.e., configured as 10,000 millionths.
+/// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
+/// as 1000 sats instead, which is a safe implementation-specific lower bound.
+/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
+/// instead, although channel negotiations will fail in that case.
+#[no_mangle]
+pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = 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, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool) -> ChannelHandshakeConfig {
+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, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32) -> ChannelHandshakeConfig {
ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
minimum_depth: minimum_depth_arg,
our_to_self_delay: our_to_self_delay_arg,
negotiate_scid_privacy: negotiate_scid_privacy_arg,
announced_channel: announced_channel_arg,
commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
+ their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg,
}), is_owned: true }
}
impl Clone for ChannelHandshakeConfig {
/// 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,
+ payment_failed_permanently: bool,
/// Any failure information conveyed via the Onion return packet by a node along the failed
/// payment route.
///
path: local_path_nonref,
}
},
- Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
+ Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
let mut payment_id_nonref = (*payment_id).clone();
let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
let mut payment_hash_nonref = (*payment_hash).clone();
- let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
+ let mut payment_failed_permanently_nonref = (*payment_failed_permanently).clone();
let mut network_update_nonref = (*network_update).clone();
let mut local_network_update_nonref = { /* network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; { } if network_update_nonref_opt.is_none() { None } else { Some({ network_update_nonref_opt.take().into_native() }) } };
let mut all_paths_failed_nonref = (*all_paths_failed).clone();
nativeEvent::PaymentPathFailed {
payment_id: local_payment_id_nonref,
payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
- rejected_by_dest: rejected_by_dest_nonref,
+ payment_failed_permanently: payment_failed_permanently_nonref,
network_update: local_network_update_nonref,
all_paths_failed: all_paths_failed_nonref,
path: local_path_nonref,
path: local_path,
}
},
- Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
+ Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
let mut local_network_update = { /* network_update*/ let network_update_opt = network_update; { } if network_update_opt.is_none() { None } else { Some({ network_update_opt.take().into_native() }) } };
let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
nativeEvent::PaymentPathFailed {
payment_id: local_payment_id,
payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
- rejected_by_dest: rejected_by_dest,
+ payment_failed_permanently: payment_failed_permanently,
network_update: local_network_update,
all_paths_failed: all_paths_failed,
path: local_path,
path: local_path_nonref.into(),
}
},
- nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
+ nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
let mut payment_id_nonref = (*payment_id).clone();
let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } };
let mut payment_hash_nonref = (*payment_hash).clone();
- let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
+ let mut payment_failed_permanently_nonref = (*payment_failed_permanently).clone();
let mut network_update_nonref = (*network_update).clone();
let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) };
let mut all_paths_failed_nonref = (*all_paths_failed).clone();
Event::PaymentPathFailed {
payment_id: local_payment_id_nonref,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
- rejected_by_dest: rejected_by_dest_nonref,
+ payment_failed_permanently: payment_failed_permanently_nonref,
network_update: local_network_update_nonref,
all_paths_failed: all_paths_failed_nonref,
path: local_path_nonref.into(),
path: local_path.into(),
}
},
- nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
+ nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } };
let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update.unwrap()) }) };
let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
Event::PaymentPathFailed {
payment_id: local_payment_id,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
- rejected_by_dest: rejected_by_dest,
+ payment_failed_permanently: payment_failed_permanently,
network_update: local_network_update,
all_paths_failed: all_paths_failed,
path: local_path.into(),
}
#[no_mangle]
/// Utility method to constructs a new PaymentPathFailed-variant Event
-pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event {
+pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event {
Event::PaymentPathFailed {
payment_id,
payment_hash,
- rejected_by_dest,
+ payment_failed_permanently,
network_update,
all_paths_failed,
path,
/// The message which should be sent.
msg: crate::lightning::ln::msgs::ChannelReestablish,
},
+ /// Used to send a channel_announcement and channel_update to a specific peer, likely on
+ /// initial connection to ensure our peers know about our channels.
+ SendChannelAnnouncement {
+ /// The node_id of the node which should receive this message
+ node_id: crate::c_types::PublicKey,
+ /// The channel_announcement which should be sent.
+ msg: crate::lightning::ln::msgs::ChannelAnnouncement,
+ /// The followup channel_update which should be sent.
+ update_msg: crate::lightning::ln::msgs::ChannelUpdate,
+ },
/// Used to indicate that a channel_announcement and channel_update should be broadcast to all
/// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
///
- /// Note that after doing so, you very likely (unless you did so very recently) want to call
- /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
- /// This ensures that any nodes which see our channel_announcement also have a relevant
+ /// Note that after doing so, you very likely (unless you did so very recently) want to
+ /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This
+ /// ensures that any nodes which see our channel_announcement also have a relevant
/// node_announcement, including relevant feature flags which may be important for routing
/// through or to us.
+ ///
+ /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement
BroadcastChannelAnnouncement {
/// The channel_announcement which should be sent.
msg: crate::lightning::ln::msgs::ChannelAnnouncement,
/// The followup channel_update which should be sent.
update_msg: crate::lightning::ln::msgs::ChannelUpdate,
},
- /// Used to indicate that a node_announcement should be broadcast to all peers.
- BroadcastNodeAnnouncement {
- /// The node_announcement which should be sent.
- msg: crate::lightning::ln::msgs::NodeAnnouncement,
- },
/// Used to indicate that a channel_update should be broadcast to all peers.
BroadcastChannelUpdate {
/// The channel_update which should be sent.
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
}
},
- MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
+ MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
let mut msg_nonref = (*msg).clone();
let mut update_msg_nonref = (*update_msg).clone();
- nativeMessageSendEvent::BroadcastChannelAnnouncement {
+ nativeMessageSendEvent::SendChannelAnnouncement {
+ node_id: node_id_nonref.into_rust(),
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
}
},
- MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
+ MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
let mut msg_nonref = (*msg).clone();
- nativeMessageSendEvent::BroadcastNodeAnnouncement {
+ let mut update_msg_nonref = (*update_msg).clone();
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
}
},
MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
msg: *unsafe { Box::from_raw(msg.take_inner()) },
}
},
- MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
- nativeMessageSendEvent::BroadcastChannelAnnouncement {
+ MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
+ nativeMessageSendEvent::SendChannelAnnouncement {
+ node_id: node_id.into_rust(),
msg: *unsafe { Box::from_raw(msg.take_inner()) },
update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
}
},
- MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
- nativeMessageSendEvent::BroadcastNodeAnnouncement {
+ MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {
msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
}
},
MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
+ nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
let mut msg_nonref = (*msg).clone();
let mut update_msg_nonref = (*update_msg).clone();
- MessageSendEvent::BroadcastChannelAnnouncement {
+ MessageSendEvent::SendChannelAnnouncement {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
let mut msg_nonref = (*msg).clone();
- MessageSendEvent::BroadcastNodeAnnouncement {
- msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ let mut update_msg_nonref = (*update_msg).clone();
+ MessageSendEvent::BroadcastChannelAnnouncement {
+ msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
}
},
nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
- MessageSendEvent::BroadcastChannelAnnouncement {
+ nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
+ MessageSendEvent::SendChannelAnnouncement {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
- MessageSendEvent::BroadcastNodeAnnouncement {
- msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
+ MessageSendEvent::BroadcastChannelAnnouncement {
+ msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
}
},
nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
}
}
#[no_mangle]
-/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
-pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
- MessageSendEvent::BroadcastChannelAnnouncement {
+/// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent
+pub extern "C" fn MessageSendEvent_send_channel_announcement(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
+ MessageSendEvent::SendChannelAnnouncement {
+ node_id,
msg,
update_msg,
}
}
#[no_mangle]
-/// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
-pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent {
- MessageSendEvent::BroadcastNodeAnnouncement {
+/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
+pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
+ MessageSendEvent::BroadcastChannelAnnouncement {
msg,
+ update_msg,
}
}
#[no_mangle]
}
}
}
+/// A trait indicating an object may generate onion messages to send
+#[repr(C)]
+pub struct OnionMessageProvider {
+ /// 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 next pending onion message for the peer with the given node id.
+ ///
+ /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ #[must_use]
+ pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
+ /// 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for OnionMessageProvider {}
+unsafe impl Sync for OnionMessageProvider {}
+#[no_mangle]
+pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider {
+ OnionMessageProvider {
+ this_arg: orig.this_arg,
+ next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
+ free: Clone::clone(&orig.free),
+ }
+}
+
+use lightning::util::events::OnionMessageProvider as rustOnionMessageProvider;
+impl rustOnionMessageProvider for OnionMessageProvider {
+ fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
+ let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
+ let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
+ local_ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for OnionMessageProvider {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { }
+impl Drop for OnionMessageProvider {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
/// A trait indicating an object may generate events.
///
/// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
///
/// # Requirements
///
-/// See [`process_pending_events`] for requirements around event processing.
-///
/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
-/// event since the last invocation. The handler must either act upon the event immediately
-/// or preserve it for later handling.
+/// event since the last invocation.
+///
+/// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
+/// and replay any unhandled events on startup. An [`Event`] is considered handled when
+/// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
+/// relevant changes to disk *before* returning.
+///
+/// Further, because an application may crash between an [`Event`] being handled and the
+/// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
+/// effect, [`Event`]s may be replayed.
///
/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
/// consult the provider's documentation on the implication of processing events and how a handler
pub this_arg: *mut c_void,
/// Processes any events generated since the last call using the given event handler.
///
- /// Subsequent calls must only process new events. However, handlers must be capable of handling
- /// duplicate events across process restarts. This may occur if the provider was recovered from
- /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ /// See the trait-level documentation for requirements.
pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::util::events::EventHandler),
/// 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 mod message_signing;
pub mod invoice;
pub mod persist;
+pub mod wakers;
pub mod logger;
pub mod config;
mod fuzz_wrappers {
#[cfg(feature="no-std")]
use alloc::{vec::Vec, boxed::Box};
-/// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`MultiThreadedLockableScore`] to disk.
+/// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
#[repr(C)]
pub struct Persister {
/// An opaque pointer which is passed to your function implementations as an argument.
/// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
#[must_use]
pub persist_graph: extern "C" fn (this_arg: *const c_void, network_graph: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::derived::CResult_NoneErrorZ,
- /// Persist the given [`MultiThreadedLockableScore`] to disk, returning an error if persistence failed.
+ /// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
#[must_use]
- pub persist_scorer: extern "C" fn (this_arg: *const c_void, scorer: &crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::c_types::derived::CResult_NoneErrorZ,
+ pub persist_scorer: extern "C" fn (this_arg: *const c_void, scorer: &crate::lightning::routing::scoring::WriteableScore) -> crate::c_types::derived::CResult_NoneErrorZ,
/// 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<extern "C" fn(this_arg: *mut c_void)>,
}
use lightning::util::persist::Persister as rustPersister;
-impl<'a> rustPersister<'a, crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::Score> for Persister {
+impl<'a> rustPersister<'a, crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore> for Persister {
fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>) -> Result<(), lightning::io::Error> {
let mut ret = (self.persist_manager)(self.this_arg, &crate::lightning::ln::channelmanager::ChannelManager { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_manager as *const lightning::ln::channelmanager::ChannelManager<_, _, _, _, _, _, >) as *mut _) }, is_owned: false });
let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })};
let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })};
local_ret
}
- fn persist_scorer(&self, mut scorer: &lightning::routing::scoring::MultiThreadedLockableScore<crate::lightning::routing::scoring::Score>) -> Result<(), lightning::io::Error> {
- let mut ret = (self.persist_scorer)(self.this_arg, &crate::lightning::routing::scoring::MultiThreadedLockableScore { inner: unsafe { ObjOps::nonnull_ptr_to_inner((scorer as *const lightning::routing::scoring::MultiThreadedLockableScore<_, >) as *mut _) }, is_owned: false });
+ fn persist_scorer(&self, mut scorer: &crate::lightning::routing::scoring::WriteableScore) -> Result<(), lightning::io::Error> {
+ let mut ret = (self.persist_scorer)(self.this_arg, scorer);
let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })};
local_ret
}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history and in the source files from which this was generated.
+//
+// This file is licensed under the license available in the LICENSE or LICENSE.md
+// file in the root of this repository or, if no such file exists, the same
+// license as that which applies to the original source files from which this
+// source was automatically generated.
+
+//! Utilities which allow users to block on some future notification from LDK. These are
+//! specifically used by [`ChannelManager`] to allow waiting until the [`ChannelManager`] needs to
+//! be re-persisted.
+//!
+//! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+/// A callback which is called when a [`Future`] completes.
+///
+/// Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
+/// taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`]
+/// instead.
+///
+/// Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
+/// futures when they receive a wake, rather than immediately executing them.
+#[repr(C)]
+pub struct FutureCallback {
+ /// 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,
+ /// The method which is called.
+ pub call: extern "C" fn (this_arg: *const 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for FutureCallback {}
+unsafe impl Sync for FutureCallback {}
+#[no_mangle]
+pub(crate) extern "C" fn FutureCallback_clone_fields(orig: &FutureCallback) -> FutureCallback {
+ FutureCallback {
+ this_arg: orig.this_arg,
+ call: Clone::clone(&orig.call),
+ free: Clone::clone(&orig.free),
+ }
+}
+
+use lightning::util::wakers::FutureCallback as rustFutureCallback;
+impl rustFutureCallback for FutureCallback {
+ fn call(&self) {
+ (self.call)(self.this_arg)
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for FutureCallback {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn FutureCallback_free(this_ptr: FutureCallback) { }
+impl Drop for FutureCallback {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
+
+use lightning::util::wakers::Future as nativeFutureImport;
+pub(crate) type nativeFuture = nativeFutureImport;
+
+/// A simple future which can complete once, and calls some callback(s) when it does so.
+#[must_use]
+#[repr(C)]
+pub struct Future {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeFuture,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 Future {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeFuture>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the Future, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn Future_free(this_obj: Future) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Future_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFuture); }
+}
+#[allow(unused)]
+impl Future {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeFuture {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFuture {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeFuture {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Registers a callback to be called upon completion of this future. If the future has already
+/// completed, the callback will be called immediately.
+#[no_mangle]
+pub extern "C" fn Future_register_callback_fn(this_arg: &crate::lightning::util::wakers::Future, mut callback: crate::lightning::util::wakers::FutureCallback) {
+ unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.register_callback_fn(callback)
+}
+
+mod std_future {
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+}
/// [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph
/// [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph
/// [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable
-///
-/// Note that scorer (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning::util::persist::Persister, mut event_handler: crate::lightning::util::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut gossip_sync: crate::lightning_background_processor::GossipSync, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger, mut scorer: crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::lightning_background_processor::BackgroundProcessor {
- let mut local_scorer = if scorer.inner.is_null() { None } else { Some( { scorer.get_native_ref() }) };
+pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning::util::persist::Persister, mut event_handler: crate::lightning::util::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut gossip_sync: crate::lightning_background_processor::GossipSync, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger, mut scorer: crate::c_types::derived::COption_WriteableScoreZ) -> crate::lightning_background_processor::BackgroundProcessor {
+ let mut local_scorer = { /* scorer*/ let scorer_opt = scorer; { } if scorer_opt.is_none() { None } else { Some({ scorer_opt.take() }) } };
let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.get_native_ref(), gossip_sync.into_native(), peer_manager.get_native_ref(), logger, local_scorer);
crate::lightning_background_processor::BackgroundProcessor { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice {
orig.clone()
}
+/// Checks if two Invoices contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport;
pub(crate) type nativeSignedRawInvoice = nativeSignedRawInvoiceImport;
pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice {
orig.clone()
}
+/// Checks if two SignedRawInvoices contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::RawInvoice as nativeRawInvoiceImport;
pub(crate) type nativeRawInvoice = nativeRawInvoiceImport;
pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice {
orig.clone()
}
+/// Checks if two RawInvoices contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::RawDataPart as nativeRawDataPartImport;
pub(crate) type nativeRawDataPart = nativeRawDataPartImport;
pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart {
orig.clone()
}
+/// Checks if two RawDataParts contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn RawDataPart_hash(o: &RawDataPart) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::PositiveTimestamp as nativePositiveTimestampImport;
pub(crate) type nativePositiveTimestamp = nativePositiveTimestampImport;
pub extern "C" fn PositiveTimestamp_clone(orig: &PositiveTimestamp) -> PositiveTimestamp {
orig.clone()
}
+/// Checks if two PositiveTimestamps contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn PositiveTimestamp_hash(o: &PositiveTimestamp) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
/// SI prefixes for the human readable part
#[derive(Clone)]
#[must_use]
pub extern "C" fn SiPrefix_eq(a: &SiPrefix, b: &SiPrefix) -> bool {
if &a.to_native() == &b.to_native() { true } else { false }
}
+/// Checks if two SiPrefixs contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn SiPrefix_hash(o: &SiPrefix) -> u64 {
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
/// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
/// This is effectively 10^12 * the prefix multiplier
#[must_use]
orig.clone()
}
/// Checks if two InvoiceSignatures contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two InvoiceSignatures contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
/// Two objects with NULL inner values will be considered "equal" here.
#[no_mangle]
/// The hash of the `RawInvoice` that was signed.
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_hash(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> *const [u8; 32] {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.hash();
+pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> *const [u8; 32] {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
ret
}
ret
}
-/// Calculate the hash of the encoded `RawInvoice`
+/// Calculate the hash of the encoded `RawInvoice` which should be signed.
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.hash();
+pub extern "C" fn RawInvoice_signable_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
crate::c_types::ThirtyTwoBytes { data: ret }
}
//! and payee using information provided by the payer and from the payee's [`Invoice`], when
//! applicable.
//!
-//! [`InvoicePayer`] is parameterized by a [`LockableScore`], which it uses for scoring failed and
-//! successful payment paths upon receiving [`Event::PaymentPathFailed`] and
-//! [`Event::PaymentPathSuccessful`] events, respectively.
+//! [`InvoicePayer`] uses its [`Router`] parameterization for optionally notifying scorers upon
+//! receiving the [`Event::PaymentPathFailed`] and [`Event::PaymentPathSuccessful`] events.
+//! It also does the same for payment probe failure and success events using [`Event::ProbeFailed`]
+//! and [`Event::ProbeSuccessful`].
//!
//! [`InvoicePayer`] is capable of retrying failed payments. It accomplishes this by implementing
//! [`EventHandler`] which decorates a user-provided handler. It will intercept any
//! # extern crate lightning_invoice;
//! # extern crate secp256k1;
//! #
-//! # #[cfg(feature = \"no-std\")]
-//! # extern crate core2;
-//! #
+//! # use lightning::io;
//! # use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
//! # use lightning::ln::channelmanager::{ChannelDetails, PaymentId, PaymentSendFailure};
//! # use lightning::ln::msgs::LightningError;
//! # use lightning::util::logger::{Logger, Record};
//! # use lightning::util::ser::{Writeable, Writer};
//! # use lightning_invoice::Invoice;
-//! # use lightning_invoice::payment::{InvoicePayer, Payer, Retry, Router};
+//! # use lightning_invoice::payment::{InFlightHtlcs, InvoicePayer, Payer, Retry, Router};
//! # use secp256k1::PublicKey;
//! # use std::cell::RefCell;
//! # use std::ops::Deref;
//! #
-//! # #[cfg(not(feature = \"std\"))]
-//! # use core2::io;
-//! # #[cfg(feature = \"std\")]
-//! # use std::io;
-//! #
//! # struct FakeEventProvider {}
//! # impl EventsProvider for FakeEventProvider {
//! # fn process_pending_events<H: Deref>(&self, handler: H) where H::Target: EventHandler {}
//! # }
//! #
//! # struct FakeRouter {}
-//! # impl<S: Score> Router<S> for FakeRouter {
+//! # impl Router for FakeRouter {
//! # fn find_route(
//! # &self, payer: &PublicKey, params: &RouteParameters, payment_hash: &PaymentHash,
-//! # first_hops: Option<&[&ChannelDetails]>, scorer: &S
+//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
//! # ) -> Result<Route, LightningError> { unimplemented!() }
+//! #
+//! # fn notify_payment_path_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
+//! # fn notify_payment_path_successful(&self, path: &[&RouteHop]) { unimplemented!() }
+//! # fn notify_payment_probe_successful(&self, path: &[&RouteHop]) { unimplemented!() }
+//! # fn notify_payment_probe_failed(&self, path: &[&RouteHop], short_channel_id: u64) { unimplemented!() }
//! # }
//! #
//! # struct FakeScorer {}
//! # let router = FakeRouter {};
//! # let scorer = RefCell::new(FakeScorer {});
//! # let logger = FakeLogger {};
-//! let invoice_payer = InvoicePayer::new(&payer, router, &scorer, &logger, event_handler, Retry::Attempts(2));
+//! let invoice_payer = InvoicePayer::new(&payer, router, &logger, event_handler, Retry::Attempts(2));
//!
//! let invoice = \"...\";
//! if let Ok(invoice) = invoice.parse::<Invoice>() {
use lightning_invoice::payment::InvoicePayer as nativeInvoicePayerImport;
-pub(crate) type nativeInvoicePayer = nativeInvoicePayerImport<crate::lightning_invoice::payment::Payer, crate::lightning::routing::scoring::Score, crate::lightning_invoice::payment::Router, &'static lightning::routing::scoring::MultiThreadedLockableScore<crate::lightning::routing::scoring::Score>, crate::lightning::util::logger::Logger, crate::lightning::util::events::EventHandler>;
+pub(crate) type nativeInvoicePayer = nativeInvoicePayerImport<crate::lightning_invoice::payment::Payer, crate::lightning_invoice::payment::Router, crate::lightning::util::logger::Logger, crate::lightning::util::events::EventHandler>;
/// A utility for paying [`Invoice`]s and sending spontaneous payments.
///
///
/// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
- pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ,
+ pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning_invoice::payment::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ,
+ /// Lets the router know that payment through a specific path has failed.
+ pub notify_payment_path_failed: extern "C" fn (this_arg: *const c_void, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: u64),
+ /// Lets the router know that payment through a specific path was successful.
+ pub notify_payment_path_successful: extern "C" fn (this_arg: *const c_void, path: crate::c_types::derived::CVec_RouteHopZ),
+ /// Lets the router know that a payment probe was successful.
+ pub notify_payment_probe_successful: extern "C" fn (this_arg: *const c_void, path: crate::c_types::derived::CVec_RouteHopZ),
+ /// Lets the router know that a payment probe failed.
+ pub notify_payment_probe_failed: extern "C" fn (this_arg: *const c_void, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: u64),
/// 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<extern "C" fn(this_arg: *mut c_void)>,
Router {
this_arg: orig.this_arg,
find_route: Clone::clone(&orig.find_route),
+ notify_payment_path_failed: Clone::clone(&orig.notify_payment_path_failed),
+ notify_payment_path_successful: Clone::clone(&orig.notify_payment_path_successful),
+ notify_payment_probe_successful: Clone::clone(&orig.notify_payment_probe_successful),
+ notify_payment_probe_failed: Clone::clone(&orig.notify_payment_probe_failed),
free: Clone::clone(&orig.free),
}
}
use lightning_invoice::payment::Router as rustRouter;
-impl rustRouter<crate::lightning::routing::scoring::Score> for Router {
- fn find_route(&self, mut payer: &secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut payment_hash: &lightning::ln::PaymentHash, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut scorer: &crate::lightning::routing::scoring::Score) -> Result<lightning::routing::router::Route, lightning::ln::msgs::LightningError> {
+impl rustRouter for Router {
+ fn find_route(&self, mut payer: &secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut payment_hash: &lightning::ln::PaymentHash, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning_invoice::payment::InFlightHtlcs) -> Result<lightning::routing::router::Route, lightning::ln::msgs::LightningError> {
let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base;
- let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, &payment_hash.0, local_first_hops, scorer);
+ let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, &payment_hash.0, local_first_hops, crate::lightning_invoice::payment::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true });
let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
local_ret
}
+ fn notify_payment_path_failed(&self, mut path: &[&lightning::routing::router::RouteHop], mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); };
+ (self.notify_payment_path_failed)(self.this_arg, local_path.into(), short_channel_id)
+ }
+ fn notify_payment_path_successful(&self, mut path: &[&lightning::routing::router::RouteHop]) {
+ let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); };
+ (self.notify_payment_path_successful)(self.this_arg, local_path.into())
+ }
+ fn notify_payment_probe_successful(&self, mut path: &[&lightning::routing::router::RouteHop]) {
+ let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); };
+ (self.notify_payment_probe_successful)(self.this_arg, local_path.into())
+ }
+ fn notify_payment_probe_failed(&self, mut path: &[&lightning::routing::router::RouteHop], mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); };
+ (self.notify_payment_probe_failed)(self.this_arg, local_path.into(), short_channel_id)
+ }
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
/// `retry` has been exceeded for a given [`Invoice`].
#[must_use]
#[no_mangle]
-pub extern "C" fn InvoicePayer_new(mut payer: crate::lightning_invoice::payment::Payer, mut router: crate::lightning_invoice::payment::Router, scorer: &crate::lightning::routing::scoring::MultiThreadedLockableScore, mut logger: crate::lightning::util::logger::Logger, mut event_handler: crate::lightning::util::events::EventHandler, mut retry: crate::lightning_invoice::payment::Retry) -> crate::lightning_invoice::payment::InvoicePayer {
- let mut ret = lightning_invoice::payment::InvoicePayer::new(payer, router, scorer.get_native_ref(), logger, event_handler, retry.into_native());
+pub extern "C" fn InvoicePayer_new(mut payer: crate::lightning_invoice::payment::Payer, mut router: crate::lightning_invoice::payment::Router, mut logger: crate::lightning::util::logger::Logger, mut event_handler: crate::lightning::util::events::EventHandler, mut retry: crate::lightning_invoice::payment::Retry) -> crate::lightning_invoice::payment::InvoicePayer {
+ let mut ret = lightning_invoice::payment::InvoicePayer::new(payer, router, logger, event_handler, retry.into_native());
crate::lightning_invoice::payment::InvoicePayer { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
<nativeInvoicePayer as lightning::util::events::EventHandler<>>::handle_event(unsafe { &mut *(this_arg as *mut nativeInvoicePayer) }, &event.to_native())
}
+
+use lightning_invoice::payment::InFlightHtlcs as nativeInFlightHtlcsImport;
+pub(crate) type nativeInFlightHtlcs = nativeInFlightHtlcsImport;
+
+/// A map with liquidity value (in msat) keyed by a short channel id and the direction the HTLC
+/// is traveling in. The direction boolean is determined by checking if the HTLC source's public
+/// key is less than its destination. See [`InFlightHtlcs::used_liquidity_msat`] for more
+/// details.
+#[must_use]
+#[repr(C)]
+pub struct InFlightHtlcs {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeInFlightHtlcs,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust 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 InFlightHtlcs {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeInFlightHtlcs>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn InFlightHtlcs_free(this_obj: InFlightHtlcs) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn InFlightHtlcs_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInFlightHtlcs); }
+}
+#[allow(unused)]
+impl InFlightHtlcs {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeInFlightHtlcs {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInFlightHtlcs {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeInFlightHtlcs {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Returns liquidity in msat given the public key of the HTLC source, target, and short channel
+/// id.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InFlightHtlcs_used_liquidity_msat(this_arg: &crate::lightning_invoice::payment::InFlightHtlcs, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut channel_scid: u64) -> crate::c_types::derived::COption_u64Z {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.used_liquidity_msat(source.get_native_ref(), target.get_native_ref(), channel_scid);
+ let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
+ local_ret
+}
+
+#[no_mangle]
+/// Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read
+pub extern "C" fn InFlightHtlcs_write(obj: &crate::lightning_invoice::payment::InFlightHtlcs) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn InFlightHtlcs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInFlightHtlcs) })
+}
+#[no_mangle]
+/// Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write
+pub extern "C" fn InFlightHtlcs_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InFlightHtlcsDecodeErrorZ {
+ let res: Result<lightning_invoice::payment::InFlightHtlcs, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::payment::InFlightHtlcs { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
use lightning_invoice::utils::DefaultRouter as nativeDefaultRouterImport;
-pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, crate::lightning::util::logger::Logger>;
+pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::LockableScore>;
/// A [`Router`] implemented using [`find_route`].
#[must_use]
/// `random_seed_bytes`.
#[must_use]
#[no_mangle]
-pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes) -> crate::lightning_invoice::utils::DefaultRouter {
- let mut ret = lightning_invoice::utils::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data);
+pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes, mut scorer: crate::lightning::routing::scoring::LockableScore) -> crate::lightning_invoice::utils::DefaultRouter {
+ let mut ret = lightning_invoice::utils::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data, scorer);
crate::lightning_invoice::utils::DefaultRouter { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
free: None,
find_route: DefaultRouter_Router_find_route,
+ notify_payment_path_failed: DefaultRouter_Router_notify_payment_path_failed,
+ notify_payment_path_successful: DefaultRouter_Router_notify_payment_path_successful,
+ notify_payment_probe_successful: DefaultRouter_Router_notify_payment_probe_successful,
+ notify_payment_probe_failed: DefaultRouter_Router_notify_payment_probe_failed,
}
}
#[must_use]
-extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, params: &crate::lightning::routing::router::RouteParameters, _payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
+extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning_invoice::payment::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
let mut local_first_hops_base = if first_hops == core::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( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
- let mut ret = <nativeDefaultRouter as lightning_invoice::payment::Router<_>>::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), params.get_native_ref(), &::lightning::ln::PaymentHash(unsafe { *_payment_hash }), local_first_hops, scorer);
+ let mut ret = <nativeDefaultRouter as lightning_invoice::payment::Router<>>::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), &::lightning::ln::PaymentHash(unsafe { *payment_hash }), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) });
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
}
+extern "C" fn DefaultRouter_Router_notify_payment_path_failed(this_arg: *const c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeDefaultRouter as lightning_invoice::payment::Router<>>::notify_payment_path_failed(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &local_path[..], short_channel_id)
+}
+extern "C" fn DefaultRouter_Router_notify_payment_path_successful(this_arg: *const c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeDefaultRouter as lightning_invoice::payment::Router<>>::notify_payment_path_successful(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &local_path[..])
+}
+extern "C" fn DefaultRouter_Router_notify_payment_probe_successful(this_arg: *const c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeDefaultRouter as lightning_invoice::payment::Router<>>::notify_payment_probe_successful(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &local_path[..])
+}
+extern "C" fn DefaultRouter_Router_notify_payment_probe_failed(this_arg: *const c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeDefaultRouter as lightning_invoice::payment::Router<>>::notify_payment_probe_failed(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &local_path[..], short_channel_id)
+}
use crate::lightning::ln::channelmanager::nativeChannelManager as nativeChannelManager;
use crate::lightning::ln::channelmanager::ChannelManager;