typedef struct LDKCVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_u32TxOutZZ;
+typedef struct LDKPublicKey {
+ uint8_t compressed_form[33];
+} LDKPublicKey;
+
+
+
+/**
+ * One counterparty's public keys which do not change over the life of a channel.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelPublicKeys {
+ /**
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeChannelPublicKeys *inner;
+ bool is_owned;
+} LDKChannelPublicKeys;
+
typedef struct LDKC2TupleTempl_u64__u64 {
uint64_t a;
uint64_t b;
struct LDKCVecTempl_Signature b;
} LDKC2TupleTempl_Signature__CVecTempl_Signature;
-typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ;
-
-typedef struct LDKCVecTempl_Signature LDKCVec_SignatureZ;
-
typedef union LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 {
struct LDKC2TupleTempl_Signature__CVecTempl_Signature *result;
uint8_t *err;
typedef struct LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ;
+
+
+/**
+ * This class tracks the per-transaction information needed to build a commitment transaction and to
+ * actually build it and sign. It is used for holder transactions that we sign only when needed
+ * and for transactions we sign for the counterparty.
+ *
+ * This class can be used inside a signer implementation to generate a signature given the relevant
+ * secret key.
+ */
+typedef struct MUST_USE_STRUCT LDKCommitmentTransaction {
+ /**
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeCommitmentTransaction *inner;
+ bool is_owned;
+} LDKCommitmentTransaction;
+
typedef union LDKCResultPtr_Signature__u8 {
struct LDKSignature *result;
uint8_t *err;
typedef struct LDKCResultTempl_Signature__u8 LDKCResult_SignatureNoneZ;
-typedef union LDKCResultPtr_CVecTempl_Signature_____u8 {
- struct LDKCVecTempl_Signature *result;
- uint8_t *err;
-} LDKCResultPtr_CVecTempl_Signature_____u8;
-
-typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 {
- union LDKCResultPtr_CVecTempl_Signature_____u8 contents;
- bool result_ok;
-} LDKCResultTempl_CVecTempl_Signature_____u8;
-
-typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 LDKCResult_CVec_SignatureZNoneZ;
-
-/**
- * A Rust str object, ie a reference to a UTF8-valid string.
- * This is *not* null-terminated so cannot be used directly as a C string!
- */
-typedef struct LDKStr {
- const uint8_t *chars;
- uintptr_t len;
-} LDKStr;
-
-/**
- * Indicates an error on the client's part (usually some variant of attempting to use too-low or
- * too-high values)
- */
-typedef enum LDKAPIError_Tag {
- /**
- * Indicates the API was wholly misused (see err for more). Cases where these can be returned
- * are documented, but generally indicates some precondition of a function was violated.
- */
- LDKAPIError_APIMisuseError,
- /**
- * Due to a high feerate, we were unable to complete the request.
- * For example, this may be returned if the feerate implies we cannot open a channel at the
- * requested value, but opening a larger channel would succeed.
- */
- LDKAPIError_FeeRateTooHigh,
- /**
- * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
- * too-many-hops, etc).
- */
- LDKAPIError_RouteError,
- /**
- * We were unable to complete the request as the Channel required to do so is unable to
- * complete the request (or was not found). This can take many forms, including disconnected
- * peer, channel at capacity, channel shutting down, etc.
- */
- LDKAPIError_ChannelUnavailable,
- /**
- * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
- * attempted action to fail.
- */
- LDKAPIError_MonitorUpdateFailed,
- /**
- * Must be last for serialization purposes
- */
- LDKAPIError_Sentinel,
-} LDKAPIError_Tag;
-
-typedef struct LDKAPIError_LDKAPIMisuseError_Body {
- LDKCVec_u8Z err;
-} LDKAPIError_LDKAPIMisuseError_Body;
-
-typedef struct LDKAPIError_LDKFeeRateTooHigh_Body {
- LDKCVec_u8Z err;
- uint32_t feerate;
-} LDKAPIError_LDKFeeRateTooHigh_Body;
-
-typedef struct LDKAPIError_LDKRouteError_Body {
- struct LDKStr err;
-} LDKAPIError_LDKRouteError_Body;
-
-typedef struct LDKAPIError_LDKChannelUnavailable_Body {
- LDKCVec_u8Z err;
-} LDKAPIError_LDKChannelUnavailable_Body;
-
-typedef struct MUST_USE_STRUCT LDKAPIError {
- LDKAPIError_Tag tag;
- union {
- LDKAPIError_LDKAPIMisuseError_Body api_misuse_error;
- LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
- LDKAPIError_LDKRouteError_Body route_error;
- LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
- };
-} LDKAPIError;
-
-typedef union LDKCResultPtr_u8__APIError {
- uint8_t *result;
- struct LDKAPIError *err;
-} LDKCResultPtr_u8__APIError;
-
-typedef struct LDKCResultTempl_u8__APIError {
- union LDKCResultPtr_u8__APIError contents;
- bool result_ok;
-} LDKCResultTempl_u8__APIError;
-
-typedef struct LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ;
-
/**
- * If a payment fails to send, it can be in one of several states. This enum is returned as the
- * Err() type describing which state the payment is in, see the description of individual enum
- * states for more.
+ * Information needed to build and sign a holder's commitment transaction.
+ *
+ * The transaction is only signed once we are ready to broadcast.
*/
-typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
+typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativePaymentSendFailure *inner;
+ LDKnativeHolderCommitmentTransaction *inner;
bool is_owned;
-} LDKPaymentSendFailure;
+} LDKHolderCommitmentTransaction;
-typedef union LDKCResultPtr_u8__PaymentSendFailure {
- uint8_t *result;
- struct LDKPaymentSendFailure *err;
-} LDKCResultPtr_u8__PaymentSendFailure;
+typedef union LDKCResultPtr_CVecTempl_Signature_____u8 {
+ struct LDKCVecTempl_Signature *result;
+ uint8_t *err;
+} LDKCResultPtr_CVecTempl_Signature_____u8;
-typedef struct LDKCResultTempl_u8__PaymentSendFailure {
- union LDKCResultPtr_u8__PaymentSendFailure contents;
+typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 {
+ union LDKCResultPtr_CVecTempl_Signature_____u8 contents;
bool result_ok;
-} LDKCResultTempl_u8__PaymentSendFailure;
+} LDKCResultTempl_CVecTempl_Signature_____u8;
-typedef struct LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ;
+typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 LDKCResult_CVec_SignatureZNoneZ;
/**
- * A channel_announcement message to be sent or received from a peer
+ * Information about an HTLC as it appears in a commitment transaction
*/
-typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
+typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelAnnouncement *inner;
+ LDKnativeHTLCOutputInCommitment *inner;
bool is_owned;
-} LDKChannelAnnouncement;
+} LDKHTLCOutputInCommitment;
/**
- * A channel_update message to be sent or received from a peer
+ * The unsigned part of a channel_announcement
*/
-typedef struct MUST_USE_STRUCT LDKChannelUpdate {
+typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelUpdate *inner;
+ LDKnativeUnsignedChannelAnnouncement *inner;
bool is_owned;
-} LDKChannelUpdate;
-
-typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
- struct LDKChannelAnnouncement a;
- struct LDKChannelUpdate b;
- struct LDKChannelUpdate c;
-} LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
-
-typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
+} LDKUnsignedChannelAnnouncement;
/**
- * An Err type for failure to process messages.
+ * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
+ * The fields are organized by holder/counterparty.
+ *
+ * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
+ * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
*/
-typedef struct MUST_USE_STRUCT LDKLightningError {
+typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeLightningError *inner;
+ LDKnativeChannelTransactionParameters *inner;
bool is_owned;
-} LDKLightningError;
-
-typedef union LDKCResultPtr_u8__LightningError {
- uint8_t *result;
- struct LDKLightningError *err;
-} LDKCResultPtr_u8__LightningError;
-
-typedef struct LDKCResultTempl_u8__LightningError {
- union LDKCResultPtr_u8__LightningError contents;
- bool result_ok;
-} LDKCResultTempl_u8__LightningError;
-
-typedef struct LDKCResultTempl_u8__LightningError LDKCResult_NoneLightningErrorZ;
-
-
+} LDKChannelTransactionParameters;
/**
- * Error for PeerManager errors. If you get one of these, you must disconnect the socket and
- * generate no further read_event/write_buffer_space_avail calls for the descriptor, only
- * triggering a single socket_disconnected call (unless it was provided in response to a
- * new_*_connection event, in which case no such socket_disconnected() must be called and the
- * socket silently disconencted).
+ * Set of lightning keys needed to operate a channel as described in BOLT 3.
+ *
+ * Signing services could be implemented on a hardware wallet. In this case,
+ * the current ChannelKeys would be a front-end on top of a communication
+ * channel connected to your secure device and lightning key material wouldn't
+ * reside on a hot server. Nevertheless, a this deployment would still need
+ * to trust the ChannelManager to avoid loss of funds as this latest component
+ * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
+ *
+ * A more secure iteration would be to use hashlock (or payment points) to pair
+ * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
+ * at the price of more state and computation on the hardware wallet side. In the future,
+ * we are looking forward to design such interface.
+ *
+ * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
+ * to act, as liveness and breach reply correctness are always going to be hard requirements
+ * of LN security model, orthogonal of key management issues.
+ *
+ * If you're implementing a custom signer, you almost certainly want to implement
+ * Readable/Writable to serialize out a unique reference to this set of keys so
+ * that you can serialize the full ChannelManager object.
+ *
*/
-typedef struct MUST_USE_STRUCT LDKPeerHandleError {
+typedef struct LDKChannelKeys {
+ void *this_arg;
/**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Gets the per-commitment point for a specific commitment number
+ *
+ * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
*/
- LDKnativePeerHandleError *inner;
- bool is_owned;
-} LDKPeerHandleError;
-
-typedef union LDKCResultPtr_u8__PeerHandleError {
- uint8_t *result;
- struct LDKPeerHandleError *err;
-} LDKCResultPtr_u8__PeerHandleError;
-
-typedef struct LDKCResultTempl_u8__PeerHandleError {
- union LDKCResultPtr_u8__PeerHandleError contents;
- bool result_ok;
-} LDKCResultTempl_u8__PeerHandleError;
-
-typedef struct LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ;
+ struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx);
+ /**
+ * Gets the commitment secret for a specific commitment number as part of the revocation process
+ *
+ * An external signer implementation should error here if the commitment was already signed
+ * and should refuse to sign it in the future.
+ *
+ * May be called more than once for the same index.
+ *
+ * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
+ * TODO: return a Result so we can signal a validation error
+ */
+ struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
+ /**
+ * Gets the holder's channel public keys and basepoints
+ */
+ struct LDKChannelPublicKeys pubkeys;
+ /**
+ * Fill in the pubkeys field as a reference to it will be given to Rust after this returns
+ * Note that this takes a pointer to this object, not the this_ptr like other methods do
+ * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
+ */
+ void (*set_pubkeys)(const struct LDKChannelKeys*);
+ /**
+ * Gets arbitrary identifiers describing the set of keys which are provided back to you in
+ * some SpendableOutputDescriptor types. These should be sufficient to identify this
+ * ChannelKeys object uniquely and lookup or re-derive its keys.
+ */
+ LDKC2Tuple_u64u64Z (*key_derivation_params)(const void *this_arg);
+ /**
+ * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
+ *
+ * Note that if signing fails or is rejected, the channel will be force-closed.
+ */
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *commitment_tx);
+ /**
+ * Create a signature for a holder's commitment transaction. This will only ever be called with
+ * the same commitment_tx (or a copy thereof), though there are currently no guarantees
+ * that it will not be called multiple times.
+ * An external signer implementation should check that the commitment has not been revoked.
+ */
+ LDKCResult_SignatureNoneZ (*sign_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *commitment_tx);
+ /**
+ * Create a signature for each HTLC transaction spending a holder's commitment transaction.
+ *
+ * Unlike sign_holder_commitment, this may be called multiple times with *different*
+ * commitment_tx values. While this will never be called with a revoked
+ * commitment_tx, it is possible that it is called with the second-latest
+ * commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
+ * ChannelMonitor decided to broadcast before it had been updated to the latest.
+ *
+ * Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
+ * commitment_tx.
+ */
+ LDKCResult_CVec_SignatureZNoneZ (*sign_holder_commitment_htlc_transactions)(const void *this_arg, const struct LDKHolderCommitmentTransaction *commitment_tx);
+ /**
+ * Create a signature for the given input in a transaction spending an HTLC or commitment
+ * transaction output when our counterparty broadcasts an old state.
+ *
+ * A justice transaction may claim multiples outputs at the same time if timelocks are
+ * similar, but only a signature for the input at index `input` should be signed for here.
+ * It may be called multiples time for same output(s) if a fee-bump is needed with regards
+ * to an upcoming timelock expiration.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * per_commitment_key is revocation secret which was provided by our counterparty when they
+ * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
+ * not allow the spending of any funds by itself (you need our holder revocation_secret to do
+ * so).
+ *
+ * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
+ * changing the format of the witness script (which is committed to in the BIP 143
+ * signatures).
+ */
+ LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *htlc);
+ /**
+ * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
+ * transaction, either offered or received.
+ *
+ * Such a transaction may claim multiples offered outputs at same time if we know the
+ * preimage for each when we create it, but only the input at index `input` should be
+ * signed for here. It may be called multiple times for same output(s) if a fee-bump is
+ * needed with regards to an upcoming timelock expiration.
+ *
+ * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
+ * outputs.
+ *
+ * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
+ *
+ * Per_commitment_point is the dynamic point corresponding to the channel state
+ * detected onchain. It has been generated by our counterparty and is used to derive
+ * channel state keys, which are then included in the witness script and committed to in the
+ * BIP 143 signature.
+ */
+ LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *htlc);
+ /**
+ * Create a signature for a (proposed) closing transaction.
+ *
+ * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
+ * chosen to forgo their output as dust.
+ */
+ LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx);
+ /**
+ * Signs a channel announcement message with our funding key, proving it comes from one
+ * of the channel participants.
+ *
+ * Note that if this fails or is rejected, the channel will not be publicly announced and
+ * our counterparty may (though likely will not) close the channel on us for violating the
+ * protocol.
+ */
+ LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *msg);
+ /**
+ * Set the counterparty static channel data, including basepoints,
+ * counterparty_selected/holder_selected_contest_delay and funding outpoint.
+ * This is done as soon as the funding outpoint is known. Since these are static channel data,
+ * they MUST NOT be allowed to change to different values once set.
+ *
+ * channel_parameters.is_populated() MUST be true.
+ *
+ * We bind holder_selected_contest_delay late here for API convenience.
+ *
+ * Will be called before any signatures are applied.
+ */
+ void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *channel_parameters);
+ void *(*clone)(const void *this_arg);
+ LDKCVec_u8Z (*write)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKChannelKeys;
/**
- * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin
- * transaction and the transaction creation keys) are trusted.
+ * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
+ * on-chain transactions to ensure no loss of funds occurs.
*
- * See trust() and verify() functions on CommitmentTransaction.
+ * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
+ * information and are actively monitoring the chain.
*
- * This structure implements Deref.
+ * Pending Events or updated HTLCs which have not yet been read out by
+ * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
+ * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
+ * gotten are fully handled before re-serializing the new state.
+ *
+ * Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
+ * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
+ * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
+ * returned block hash and the the current chain and then reconnecting blocks to get to the
+ * best chain) upon deserializing the object!
*/
-typedef struct MUST_USE_STRUCT LDKTrustedCommitmentTransaction {
+typedef struct MUST_USE_STRUCT LDKChannelMonitor {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeTrustedCommitmentTransaction *inner;
+ LDKnativeChannelMonitor *inner;
bool is_owned;
-} LDKTrustedCommitmentTransaction;
+} LDKChannelMonitor;
-typedef union LDKCResultPtr_TrustedCommitmentTransaction__u8 {
- struct LDKTrustedCommitmentTransaction *result;
- uint8_t *err;
-} LDKCResultPtr_TrustedCommitmentTransaction__u8;
+typedef struct LDKC2TupleTempl_ThirtyTwoBytes__ChannelMonitor {
+ struct LDKThirtyTwoBytes a;
+ struct LDKChannelMonitor b;
+} LDKC2TupleTempl_ThirtyTwoBytes__ChannelMonitor;
-typedef struct LDKCResultTempl_TrustedCommitmentTransaction__u8 {
- union LDKCResultPtr_TrustedCommitmentTransaction__u8 contents;
- bool result_ok;
-} LDKCResultTempl_TrustedCommitmentTransaction__u8;
+typedef struct LDKC2TupleTempl_ThirtyTwoBytes__ChannelMonitor LDKC2Tuple_BlockHashChannelMonitorZ;
-typedef struct LDKCResultTempl_TrustedCommitmentTransaction__u8 LDKCResult_TrustedCommitmentTransactionNoneZ;
+typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ;
-typedef struct LDKPublicKey {
- uint8_t compressed_form[33];
-} LDKPublicKey;
+typedef struct LDKCVecTempl_Signature LDKCVec_SignatureZ;
/**
- * When on-chain outputs are created by rust-lightning (which our counterparty is not able to
- * claim at any point in the future) an event is generated which you must track and be able to
- * spend on-chain. The information needed to do this is provided in this enum, including the
- * outpoint describing which txid and output index is available, the full output which exists at
- * that txid/index, and any keys or other information required to sign.
+ * A Rust str object, ie a reference to a UTF8-valid string.
+ * This is *not* null-terminated so cannot be used directly as a C string!
*/
-typedef enum LDKSpendableOutputDescriptor_Tag {
+typedef struct LDKStr {
+ const uint8_t *chars;
+ uintptr_t len;
+} LDKStr;
+
+/**
+ * Indicates an error on the client's part (usually some variant of attempting to use too-low or
+ * too-high values)
+ */
+typedef enum LDKAPIError_Tag {
/**
- * An output to a script which was provided via KeysInterface, thus you should already know
- * how to spend it. No keys are provided as rust-lightning was never given any keys - only the
- * script_pubkey as it appears in the output.
- * These may include outputs from a transaction punishing our counterparty or claiming an HTLC
- * on-chain using the payment preimage or after it has timed out.
+ * Indicates the API was wholly misused (see err for more). Cases where these can be returned
+ * are documented, but generally indicates some precondition of a function was violated.
*/
- LDKSpendableOutputDescriptor_StaticOutput,
+ LDKAPIError_APIMisuseError,
/**
- * An output to a P2WSH script which can be spent with a single signature after a CSV delay.
- *
- * The witness in the spending input should be:
- * <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
- *
- * Note that the nSequence field in the spending input must be set to to_self_delay
- * (which means the transaction is not broadcastable until at least to_self_delay
- * blocks after the outpoint confirms).
- *
- * These are generally the result of a \"revocable\" output to us, spendable only by us unless
- * it is an output from an old state which we broadcast (which should never happen).
- *
- * To derive the delayed_payment key which is used to sign for this input, you must pass the
- * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in
- * ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
- * chan_utils::derive_private_key. The public key can be generated without the secret key
- * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
- * ChannelKeys::pubkeys().
- *
- * To derive the revocation_pubkey provided here (which is used in the witness
- * script generation), you must pass the counterparty revocation_basepoint (which appears in the
- * call to ChannelKeys::ready_channel) and the provided per_commitment point
- * to chan_utils::derive_public_revocation_key.
- *
- * The witness script which is hashed and included in the output script_pubkey may be
- * regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
- * (derived as above), and the to_self_delay contained here to
- * chan_utils::get_revokeable_redeemscript.
+ * Due to a high feerate, we were unable to complete the request.
+ * For example, this may be returned if the feerate implies we cannot open a channel at the
+ * requested value, but opening a larger channel would succeed.
*/
- LDKSpendableOutputDescriptor_DynamicOutputP2WSH,
+ LDKAPIError_FeeRateTooHigh,
/**
- * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
- * corresponds to the public key in ChannelKeys::pubkeys().payment_point).
- * The witness in the spending input, is, thus, simply:
- * <BIP 143 signature> <payment key>
- *
- * These are generally the result of our counterparty having broadcast the current state,
- * allowing us to claim the non-HTLC-encumbered outputs immediately.
+ * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route,
+ * too-many-hops, etc).
*/
- LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment,
+ LDKAPIError_RouteError,
/**
- * Must be last for serialization purposes
+ * We were unable to complete the request as the Channel required to do so is unable to
+ * complete the request (or was not found). This can take many forms, including disconnected
+ * peer, channel at capacity, channel shutting down, etc.
*/
- LDKSpendableOutputDescriptor_Sentinel,
-} LDKSpendableOutputDescriptor_Tag;
-
-typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body {
- struct LDKOutPoint outpoint;
- struct LDKTxOut output;
-} LDKSpendableOutputDescriptor_LDKStaticOutput_Body;
-
-typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body {
- struct LDKOutPoint outpoint;
- struct LDKPublicKey per_commitment_point;
- uint16_t to_self_delay;
- struct LDKTxOut output;
- LDKC2Tuple_u64u64Z key_derivation_params;
- struct LDKPublicKey revocation_pubkey;
-} LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body;
-
-typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body {
- struct LDKOutPoint outpoint;
- struct LDKTxOut output;
- LDKC2Tuple_u64u64Z key_derivation_params;
-} LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body;
-
-typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor {
- LDKSpendableOutputDescriptor_Tag tag;
- union {
- LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output;
- LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh;
- LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body static_output_counterparty_payment;
- };
-} LDKSpendableOutputDescriptor;
-
-typedef struct LDKCVecTempl_SpendableOutputDescriptor {
- struct LDKSpendableOutputDescriptor *data;
- uintptr_t datalen;
-} LDKCVecTempl_SpendableOutputDescriptor;
-
-typedef struct LDKCVecTempl_SpendableOutputDescriptor LDKCVec_SpendableOutputDescriptorZ;
-
-/**
- * An Event which you should probably take some action in response to.
- *
- * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
- * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
- * written as it makes no sense to respond to it after reconnecting to peers).
- */
-typedef enum LDKEvent_Tag {
- /**
- * Used to indicate that the client should generate a funding transaction with the given
- * parameters and then call ChannelManager::funding_transaction_generated.
- * Generated in ChannelManager message handling.
- * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
- * counterparty can steal your funds!
- */
- LDKEvent_FundingGenerationReady,
- /**
- * Used to indicate that the client may now broadcast the funding transaction it created for a
- * channel. Broadcasting such a transaction prior to this event may lead to our counterparty
- * trivially stealing all funds in the funding transaction!
- */
- LDKEvent_FundingBroadcastSafe,
- /**
- * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
- * ChannelManager::claim_funds to get it....
- * Note that if the preimage is not known or the amount paid is incorrect, you should call
- * ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
- * network congestion.
- * The amount paid should be considered 'incorrect' when it is less than or more than twice
- * the amount expected.
- * If you fail to call either ChannelManager::claim_funds or
- * ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
- * automatically failed.
- */
- LDKEvent_PaymentReceived,
- /**
- * Indicates an outbound payment we made succeeded (ie it made it all the way to its target
- * and we got back the payment preimage for it).
- * Note that duplicative PaymentSent Events may be generated - it is your responsibility to
- * deduplicate them by payment_preimage (which MUST be unique)!
- */
- LDKEvent_PaymentSent,
- /**
- * Indicates an outbound payment we made failed. Probably some intermediary node dropped
- * something. You may wish to retry with a different route.
- * Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
- * deduplicate them by payment_hash (which MUST be unique)!
- */
- LDKEvent_PaymentFailed,
- /**
- * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
- * time in the future.
- */
- LDKEvent_PendingHTLCsForwardable,
+ LDKAPIError_ChannelUnavailable,
/**
- * Used to indicate that an output was generated on-chain which you should know how to spend.
- * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
- * counterparty spending them due to some kind of timeout. Thus, you need to store them
- * somewhere and spend them when you create on-chain transactions.
+ * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
+ * attempted action to fail.
*/
- LDKEvent_SpendableOutputs,
+ LDKAPIError_MonitorUpdateFailed,
/**
* Must be last for serialization purposes
*/
- LDKEvent_Sentinel,
-} LDKEvent_Tag;
-
-typedef struct LDKEvent_LDKFundingGenerationReady_Body {
- struct LDKThirtyTwoBytes temporary_channel_id;
- uint64_t channel_value_satoshis;
- LDKCVec_u8Z output_script;
- uint64_t user_channel_id;
-} LDKEvent_LDKFundingGenerationReady_Body;
-
-typedef struct LDKEvent_LDKFundingBroadcastSafe_Body {
- struct LDKOutPoint funding_txo;
- uint64_t user_channel_id;
-} LDKEvent_LDKFundingBroadcastSafe_Body;
-
-typedef struct LDKEvent_LDKPaymentReceived_Body {
- struct LDKThirtyTwoBytes payment_hash;
- struct LDKThirtyTwoBytes payment_secret;
- uint64_t amt;
-} LDKEvent_LDKPaymentReceived_Body;
+ LDKAPIError_Sentinel,
+} LDKAPIError_Tag;
-typedef struct LDKEvent_LDKPaymentSent_Body {
- struct LDKThirtyTwoBytes payment_preimage;
-} LDKEvent_LDKPaymentSent_Body;
+typedef struct LDKAPIError_LDKAPIMisuseError_Body {
+ LDKCVec_u8Z err;
+} LDKAPIError_LDKAPIMisuseError_Body;
-typedef struct LDKEvent_LDKPaymentFailed_Body {
- struct LDKThirtyTwoBytes payment_hash;
- bool rejected_by_dest;
-} LDKEvent_LDKPaymentFailed_Body;
+typedef struct LDKAPIError_LDKFeeRateTooHigh_Body {
+ LDKCVec_u8Z err;
+ uint32_t feerate;
+} LDKAPIError_LDKFeeRateTooHigh_Body;
-typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
- uint64_t time_forwardable;
-} LDKEvent_LDKPendingHTLCsForwardable_Body;
+typedef struct LDKAPIError_LDKRouteError_Body {
+ struct LDKStr err;
+} LDKAPIError_LDKRouteError_Body;
-typedef struct LDKEvent_LDKSpendableOutputs_Body {
- LDKCVec_SpendableOutputDescriptorZ outputs;
-} LDKEvent_LDKSpendableOutputs_Body;
+typedef struct LDKAPIError_LDKChannelUnavailable_Body {
+ LDKCVec_u8Z err;
+} LDKAPIError_LDKChannelUnavailable_Body;
-typedef struct MUST_USE_STRUCT LDKEvent {
- LDKEvent_Tag tag;
+typedef struct MUST_USE_STRUCT LDKAPIError {
+ LDKAPIError_Tag tag;
union {
- LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
- LDKEvent_LDKFundingBroadcastSafe_Body funding_broadcast_safe;
- LDKEvent_LDKPaymentReceived_Body payment_received;
- LDKEvent_LDKPaymentSent_Body payment_sent;
- LDKEvent_LDKPaymentFailed_Body payment_failed;
- LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
- LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
+ LDKAPIError_LDKAPIMisuseError_Body api_misuse_error;
+ LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high;
+ LDKAPIError_LDKRouteError_Body route_error;
+ LDKAPIError_LDKChannelUnavailable_Body channel_unavailable;
};
-} LDKEvent;
-
-
-
-/**
- * An accept_channel message to be sent or received from a peer
- */
-typedef struct MUST_USE_STRUCT LDKAcceptChannel {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeAcceptChannel *inner;
- bool is_owned;
-} LDKAcceptChannel;
+} LDKAPIError;
+typedef union LDKCResultPtr_u8__APIError {
+ uint8_t *result;
+ struct LDKAPIError *err;
+} LDKCResultPtr_u8__APIError;
+typedef struct LDKCResultTempl_u8__APIError {
+ union LDKCResultPtr_u8__APIError contents;
+ bool result_ok;
+} LDKCResultTempl_u8__APIError;
-/**
- * An open_channel message to be sent or received from a peer
- */
-typedef struct MUST_USE_STRUCT LDKOpenChannel {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeOpenChannel *inner;
- bool is_owned;
-} LDKOpenChannel;
+typedef struct LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ;
/**
- * A funding_created message to be sent or received from a peer
+ * If a payment fails to send, it can be in one of several states. This enum is returned as the
+ * Err() type describing which state the payment is in, see the description of individual enum
+ * states for more.
*/
-typedef struct MUST_USE_STRUCT LDKFundingCreated {
+typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeFundingCreated *inner;
+ LDKnativePaymentSendFailure *inner;
bool is_owned;
-} LDKFundingCreated;
+} LDKPaymentSendFailure;
+typedef union LDKCResultPtr_u8__PaymentSendFailure {
+ uint8_t *result;
+ struct LDKPaymentSendFailure *err;
+} LDKCResultPtr_u8__PaymentSendFailure;
+typedef struct LDKCResultTempl_u8__PaymentSendFailure {
+ union LDKCResultPtr_u8__PaymentSendFailure contents;
+ bool result_ok;
+} LDKCResultTempl_u8__PaymentSendFailure;
-/**
- * A funding_signed message to be sent or received from a peer
- */
-typedef struct MUST_USE_STRUCT LDKFundingSigned {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeFundingSigned *inner;
- bool is_owned;
-} LDKFundingSigned;
+typedef struct LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ;
/**
- * A funding_locked message to be sent or received from a peer
+ * An update generated by the underlying Channel itself which contains some new information the
+ * ChannelMonitor should be made aware of.
*/
-typedef struct MUST_USE_STRUCT LDKFundingLocked {
+typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeFundingLocked *inner;
+ LDKnativeChannelMonitorUpdate *inner;
bool is_owned;
-} LDKFundingLocked;
+} LDKChannelMonitorUpdate;
/**
- * An announcement_signatures message to be sent or received from a peer
+ * An event to be processed by the ChannelManager.
*/
-typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures {
+typedef struct MUST_USE_STRUCT LDKMonitorEvent {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeAnnouncementSignatures *inner;
+ LDKnativeMonitorEvent *inner;
bool is_owned;
-} LDKAnnouncementSignatures;
+} LDKMonitorEvent;
+typedef struct LDKCVecTempl_MonitorEvent {
+ struct LDKMonitorEvent *data;
+ uintptr_t datalen;
+} LDKCVecTempl_MonitorEvent;
+typedef struct LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ;
/**
- * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
- * transaction updates if they were pending.
- */
-typedef struct MUST_USE_STRUCT LDKCommitmentUpdate {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
+ * blocks are connected and disconnected.
+ *
+ * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
+ * responsible for maintaining a set of monitors such that they can be updated accordingly as
+ * channel state changes and HTLCs are resolved. See method documentation for specific
+ * requirements.
+ *
+ * Implementations **must** ensure that updates are successfully applied and persisted upon method
+ * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
+ * without taking any further action such as persisting the current state.
+ *
+ * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
+ * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
+ * could result in a revoked transaction being broadcast, allowing the counterparty to claim all
+ * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
+ * multiple instances.
+ *
+ * [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html
+ * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+ * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure
+ */
+typedef struct LDKWatch {
+ void *this_arg;
+ /**
+ * Watches a channel identified by `funding_txo` using `monitor`.
+ *
+ * Implementations are responsible for watching the chain for the funding transaction along
+ * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
+ * calling [`block_connected`] and [`block_disconnected`] on the monitor.
+ *
+ * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
+ * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
+ * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
*/
- LDKnativeCommitmentUpdate *inner;
- bool is_owned;
-} LDKCommitmentUpdate;
+ LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor);
+ /**
+ * Updates a channel identified by `funding_txo` by applying `update` to its monitor.
+ *
+ * Implementations must call [`update_monitor`] with the given update. See
+ * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
+ *
+ * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
+ * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+ */
+ LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update);
+ /**
+ * Returns any monitor events since the last call. Subsequent calls must only return new
+ * events.
+ */
+ LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKWatch;
+
+/**
+ * An interface to send a transaction to the Bitcoin network.
+ */
+typedef struct LDKBroadcasterInterface {
+ void *this_arg;
+ /**
+ * Sends a transaction out to (hopefully) be mined.
+ */
+ void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx);
+ void (*free)(void *this_arg);
+} LDKBroadcasterInterface;
+
+typedef struct LDKSecretKey {
+ uint8_t bytes[32];
+} LDKSecretKey;
/**
- * A revoke_and_ack message to be sent or received from a peer
+ * An error in decoding a message or struct.
*/
-typedef struct MUST_USE_STRUCT LDKRevokeAndACK {
+typedef struct MUST_USE_STRUCT LDKDecodeError {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeRevokeAndACK *inner;
+ LDKnativeDecodeError *inner;
bool is_owned;
-} LDKRevokeAndACK;
+} LDKDecodeError;
+
+typedef union LDKCResultPtr_ChannelKeys__DecodeError {
+ struct LDKChannelKeys *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_ChannelKeys__DecodeError;
+
+typedef struct LDKCResultTempl_ChannelKeys__DecodeError {
+ union LDKCResultPtr_ChannelKeys__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_ChannelKeys__DecodeError;
+typedef struct LDKCResultTempl_ChannelKeys__DecodeError LDKCResult_ChanKeySignerDecodeErrorZ;
+typedef struct LDKu8slice {
+ const uint8_t *data;
+ uintptr_t datalen;
+} LDKu8slice;
/**
- * A closing_signed message to be sent or received from a peer
+ * A trait to describe an object which can get user secrets and key material.
*/
-typedef struct MUST_USE_STRUCT LDKClosingSigned {
+typedef struct LDKKeysInterface {
+ void *this_arg;
/**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Get node secret key (aka node_id or network_key)
*/
- LDKnativeClosingSigned *inner;
- bool is_owned;
-} LDKClosingSigned;
-
+ struct LDKSecretKey (*get_node_secret)(const void *this_arg);
+ /**
+ * Get destination redeemScript to encumber static protocol exit points.
+ */
+ LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
+ /**
+ * Get shutdown_pubkey to use as PublicKey at channel closure
+ */
+ struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
+ /**
+ * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
+ * restarted with some stale data!
+ */
+ struct LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
+ /**
+ * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
+ * onion packets and for temporary channel IDs. There is no requirement that these be
+ * persisted anywhere, though they must be unique across restarts.
+ */
+ struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
+ /**
+ * Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream.
+ * This is only called during deserialization of other objects which contain
+ * `ChannelKeys`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s).
+ * The bytes are exactly those which `<Self::ChanKeySigner as Writeable>::write()` writes, and
+ * contain no versioning scheme. You may wish to include your own version prefix and ensure
+ * you've read all of the provided bytes to ensure no corruption occurred.
+ */
+ LDKCResult_ChanKeySignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader);
+ void (*free)(void *this_arg);
+} LDKKeysInterface;
+/**
+ * A trait which should be implemented to provide feerate information on a number of time
+ * horizons.
+ *
+ * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+ * called from inside the library in response to chain events, P2P events, or timer events).
+ */
+typedef struct LDKFeeEstimator {
+ void *this_arg;
+ /**
+ * Gets estimated satoshis of fee required per 1000 Weight-Units.
+ *
+ * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
+ * don't put us below 1 satoshi-per-byte).
+ *
+ * This translates to:
+ * * satoshis-per-byte * 250
+ * * ceil(satoshis-per-kbyte / 4)
+ */
+ uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target);
+ void (*free)(void *this_arg);
+} LDKFeeEstimator;
/**
- * A shutdown message to be sent or received from a peer
+ * A trait encapsulating the operations required of a logger
*/
-typedef struct MUST_USE_STRUCT LDKShutdown {
+typedef struct LDKLogger {
+ void *this_arg;
/**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ * Logs the `Record`
*/
- LDKnativeShutdown *inner;
- bool is_owned;
-} LDKShutdown;
+ void (*log)(const void *this_arg, const char *record);
+ void (*free)(void *this_arg);
+} LDKLogger;
/**
- * A channel_reestablish message to be sent or received from a peer
+ * Manager which keeps track of a number of channels and sends messages to the appropriate
+ * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
+ *
+ * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
+ * to individual Channels.
+ *
+ * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
+ * all peers during write/read (though does not modify this instance, only the instance being
+ * serialized). This will result in any channels which have not yet exchanged funding_created (ie
+ * called funding_transaction_generated for outbound channels).
+ *
+ * Note that you can be a bit lazier about writing out ChannelManager than you can be with
+ * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
+ * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
+ * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
+ * the serialization process). If the deserialized version is out-of-date compared to the
+ * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
+ * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
+ *
+ * Note that the deserializer is only implemented for (Sha256dHash, ChannelManager), which
+ * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
+ * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
+ * block_connected() to step towards your best block) upon deserialization before using the
+ * object!
+ *
+ * Note that ChannelManager is responsible for tracking liveness of its channels and generating
+ * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
+ * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
+ * offline for a full minute. In order to track this, you must call
+ * timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfect.
+ *
+ * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
+ * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
+ * essentially you should default to using a SimpleRefChannelManager, and use a
+ * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
+ * you're using lightning-net-tokio.
*/
-typedef struct MUST_USE_STRUCT LDKChannelReestablish {
+typedef struct MUST_USE_STRUCT LDKChannelManager {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelReestablish *inner;
+ LDKnativeChannelManager *inner;
bool is_owned;
-} LDKChannelReestablish;
+} LDKChannelManager;
+
+typedef struct LDKC2TupleTempl_ThirtyTwoBytes__ChannelManager {
+ struct LDKThirtyTwoBytes a;
+ struct LDKChannelManager b;
+} LDKC2TupleTempl_ThirtyTwoBytes__ChannelManager;
+
+typedef struct LDKC2TupleTempl_ThirtyTwoBytes__ChannelManager LDKC2Tuple_BlockHashChannelManagerZ;
/**
- * A node_announcement message to be sent or received from a peer
+ * A channel_announcement message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKNodeAnnouncement {
+typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
/**
* Nearly everywhere, 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;
+ LDKnativeChannelAnnouncement *inner;
bool is_owned;
-} LDKNodeAnnouncement;
+} LDKChannelAnnouncement;
/**
- * An error message to be sent or received from a peer
+ * A channel_update message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKErrorMessage {
+typedef struct MUST_USE_STRUCT LDKChannelUpdate {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeErrorMessage *inner;
+ LDKnativeChannelUpdate *inner;
bool is_owned;
-} LDKErrorMessage;
+} LDKChannelUpdate;
+
+typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
+ struct LDKChannelAnnouncement a;
+ struct LDKChannelUpdate b;
+ struct LDKChannelUpdate c;
+} LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
+
+typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
+
+
/**
- * Used to put an error message in a LightningError
+ * An Err type for failure to process messages.
*/
-typedef enum LDKErrorAction_Tag {
+typedef struct MUST_USE_STRUCT LDKLightningError {
/**
- * The peer took some action which made us think they were useless. Disconnect them.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKErrorAction_DisconnectPeer,
- /**
- * The peer did something harmless that we weren't able to process, just log and ignore
- */
- LDKErrorAction_IgnoreError,
- /**
- * The peer did something incorrect. Tell them.
- */
- LDKErrorAction_SendErrorMessage,
- /**
- * Must be last for serialization purposes
- */
- LDKErrorAction_Sentinel,
-} LDKErrorAction_Tag;
+ LDKnativeLightningError *inner;
+ bool is_owned;
+} LDKLightningError;
-typedef struct LDKErrorAction_LDKDisconnectPeer_Body {
- struct LDKErrorMessage msg;
-} LDKErrorAction_LDKDisconnectPeer_Body;
+typedef union LDKCResultPtr_u8__LightningError {
+ uint8_t *result;
+ struct LDKLightningError *err;
+} LDKCResultPtr_u8__LightningError;
+
+typedef struct LDKCResultTempl_u8__LightningError {
+ union LDKCResultPtr_u8__LightningError contents;
+ bool result_ok;
+} LDKCResultTempl_u8__LightningError;
+
+typedef struct LDKCResultTempl_u8__LightningError LDKCResult_NoneLightningErrorZ;
-typedef struct LDKErrorAction_LDKSendErrorMessage_Body {
- struct LDKErrorMessage msg;
-} LDKErrorAction_LDKSendErrorMessage_Body;
-typedef struct MUST_USE_STRUCT LDKErrorAction {
- LDKErrorAction_Tag tag;
- union {
- LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer;
- LDKErrorAction_LDKSendErrorMessage_Body send_error_message;
- };
-} LDKErrorAction;
/**
- * The information we received from a peer along the route of a payment we originated. This is
- * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
- * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
+ * Error for PeerManager errors. If you get one of these, you must disconnect the socket and
+ * generate no further read_event/write_buffer_space_avail calls for the descriptor, only
+ * triggering a single socket_disconnected call (unless it was provided in response to a
+ * new_*_connection event, in which case no such socket_disconnected() must be called and the
+ * socket silently disconencted).
*/
-typedef enum LDKHTLCFailChannelUpdate_Tag {
- /**
- * We received an error which included a full ChannelUpdate message.
- */
- LDKHTLCFailChannelUpdate_ChannelUpdateMessage,
- /**
- * We received an error which indicated only that a channel has been closed
- */
- LDKHTLCFailChannelUpdate_ChannelClosed,
- /**
- * We received an error which indicated only that a node has failed
- */
- LDKHTLCFailChannelUpdate_NodeFailure,
+typedef struct MUST_USE_STRUCT LDKPeerHandleError {
/**
- * Must be last for serialization purposes
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKHTLCFailChannelUpdate_Sentinel,
-} LDKHTLCFailChannelUpdate_Tag;
-
-typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body {
- struct LDKChannelUpdate msg;
-} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body;
+ LDKnativePeerHandleError *inner;
+ bool is_owned;
+} LDKPeerHandleError;
-typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body {
- uint64_t short_channel_id;
- bool is_permanent;
-} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body;
+typedef union LDKCResultPtr_u8__PeerHandleError {
+ uint8_t *result;
+ struct LDKPeerHandleError *err;
+} LDKCResultPtr_u8__PeerHandleError;
-typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body {
- struct LDKPublicKey node_id;
- bool is_permanent;
-} LDKHTLCFailChannelUpdate_LDKNodeFailure_Body;
+typedef struct LDKCResultTempl_u8__PeerHandleError {
+ union LDKCResultPtr_u8__PeerHandleError contents;
+ bool result_ok;
+} LDKCResultTempl_u8__PeerHandleError;
-typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate {
- LDKHTLCFailChannelUpdate_Tag tag;
- union {
- LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message;
- LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed;
- LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure;
- };
-} LDKHTLCFailChannelUpdate;
+typedef struct LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ;
/**
- * A query_channel_range message is used to query a peer for channel
- * UTXOs in a range of blocks. The recipient of a query makes a best
- * effort to reply to the query using one or more reply_channel_range
- * messages.
+ * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin
+ * transaction and the transaction creation keys) are trusted.
+ *
+ * See trust() and verify() functions on CommitmentTransaction.
+ *
+ * This structure implements Deref.
*/
-typedef struct MUST_USE_STRUCT LDKQueryChannelRange {
+typedef struct MUST_USE_STRUCT LDKTrustedCommitmentTransaction {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeQueryChannelRange *inner;
+ LDKnativeTrustedCommitmentTransaction *inner;
bool is_owned;
-} LDKQueryChannelRange;
+} LDKTrustedCommitmentTransaction;
+typedef union LDKCResultPtr_TrustedCommitmentTransaction__u8 {
+ struct LDKTrustedCommitmentTransaction *result;
+ uint8_t *err;
+} LDKCResultPtr_TrustedCommitmentTransaction__u8;
+typedef struct LDKCResultTempl_TrustedCommitmentTransaction__u8 {
+ union LDKCResultPtr_TrustedCommitmentTransaction__u8 contents;
+ bool result_ok;
+} LDKCResultTempl_TrustedCommitmentTransaction__u8;
-/**
- * A query_short_channel_ids message is used to query a peer for
- * routing gossip messages related to one or more short_channel_ids.
- * The query recipient will reply with the latest, if available,
- * channel_announcement, channel_update and node_announcement messages
- * it maintains for the requested short_channel_ids followed by a
- * reply_short_channel_ids_end message. The short_channel_ids sent in
- * this query are encoded. We only support encoding_type=0 uncompressed
- * serialization and do not support encoding_type=1 zlib serialization.
- */
-typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeQueryShortChannelIds *inner;
- bool is_owned;
-} LDKQueryShortChannelIds;
+typedef struct LDKCResultTempl_TrustedCommitmentTransaction__u8 LDKCResult_TrustedCommitmentTransactionNoneZ;
/**
- * An event generated by ChannelManager which indicates a message should be sent to a peer (or
- * broadcast to most peers).
- * These events are handled by PeerManager::process_events if you are using a PeerManager.
+ * When on-chain outputs are created by rust-lightning (which our counterparty is not able to
+ * claim at any point in the future) an event is generated which you must track and be able to
+ * spend on-chain. The information needed to do this is provided in this enum, including the
+ * outpoint describing which txid and output index is available, the full output which exists at
+ * that txid/index, and any keys or other information required to sign.
*/
-typedef enum LDKMessageSendEvent_Tag {
- /**
- * Used to indicate that we've accepted a channel open and should send the accept_channel
- * message provided to the given peer.
- */
- LDKMessageSendEvent_SendAcceptChannel,
- /**
- * Used to indicate that we've initiated a channel open and should send the open_channel
- * message provided to the given peer.
- */
- LDKMessageSendEvent_SendOpenChannel,
- /**
- * Used to indicate that a funding_created message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendFundingCreated,
- /**
- * Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendFundingSigned,
- /**
- * Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendFundingLocked,
- /**
- * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendAnnouncementSignatures,
- /**
- * Used to indicate that a series of HTLC update messages, as well as a commitment_signed
- * message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_UpdateHTLCs,
- /**
- * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendRevokeAndACK,
- /**
- * Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendClosingSigned,
- /**
- * Used to indicate that a shutdown message should be sent to the peer with the given node_id.
- */
- LDKMessageSendEvent_SendShutdown,
+typedef enum LDKSpendableOutputDescriptor_Tag {
/**
- * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
+ * An output to a script which was provided via KeysInterface, thus you should already know
+ * how to spend it. No keys are provided as rust-lightning was never given any keys - only the
+ * script_pubkey as it appears in the output.
+ * These may include outputs from a transaction punishing our counterparty or claiming an HTLC
+ * on-chain using the payment preimage or after it has timed out.
*/
- LDKMessageSendEvent_SendChannelReestablish,
+ LDKSpendableOutputDescriptor_StaticOutput,
/**
- * 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).
+ * An output to a P2WSH script which can be spent with a single signature after a CSV delay.
*
- * Note that after doing so, you very likely (unless you did so very recently) want to call
- * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
- * This ensures that any nodes which see our channel_announcement also have a relevant
- * node_announcement, including relevant feature flags which may be important for routing
- * through or to us.
- */
- LDKMessageSendEvent_BroadcastChannelAnnouncement,
- /**
- * Used to indicate that a node_announcement should be broadcast to all peers.
+ * The witness in the spending input should be:
+ * <BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>
+ *
+ * Note that the nSequence field in the spending input must be set to to_self_delay
+ * (which means the transaction is not broadcastable until at least to_self_delay
+ * blocks after the outpoint confirms).
+ *
+ * These are generally the result of a \"revocable\" output to us, spendable only by us unless
+ * it is an output from an old state which we broadcast (which should never happen).
+ *
+ * To derive the delayed_payment key which is used to sign for this input, you must pass the
+ * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in
+ * ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
+ * chan_utils::derive_private_key. The public key can be generated without the secret key
+ * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
+ * ChannelKeys::pubkeys().
+ *
+ * To derive the revocation_pubkey provided here (which is used in the witness
+ * script generation), you must pass the counterparty revocation_basepoint (which appears in the
+ * call to ChannelKeys::ready_channel) and the provided per_commitment point
+ * to chan_utils::derive_public_revocation_key.
+ *
+ * The witness script which is hashed and included in the output script_pubkey may be
+ * regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
+ * (derived as above), and the to_self_delay contained here to
+ * chan_utils::get_revokeable_redeemscript.
*/
- LDKMessageSendEvent_BroadcastNodeAnnouncement,
+ LDKSpendableOutputDescriptor_DynamicOutputP2WSH,
/**
- * Used to indicate that a channel_update should be broadcast to all peers.
+ * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
+ * corresponds to the public key in ChannelKeys::pubkeys().payment_point).
+ * The witness in the spending input, is, thus, simply:
+ * <BIP 143 signature> <payment key>
+ *
+ * These are generally the result of our counterparty having broadcast the current state,
+ * allowing us to claim the non-HTLC-encumbered outputs immediately.
*/
- LDKMessageSendEvent_BroadcastChannelUpdate,
+ LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment,
/**
- * Broadcast an error downstream to be handled
+ * Must be last for serialization purposes
*/
- LDKMessageSendEvent_HandleError,
- /**
- * When a payment fails we may receive updates back from the hop where it failed. In such
- * cases this event is generated so that we can inform the network graph of this information.
+ LDKSpendableOutputDescriptor_Sentinel,
+} LDKSpendableOutputDescriptor_Tag;
+
+typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body {
+ struct LDKOutPoint outpoint;
+ struct LDKTxOut output;
+} LDKSpendableOutputDescriptor_LDKStaticOutput_Body;
+
+typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body {
+ struct LDKOutPoint outpoint;
+ struct LDKPublicKey per_commitment_point;
+ uint16_t to_self_delay;
+ struct LDKTxOut output;
+ LDKC2Tuple_u64u64Z key_derivation_params;
+ struct LDKPublicKey revocation_pubkey;
+} LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body;
+
+typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body {
+ struct LDKOutPoint outpoint;
+ struct LDKTxOut output;
+ LDKC2Tuple_u64u64Z key_derivation_params;
+} LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body;
+
+typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor {
+ LDKSpendableOutputDescriptor_Tag tag;
+ union {
+ LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output;
+ LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh;
+ LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body static_output_counterparty_payment;
+ };
+} LDKSpendableOutputDescriptor;
+
+typedef struct LDKCVecTempl_SpendableOutputDescriptor {
+ struct LDKSpendableOutputDescriptor *data;
+ uintptr_t datalen;
+} LDKCVecTempl_SpendableOutputDescriptor;
+
+typedef struct LDKCVecTempl_SpendableOutputDescriptor LDKCVec_SpendableOutputDescriptorZ;
+
+/**
+ * An Event which you should probably take some action in response to.
+ *
+ * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
+ * them directly as they don't round-trip exactly (for example FundingGenerationReady is never
+ * written as it makes no sense to respond to it after reconnecting to peers).
+ */
+typedef enum LDKEvent_Tag {
+ /**
+ * Used to indicate that the client should generate a funding transaction with the given
+ * parameters and then call ChannelManager::funding_transaction_generated.
+ * Generated in ChannelManager message handling.
+ * Note that *all inputs* in the funding transaction must spend SegWit outputs or your
+ * counterparty can steal your funds!
*/
- LDKMessageSendEvent_PaymentFailureNetworkUpdate,
+ LDKEvent_FundingGenerationReady,
/**
- * Query a peer for channels with funding transaction UTXOs in a block range.
+ * Used to indicate that the client may now broadcast the funding transaction it created for a
+ * channel. Broadcasting such a transaction prior to this event may lead to our counterparty
+ * trivially stealing all funds in the funding transaction!
*/
- LDKMessageSendEvent_SendChannelRangeQuery,
+ LDKEvent_FundingBroadcastSafe,
/**
- * Request routing gossip messages from a peer for a list of channels identified by
- * their short_channel_ids.
+ * Indicates we've received money! Just gotta dig out that payment preimage and feed it to
+ * ChannelManager::claim_funds to get it....
+ * Note that if the preimage is not known or the amount paid is incorrect, you should call
+ * ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
+ * network congestion.
+ * The amount paid should be considered 'incorrect' when it is less than or more than twice
+ * the amount expected.
+ * If you fail to call either ChannelManager::claim_funds or
+ * ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
+ * automatically failed.
*/
- LDKMessageSendEvent_SendShortIdsQuery,
+ LDKEvent_PaymentReceived,
+ /**
+ * Indicates an outbound payment we made succeeded (ie it made it all the way to its target
+ * and we got back the payment preimage for it).
+ * Note that duplicative PaymentSent Events may be generated - it is your responsibility to
+ * deduplicate them by payment_preimage (which MUST be unique)!
+ */
+ LDKEvent_PaymentSent,
+ /**
+ * Indicates an outbound payment we made failed. Probably some intermediary node dropped
+ * something. You may wish to retry with a different route.
+ * Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
+ * deduplicate them by payment_hash (which MUST be unique)!
+ */
+ LDKEvent_PaymentFailed,
+ /**
+ * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
+ * time in the future.
+ */
+ LDKEvent_PendingHTLCsForwardable,
+ /**
+ * Used to indicate that an output was generated on-chain which you should know how to spend.
+ * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
+ * counterparty spending them due to some kind of timeout. Thus, you need to store them
+ * somewhere and spend them when you create on-chain transactions.
+ */
+ LDKEvent_SpendableOutputs,
/**
* Must be last for serialization purposes
*/
- LDKMessageSendEvent_Sentinel,
-} LDKMessageSendEvent_Tag;
+ LDKEvent_Sentinel,
+} LDKEvent_Tag;
-typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body {
- struct LDKPublicKey node_id;
- struct LDKAcceptChannel msg;
-} LDKMessageSendEvent_LDKSendAcceptChannel_Body;
+typedef struct LDKEvent_LDKFundingGenerationReady_Body {
+ struct LDKThirtyTwoBytes temporary_channel_id;
+ uint64_t channel_value_satoshis;
+ LDKCVec_u8Z output_script;
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingGenerationReady_Body;
-typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body {
- struct LDKPublicKey node_id;
- struct LDKOpenChannel msg;
-} LDKMessageSendEvent_LDKSendOpenChannel_Body;
+typedef struct LDKEvent_LDKFundingBroadcastSafe_Body {
+ struct LDKOutPoint funding_txo;
+ uint64_t user_channel_id;
+} LDKEvent_LDKFundingBroadcastSafe_Body;
-typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body {
- struct LDKPublicKey node_id;
- struct LDKFundingCreated msg;
-} LDKMessageSendEvent_LDKSendFundingCreated_Body;
+typedef struct LDKEvent_LDKPaymentReceived_Body {
+ struct LDKThirtyTwoBytes payment_hash;
+ struct LDKThirtyTwoBytes payment_secret;
+ uint64_t amt;
+} LDKEvent_LDKPaymentReceived_Body;
-typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body {
- struct LDKPublicKey node_id;
- struct LDKFundingSigned msg;
-} LDKMessageSendEvent_LDKSendFundingSigned_Body;
+typedef struct LDKEvent_LDKPaymentSent_Body {
+ struct LDKThirtyTwoBytes payment_preimage;
+} LDKEvent_LDKPaymentSent_Body;
-typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body {
- struct LDKPublicKey node_id;
- struct LDKFundingLocked msg;
-} LDKMessageSendEvent_LDKSendFundingLocked_Body;
+typedef struct LDKEvent_LDKPaymentFailed_Body {
+ struct LDKThirtyTwoBytes payment_hash;
+ bool rejected_by_dest;
+} LDKEvent_LDKPaymentFailed_Body;
-typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body {
- struct LDKPublicKey node_id;
- struct LDKAnnouncementSignatures msg;
-} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body;
+typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
+ uint64_t time_forwardable;
+} LDKEvent_LDKPendingHTLCsForwardable_Body;
-typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body {
- struct LDKPublicKey node_id;
- struct LDKCommitmentUpdate updates;
-} LDKMessageSendEvent_LDKUpdateHTLCs_Body;
+typedef struct LDKEvent_LDKSpendableOutputs_Body {
+ LDKCVec_SpendableOutputDescriptorZ outputs;
+} LDKEvent_LDKSpendableOutputs_Body;
-typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body {
- struct LDKPublicKey node_id;
- struct LDKRevokeAndACK msg;
-} LDKMessageSendEvent_LDKSendRevokeAndACK_Body;
+typedef struct MUST_USE_STRUCT LDKEvent {
+ LDKEvent_Tag tag;
+ union {
+ LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
+ LDKEvent_LDKFundingBroadcastSafe_Body funding_broadcast_safe;
+ LDKEvent_LDKPaymentReceived_Body payment_received;
+ LDKEvent_LDKPaymentSent_Body payment_sent;
+ LDKEvent_LDKPaymentFailed_Body payment_failed;
+ LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
+ LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
+ };
+} LDKEvent;
-typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body {
- struct LDKPublicKey node_id;
- struct LDKClosingSigned msg;
-} LDKMessageSendEvent_LDKSendClosingSigned_Body;
-typedef struct LDKMessageSendEvent_LDKSendShutdown_Body {
- struct LDKPublicKey node_id;
- struct LDKShutdown msg;
-} LDKMessageSendEvent_LDKSendShutdown_Body;
-typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body {
- struct LDKPublicKey node_id;
- struct LDKChannelReestablish msg;
-} LDKMessageSendEvent_LDKSendChannelReestablish_Body;
+/**
+ * An accept_channel message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKAcceptChannel {
+ /**
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeAcceptChannel *inner;
+ bool is_owned;
+} LDKAcceptChannel;
-typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body {
- struct LDKChannelAnnouncement msg;
- struct LDKChannelUpdate update_msg;
-} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body;
-typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body {
- struct LDKNodeAnnouncement msg;
-} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body;
-typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body {
- struct LDKChannelUpdate msg;
-} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body;
+/**
+ * An open_channel message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKOpenChannel {
+ /**
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeOpenChannel *inner;
+ bool is_owned;
+} LDKOpenChannel;
-typedef struct LDKMessageSendEvent_LDKHandleError_Body {
- struct LDKPublicKey node_id;
- struct LDKErrorAction action;
-} LDKMessageSendEvent_LDKHandleError_Body;
-typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body {
- struct LDKHTLCFailChannelUpdate update;
-} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body;
-typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body {
- struct LDKPublicKey node_id;
- struct LDKQueryChannelRange msg;
-} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body;
-
-typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body {
- struct LDKPublicKey node_id;
- struct LDKQueryShortChannelIds msg;
-} LDKMessageSendEvent_LDKSendShortIdsQuery_Body;
-
-typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
- LDKMessageSendEvent_Tag tag;
- union {
- LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel;
- LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel;
- LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created;
- LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed;
- LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked;
- LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures;
- LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs;
- LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack;
- LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
- LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
- LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
- LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
- LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
- LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
- LDKMessageSendEvent_LDKHandleError_Body handle_error;
- LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update;
- LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
- LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query;
- };
-} LDKMessageSendEvent;
-
-typedef struct LDKCVecTempl_MessageSendEvent {
- struct LDKMessageSendEvent *data;
- uintptr_t datalen;
-} LDKCVecTempl_MessageSendEvent;
-
-typedef struct LDKCVecTempl_MessageSendEvent LDKCVec_MessageSendEventZ;
-
-/**
- * A trait indicating an object may generate message send events
- */
-typedef struct LDKMessageSendEventsProvider {
- void *this_arg;
- /**
- * Gets the list of pending events which were generated by previous actions, clearing the list
- * in the process.
- */
- LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg);
- void (*free)(void *this_arg);
-} LDKMessageSendEventsProvider;
-
-typedef struct LDKCVecTempl_Event {
- struct LDKEvent *data;
- uintptr_t datalen;
-} LDKCVecTempl_Event;
-
-typedef struct LDKCVecTempl_Event LDKCVec_EventZ;
-
-/**
- * A trait indicating an object may generate events
- */
-typedef struct LDKEventsProvider {
- void *this_arg;
- /**
- * Gets the list of pending events which were generated by previous actions, clearing the list
- * in the process.
- */
- LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg);
- void (*free)(void *this_arg);
-} LDKEventsProvider;
-
-/**
- * A trait encapsulating the operations required of a logger
- */
-typedef struct LDKLogger {
- void *this_arg;
- /**
- * Logs the `Record`
- */
- void (*log)(const void *this_arg, const char *record);
- void (*free)(void *this_arg);
-} LDKLogger;
+/**
+ * A funding_created message to be sent or received from a peer
+ */
+typedef struct MUST_USE_STRUCT LDKFundingCreated {
+ /**
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeFundingCreated *inner;
+ bool is_owned;
+} LDKFundingCreated;
/**
- * Configuration we set when applicable.
- *
- * Default::default() provides sane defaults.
+ * A funding_signed message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig {
+typedef struct MUST_USE_STRUCT LDKFundingSigned {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelHandshakeConfig *inner;
+ LDKnativeFundingSigned *inner;
bool is_owned;
-} LDKChannelHandshakeConfig;
+} LDKFundingSigned;
/**
- * Optional channel limits which are applied during channel creation.
- *
- * These limits are only applied to our counterparty's limits, not our own.
- *
- * Use 0/<type>::max_value() as appropriate to skip checking.
- *
- * Provides sane defaults for most configurations.
- *
- * Most additional limits are disabled except those with which specify a default in individual
- * field documentation. Note that this may result in barely-usable channels, but since they
- * are applied mostly only to incoming channels that's not much of a problem.
+ * A funding_locked message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits {
+typedef struct MUST_USE_STRUCT LDKFundingLocked {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelHandshakeLimits *inner;
+ LDKnativeFundingLocked *inner;
bool is_owned;
-} LDKChannelHandshakeLimits;
+} LDKFundingLocked;
/**
- * Options which apply on a per-channel basis and may change at runtime or based on negotiation
- * with our counterparty.
+ * An announcement_signatures message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKChannelConfig {
+typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelConfig *inner;
+ LDKnativeAnnouncementSignatures *inner;
bool is_owned;
-} LDKChannelConfig;
-
-typedef struct LDKu8slice {
- const uint8_t *data;
- uintptr_t datalen;
-} LDKu8slice;
+} LDKAnnouncementSignatures;
/**
- * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
- *
- * Default::default() provides sane defaults for most configurations
- * (but currently with 0 relay fees!)
+ * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
+ * transaction updates if they were pending.
*/
-typedef struct MUST_USE_STRUCT LDKUserConfig {
+typedef struct MUST_USE_STRUCT LDKCommitmentUpdate {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeUserConfig *inner;
+ LDKnativeCommitmentUpdate *inner;
bool is_owned;
-} LDKUserConfig;
-
-typedef union LDKCResultPtr_TxOut__AccessError {
- struct LDKTxOut *result;
- enum LDKAccessError *err;
-} LDKCResultPtr_TxOut__AccessError;
-
-typedef struct LDKCResultTempl_TxOut__AccessError {
- union LDKCResultPtr_TxOut__AccessError contents;
- bool result_ok;
-} LDKCResultTempl_TxOut__AccessError;
-
-typedef struct LDKCResultTempl_TxOut__AccessError LDKCResult_TxOutAccessErrorZ;
-
-/**
- * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
- * UTXOs.
- */
-typedef struct LDKAccess {
- void *this_arg;
- /**
- * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
- * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
- * is unknown.
- *
- * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
- */
- LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id);
- void (*free)(void *this_arg);
-} LDKAccess;
+} LDKCommitmentUpdate;
/**
- * One counterparty's public keys which do not change over the life of a channel.
+ * A revoke_and_ack message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKChannelPublicKeys {
+typedef struct MUST_USE_STRUCT LDKRevokeAndACK {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelPublicKeys *inner;
+ LDKnativeRevokeAndACK *inner;
bool is_owned;
-} LDKChannelPublicKeys;
+} LDKRevokeAndACK;
/**
- * This class tracks the per-transaction information needed to build a commitment transaction and to
- * actually build it and sign. It is used for holder transactions that we sign only when needed
- * and for transactions we sign for the counterparty.
- *
- * This class can be used inside a signer implementation to generate a signature given the relevant
- * secret key.
+ * A closing_signed message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKCommitmentTransaction {
+typedef struct MUST_USE_STRUCT LDKClosingSigned {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeCommitmentTransaction *inner;
+ LDKnativeClosingSigned *inner;
bool is_owned;
-} LDKCommitmentTransaction;
+} LDKClosingSigned;
/**
- * Information needed to build and sign a holder's commitment transaction.
- *
- * The transaction is only signed once we are ready to broadcast.
+ * A shutdown message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction {
+typedef struct MUST_USE_STRUCT LDKShutdown {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeHolderCommitmentTransaction *inner;
+ LDKnativeShutdown *inner;
bool is_owned;
-} LDKHolderCommitmentTransaction;
+} LDKShutdown;
/**
- * Information about an HTLC as it appears in a commitment transaction
+ * A channel_reestablish message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment {
+typedef struct MUST_USE_STRUCT LDKChannelReestablish {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeHTLCOutputInCommitment *inner;
+ LDKnativeChannelReestablish *inner;
bool is_owned;
-} LDKHTLCOutputInCommitment;
+} LDKChannelReestablish;
/**
- * The unsigned part of a channel_announcement
+ * A node_announcement message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
+typedef struct MUST_USE_STRUCT LDKNodeAnnouncement {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeUnsignedChannelAnnouncement *inner;
+ LDKnativeNodeAnnouncement *inner;
bool is_owned;
-} LDKUnsignedChannelAnnouncement;
+} LDKNodeAnnouncement;
/**
- * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
- * The fields are organized by holder/counterparty.
- *
- * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters
- * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions.
+ * An error message to be sent or received from a peer
*/
-typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters {
+typedef struct MUST_USE_STRUCT LDKErrorMessage {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelTransactionParameters *inner;
+ LDKnativeErrorMessage *inner;
bool is_owned;
-} LDKChannelTransactionParameters;
+} LDKErrorMessage;
/**
- * Set of lightning keys needed to operate a channel as described in BOLT 3.
- *
- * Signing services could be implemented on a hardware wallet. In this case,
- * the current ChannelKeys would be a front-end on top of a communication
- * channel connected to your secure device and lightning key material wouldn't
- * reside on a hot server. Nevertheless, a this deployment would still need
- * to trust the ChannelManager to avoid loss of funds as this latest component
- * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys.
- *
- * A more secure iteration would be to use hashlock (or payment points) to pair
- * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager
- * at the price of more state and computation on the hardware wallet side. In the future,
- * we are looking forward to design such interface.
- *
- * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
- * to act, as liveness and breach reply correctness are always going to be hard requirements
- * of LN security model, orthogonal of key management issues.
- *
- * If you're implementing a custom signer, you almost certainly want to implement
- * Readable/Writable to serialize out a unique reference to this set of keys so
- * that you can serialize the full ChannelManager object.
- *
+ * Used to put an error message in a LightningError
*/
-typedef struct LDKChannelKeys {
- void *this_arg;
+typedef enum LDKErrorAction_Tag {
/**
- * Gets the per-commitment point for a specific commitment number
- *
- * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
+ * The peer took some action which made us think they were useless. Disconnect them.
*/
- struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx);
+ LDKErrorAction_DisconnectPeer,
/**
- * Gets the commitment secret for a specific commitment number as part of the revocation process
- *
- * An external signer implementation should error here if the commitment was already signed
- * and should refuse to sign it in the future.
- *
- * May be called more than once for the same index.
- *
- * Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
- * TODO: return a Result so we can signal a validation error
+ * The peer did something harmless that we weren't able to process, just log and ignore
*/
- struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
+ LDKErrorAction_IgnoreError,
/**
- * Gets the holder's channel public keys and basepoints
+ * The peer did something incorrect. Tell them.
*/
- struct LDKChannelPublicKeys pubkeys;
+ LDKErrorAction_SendErrorMessage,
/**
- * Fill in the pubkeys field as a reference to it will be given to Rust after this returns
- * Note that this takes a pointer to this object, not the this_ptr like other methods do
- * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating.
+ * Must be last for serialization purposes
*/
- void (*set_pubkeys)(const struct LDKChannelKeys*);
+ LDKErrorAction_Sentinel,
+} LDKErrorAction_Tag;
+
+typedef struct LDKErrorAction_LDKDisconnectPeer_Body {
+ struct LDKErrorMessage msg;
+} LDKErrorAction_LDKDisconnectPeer_Body;
+
+typedef struct LDKErrorAction_LDKSendErrorMessage_Body {
+ struct LDKErrorMessage msg;
+} LDKErrorAction_LDKSendErrorMessage_Body;
+
+typedef struct MUST_USE_STRUCT LDKErrorAction {
+ LDKErrorAction_Tag tag;
+ union {
+ LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer;
+ LDKErrorAction_LDKSendErrorMessage_Body send_error_message;
+ };
+} LDKErrorAction;
+
+/**
+ * The information we received from a peer along the route of a payment we originated. This is
+ * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
+ * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
+ */
+typedef enum LDKHTLCFailChannelUpdate_Tag {
/**
- * Gets arbitrary identifiers describing the set of keys which are provided back to you in
- * some SpendableOutputDescriptor types. These should be sufficient to identify this
- * ChannelKeys object uniquely and lookup or re-derive its keys.
+ * We received an error which included a full ChannelUpdate message.
*/
- LDKC2Tuple_u64u64Z (*key_derivation_params)(const void *this_arg);
+ LDKHTLCFailChannelUpdate_ChannelUpdateMessage,
/**
- * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
- *
- * Note that if signing fails or is rejected, the channel will be force-closed.
+ * We received an error which indicated only that a channel has been closed
*/
- LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *commitment_tx);
+ LDKHTLCFailChannelUpdate_ChannelClosed,
/**
- * Create a signature for a holder's commitment transaction. This will only ever be called with
- * the same commitment_tx (or a copy thereof), though there are currently no guarantees
- * that it will not be called multiple times.
- * An external signer implementation should check that the commitment has not been revoked.
+ * We received an error which indicated only that a node has failed
*/
- LDKCResult_SignatureNoneZ (*sign_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *commitment_tx);
+ LDKHTLCFailChannelUpdate_NodeFailure,
/**
- * Create a signature for each HTLC transaction spending a holder's commitment transaction.
- *
- * Unlike sign_holder_commitment, this may be called multiple times with *different*
- * commitment_tx values. While this will never be called with a revoked
- * commitment_tx, it is possible that it is called with the second-latest
- * commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
- * ChannelMonitor decided to broadcast before it had been updated to the latest.
- *
- * Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
- * commitment_tx.
+ * Must be last for serialization purposes
*/
- LDKCResult_CVec_SignatureZNoneZ (*sign_holder_commitment_htlc_transactions)(const void *this_arg, const struct LDKHolderCommitmentTransaction *commitment_tx);
+ LDKHTLCFailChannelUpdate_Sentinel,
+} LDKHTLCFailChannelUpdate_Tag;
+
+typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body {
+ struct LDKChannelUpdate msg;
+} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body;
+
+typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body {
+ uint64_t short_channel_id;
+ bool is_permanent;
+} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body;
+
+typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body {
+ struct LDKPublicKey node_id;
+ bool is_permanent;
+} LDKHTLCFailChannelUpdate_LDKNodeFailure_Body;
+
+typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate {
+ LDKHTLCFailChannelUpdate_Tag tag;
+ union {
+ LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message;
+ LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed;
+ LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure;
+ };
+} LDKHTLCFailChannelUpdate;
+
+
+
+/**
+ * A query_channel_range message is used to query a peer for channel
+ * UTXOs in a range of blocks. The recipient of a query makes a best
+ * effort to reply to the query using one or more reply_channel_range
+ * messages.
+ */
+typedef struct MUST_USE_STRUCT LDKQueryChannelRange {
/**
- * Create a signature for the given input in a transaction spending an HTLC or commitment
- * transaction output when our counterparty broadcasts an old state.
- *
- * A justice transaction may claim multiples outputs at the same time if timelocks are
- * similar, but only a signature for the input at index `input` should be signed for here.
- * It may be called multiples time for same output(s) if a fee-bump is needed with regards
- * to an upcoming timelock expiration.
- *
- * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
- *
- * per_commitment_key is revocation secret which was provided by our counterparty when they
- * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
- * not allow the spending of any funds by itself (you need our holder revocation_secret to do
- * so).
- *
- * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
- * changing the format of the witness script (which is committed to in the BIP 143
- * signatures).
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *htlc);
+ LDKnativeQueryChannelRange *inner;
+ bool is_owned;
+} LDKQueryChannelRange;
+
+
+
+/**
+ * A query_short_channel_ids message is used to query a peer for
+ * routing gossip messages related to one or more short_channel_ids.
+ * The query recipient will reply with the latest, if available,
+ * channel_announcement, channel_update and node_announcement messages
+ * it maintains for the requested short_channel_ids followed by a
+ * reply_short_channel_ids_end message. The short_channel_ids sent in
+ * this query are encoded. We only support encoding_type=0 uncompressed
+ * serialization and do not support encoding_type=1 zlib serialization.
+ */
+typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds {
/**
- * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
- * transaction, either offered or received.
- *
- * Such a transaction may claim multiples offered outputs at same time if we know the
- * preimage for each when we create it, but only the input at index `input` should be
- * signed for here. It may be called multiple times for same output(s) if a fee-bump is
- * needed with regards to an upcoming timelock expiration.
- *
- * Witness_script is either a offered or received script as defined in BOLT3 for HTLC
- * outputs.
- *
- * Amount is value of the output spent by this input, committed to in the BIP 143 signature.
- *
- * Per_commitment_point is the dynamic point corresponding to the channel state
- * detected onchain. It has been generated by our counterparty and is used to derive
- * channel state keys, which are then included in the witness script and committed to in the
- * BIP 143 signature.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *htlc);
+ LDKnativeQueryShortChannelIds *inner;
+ bool is_owned;
+} LDKQueryShortChannelIds;
+
+/**
+ * An event generated by ChannelManager which indicates a message should be sent to a peer (or
+ * broadcast to most peers).
+ * These events are handled by PeerManager::process_events if you are using a PeerManager.
+ */
+typedef enum LDKMessageSendEvent_Tag {
/**
- * Create a signature for a (proposed) closing transaction.
- *
- * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
- * chosen to forgo their output as dust.
+ * Used to indicate that we've accepted a channel open and should send the accept_channel
+ * message provided to the given peer.
*/
- LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx);
+ LDKMessageSendEvent_SendAcceptChannel,
/**
- * Signs a channel announcement message with our funding key, proving it comes from one
- * of the channel participants.
- *
- * Note that if this fails or is rejected, the channel will not be publicly announced and
- * our counterparty may (though likely will not) close the channel on us for violating the
- * protocol.
+ * Used to indicate that we've initiated a channel open and should send the open_channel
+ * message provided to the given peer.
*/
- LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *msg);
+ LDKMessageSendEvent_SendOpenChannel,
/**
- * Set the counterparty static channel data, including basepoints,
- * counterparty_selected/holder_selected_contest_delay and funding outpoint.
- * This is done as soon as the funding outpoint is known. Since these are static channel data,
- * they MUST NOT be allowed to change to different values once set.
- *
- * channel_parameters.is_populated() MUST be true.
- *
- * We bind holder_selected_contest_delay late here for API convenience.
+ * Used to indicate that a funding_created message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendFundingCreated,
+ /**
+ * Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendFundingSigned,
+ /**
+ * Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendFundingLocked,
+ /**
+ * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendAnnouncementSignatures,
+ /**
+ * Used to indicate that a series of HTLC update messages, as well as a commitment_signed
+ * message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_UpdateHTLCs,
+ /**
+ * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendRevokeAndACK,
+ /**
+ * Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendClosingSigned,
+ /**
+ * Used to indicate that a shutdown message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendShutdown,
+ /**
+ * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
+ */
+ LDKMessageSendEvent_SendChannelReestablish,
+ /**
+ * Used to indicate that a channel_announcement and channel_update should be broadcast to all
+ * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
*
- * Will be called before any signatures are applied.
+ * Note that after doing so, you very likely (unless you did so very recently) want to call
+ * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
+ * This ensures that any nodes which see our channel_announcement also have a relevant
+ * node_announcement, including relevant feature flags which may be important for routing
+ * through or to us.
+ */
+ LDKMessageSendEvent_BroadcastChannelAnnouncement,
+ /**
+ * Used to indicate that a node_announcement should be broadcast to all peers.
+ */
+ LDKMessageSendEvent_BroadcastNodeAnnouncement,
+ /**
+ * Used to indicate that a channel_update should be broadcast to all peers.
+ */
+ LDKMessageSendEvent_BroadcastChannelUpdate,
+ /**
+ * Broadcast an error downstream to be handled
+ */
+ LDKMessageSendEvent_HandleError,
+ /**
+ * When a payment fails we may receive updates back from the hop where it failed. In such
+ * cases this event is generated so that we can inform the network graph of this information.
+ */
+ LDKMessageSendEvent_PaymentFailureNetworkUpdate,
+ /**
+ * Query a peer for channels with funding transaction UTXOs in a block range.
+ */
+ LDKMessageSendEvent_SendChannelRangeQuery,
+ /**
+ * Request routing gossip messages from a peer for a list of channels identified by
+ * their short_channel_ids.
+ */
+ LDKMessageSendEvent_SendShortIdsQuery,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKMessageSendEvent_Sentinel,
+} LDKMessageSendEvent_Tag;
+
+typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body {
+ struct LDKPublicKey node_id;
+ struct LDKAcceptChannel msg;
+} LDKMessageSendEvent_LDKSendAcceptChannel_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body {
+ struct LDKPublicKey node_id;
+ struct LDKOpenChannel msg;
+} LDKMessageSendEvent_LDKSendOpenChannel_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body {
+ struct LDKPublicKey node_id;
+ struct LDKFundingCreated msg;
+} LDKMessageSendEvent_LDKSendFundingCreated_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body {
+ struct LDKPublicKey node_id;
+ struct LDKFundingSigned msg;
+} LDKMessageSendEvent_LDKSendFundingSigned_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body {
+ struct LDKPublicKey node_id;
+ struct LDKFundingLocked msg;
+} LDKMessageSendEvent_LDKSendFundingLocked_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body {
+ struct LDKPublicKey node_id;
+ struct LDKAnnouncementSignatures msg;
+} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body;
+
+typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body {
+ struct LDKPublicKey node_id;
+ struct LDKCommitmentUpdate updates;
+} LDKMessageSendEvent_LDKUpdateHTLCs_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body {
+ struct LDKPublicKey node_id;
+ struct LDKRevokeAndACK msg;
+} LDKMessageSendEvent_LDKSendRevokeAndACK_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body {
+ struct LDKPublicKey node_id;
+ struct LDKClosingSigned msg;
+} LDKMessageSendEvent_LDKSendClosingSigned_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendShutdown_Body {
+ struct LDKPublicKey node_id;
+ struct LDKShutdown msg;
+} LDKMessageSendEvent_LDKSendShutdown_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body {
+ struct LDKPublicKey node_id;
+ struct LDKChannelReestablish msg;
+} LDKMessageSendEvent_LDKSendChannelReestablish_Body;
+
+typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body {
+ struct LDKChannelAnnouncement msg;
+ struct LDKChannelUpdate update_msg;
+} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body;
+
+typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body {
+ struct LDKNodeAnnouncement msg;
+} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body;
+
+typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body {
+ struct LDKChannelUpdate msg;
+} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body;
+
+typedef struct LDKMessageSendEvent_LDKHandleError_Body {
+ struct LDKPublicKey node_id;
+ struct LDKErrorAction action;
+} LDKMessageSendEvent_LDKHandleError_Body;
+
+typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body {
+ struct LDKHTLCFailChannelUpdate update;
+} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body {
+ struct LDKPublicKey node_id;
+ struct LDKQueryChannelRange msg;
+} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body;
+
+typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body {
+ struct LDKPublicKey node_id;
+ struct LDKQueryShortChannelIds msg;
+} LDKMessageSendEvent_LDKSendShortIdsQuery_Body;
+
+typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
+ LDKMessageSendEvent_Tag tag;
+ union {
+ LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel;
+ LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel;
+ LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created;
+ LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed;
+ LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked;
+ LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures;
+ LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs;
+ LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack;
+ LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed;
+ LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown;
+ LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish;
+ LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement;
+ LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement;
+ LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
+ LDKMessageSendEvent_LDKHandleError_Body handle_error;
+ LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update;
+ LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
+ LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query;
+ };
+} LDKMessageSendEvent;
+
+typedef struct LDKCVecTempl_MessageSendEvent {
+ struct LDKMessageSendEvent *data;
+ uintptr_t datalen;
+} LDKCVecTempl_MessageSendEvent;
+
+typedef struct LDKCVecTempl_MessageSendEvent LDKCVec_MessageSendEventZ;
+
+/**
+ * A trait indicating an object may generate message send events
+ */
+typedef struct LDKMessageSendEventsProvider {
+ void *this_arg;
+ /**
+ * Gets the list of pending events which were generated by previous actions, clearing the list
+ * in the process.
+ */
+ LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg);
+ void (*free)(void *this_arg);
+} LDKMessageSendEventsProvider;
+
+typedef struct LDKCVecTempl_Event {
+ struct LDKEvent *data;
+ uintptr_t datalen;
+} LDKCVecTempl_Event;
+
+typedef struct LDKCVecTempl_Event LDKCVec_EventZ;
+
+/**
+ * A trait indicating an object may generate events
+ */
+typedef struct LDKEventsProvider {
+ void *this_arg;
+ /**
+ * Gets the list of pending events which were generated by previous actions, clearing the list
+ * in the process.
*/
- void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *channel_parameters);
- void *(*clone)(const void *this_arg);
- LDKCVec_u8Z (*write)(const void *this_arg);
+ LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg);
void (*free)(void *this_arg);
-} LDKChannelKeys;
+} LDKEventsProvider;
/**
- * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
- * on-chain transactions to ensure no loss of funds occurs.
- *
- * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
- * information and are actively monitoring the chain.
- *
- * Pending Events or updated HTLCs which have not yet been read out by
- * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
- * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
- * gotten are fully handled before re-serializing the new state.
+ * Configuration we set when applicable.
*
- * Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
- * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
- * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
- * returned block hash and the the current chain and then reconnecting blocks to get to the
- * best chain) upon deserializing the object!
+ * Default::default() provides sane defaults.
*/
-typedef struct MUST_USE_STRUCT LDKChannelMonitor {
+typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelMonitor *inner;
+ LDKnativeChannelHandshakeConfig *inner;
bool is_owned;
-} LDKChannelMonitor;
+} LDKChannelHandshakeConfig;
/**
- * An update generated by the underlying Channel itself which contains some new information the
- * ChannelMonitor should be made aware of.
+ * Optional channel limits which are applied during channel creation.
+ *
+ * These limits are only applied to our counterparty's limits, not our own.
+ *
+ * Use 0/<type>::max_value() as appropriate to skip checking.
+ *
+ * Provides sane defaults for most configurations.
+ *
+ * Most additional limits are disabled except those with which specify a default in individual
+ * field documentation. Note that this may result in barely-usable channels, but since they
+ * are applied mostly only to incoming channels that's not much of a problem.
*/
-typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
+typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeChannelMonitorUpdate *inner;
+ LDKnativeChannelHandshakeLimits *inner;
bool is_owned;
-} LDKChannelMonitorUpdate;
+} LDKChannelHandshakeLimits;
/**
- * An event to be processed by the ChannelManager.
+ * Options which apply on a per-channel basis and may change at runtime or based on negotiation
+ * with our counterparty.
*/
-typedef struct MUST_USE_STRUCT LDKMonitorEvent {
+typedef struct MUST_USE_STRUCT LDKChannelConfig {
/**
* Nearly everywhere, inner must be non-null, however in places where
* the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKnativeMonitorEvent *inner;
+ LDKnativeChannelConfig *inner;
bool is_owned;
-} LDKMonitorEvent;
+} LDKChannelConfig;
-typedef struct LDKCVecTempl_MonitorEvent {
- struct LDKMonitorEvent *data;
- uintptr_t datalen;
-} LDKCVecTempl_MonitorEvent;
-typedef struct LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ;
/**
- * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
- * blocks are connected and disconnected.
- *
- * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
- * responsible for maintaining a set of monitors such that they can be updated accordingly as
- * channel state changes and HTLCs are resolved. See method documentation for specific
- * requirements.
- *
- * Implementations **must** ensure that updates are successfully applied and persisted upon method
- * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
- * without taking any further action such as persisting the current state.
- *
- * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
- * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
- * could result in a revoked transaction being broadcast, allowing the counterparty to claim all
- * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
- * multiple instances.
+ * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
*
- * [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html
- * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
- * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure
+ * Default::default() provides sane defaults for most configurations
+ * (but currently with 0 relay fees!)
*/
-typedef struct LDKWatch {
- void *this_arg;
+typedef struct MUST_USE_STRUCT LDKUserConfig {
/**
- * Watches a channel identified by `funding_txo` using `monitor`.
- *
- * Implementations are responsible for watching the chain for the funding transaction along
- * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
- * calling [`block_connected`] and [`block_disconnected`] on the monitor.
- *
- * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
- * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
- * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
*/
- LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor);
+ LDKnativeUserConfig *inner;
+ bool is_owned;
+} LDKUserConfig;
+
+typedef union LDKCResultPtr_TxOut__AccessError {
+ struct LDKTxOut *result;
+ enum LDKAccessError *err;
+} LDKCResultPtr_TxOut__AccessError;
+
+typedef struct LDKCResultTempl_TxOut__AccessError {
+ union LDKCResultPtr_TxOut__AccessError contents;
+ bool result_ok;
+} LDKCResultTempl_TxOut__AccessError;
+
+typedef struct LDKCResultTempl_TxOut__AccessError LDKCResult_TxOutAccessErrorZ;
+
+/**
+ * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
+ * UTXOs.
+ */
+typedef struct LDKAccess {
+ void *this_arg;
/**
- * Updates a channel identified by `funding_txo` by applying `update` to its monitor.
- *
- * Implementations must call [`update_monitor`] with the given update. See
- * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
+ * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
+ * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
+ * is unknown.
*
- * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
- * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
- */
- LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update);
- /**
- * Returns any monitor events since the last call. Subsequent calls must only return new
- * events.
+ * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
*/
- LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg);
+ LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id);
void (*free)(void *this_arg);
-} LDKWatch;
+} LDKAccess;
/**
* The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
void (*free)(void *this_arg);
} LDKFilter;
-/**
- * An interface to send a transaction to the Bitcoin network.
- */
-typedef struct LDKBroadcasterInterface {
- void *this_arg;
- /**
- * Sends a transaction out to (hopefully) be mined.
- */
- void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx);
- void (*free)(void *this_arg);
-} LDKBroadcasterInterface;
-
-/**
- * A trait which should be implemented to provide feerate information on a number of time
- * horizons.
- *
- * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
- * called from inside the library in response to chain events, P2P events, or timer events).
- */
-typedef struct LDKFeeEstimator {
- void *this_arg;
- /**
- * Gets estimated satoshis of fee required per 1000 Weight-Units.
- *
- * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
- * don't put us below 1 satoshi-per-byte).
- *
- * This translates to:
- * * satoshis-per-byte * 250
- * * ceil(satoshis-per-kbyte / 4)
- */
- uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target);
- void (*free)(void *this_arg);
-} LDKFeeEstimator;
-
/**
* `Persist` defines behavior for persisting channel monitors: this could mean
* writing once to disk, and/or uploading to one or more backup services.
typedef struct LDKCVecTempl_C2TupleTempl_usize__Transaction LDKCVec_C2Tuple_usizeTransactionZZ;
+typedef union LDKCResultPtr_ChannelMonitorUpdate__DecodeError {
+ struct LDKChannelMonitorUpdate *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_ChannelMonitorUpdate__DecodeError;
+
+typedef struct LDKCResultTempl_ChannelMonitorUpdate__DecodeError {
+ union LDKCResultPtr_ChannelMonitorUpdate__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_ChannelMonitorUpdate__DecodeError;
+
+typedef struct LDKCResultTempl_ChannelMonitorUpdate__DecodeError LDKCResult_ChannelMonitorUpdateDecodeErrorZ;
+
/**
typedef struct LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ;
-typedef struct LDKSecretKey {
- uint8_t bytes[32];
-} LDKSecretKey;
-
-
-
-/**
- * An error in decoding a message or struct.
- */
-typedef struct MUST_USE_STRUCT LDKDecodeError {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeDecodeError *inner;
- bool is_owned;
-} LDKDecodeError;
-
-typedef union LDKCResultPtr_ChannelKeys__DecodeError {
- struct LDKChannelKeys *result;
+typedef union LDKCResultPtr_C2TupleTempl_ThirtyTwoBytes__ChannelMonitor_____DecodeError {
+ struct LDKC2TupleTempl_ThirtyTwoBytes__ChannelMonitor *result;
struct LDKDecodeError *err;
-} LDKCResultPtr_ChannelKeys__DecodeError;
-
-typedef struct LDKCResultTempl_ChannelKeys__DecodeError {
- union LDKCResultPtr_ChannelKeys__DecodeError contents;
- bool result_ok;
-} LDKCResultTempl_ChannelKeys__DecodeError;
-
-typedef struct LDKCResultTempl_ChannelKeys__DecodeError LDKCResult_ChanKeySignerDecodeErrorZ;
-
-/**
- * A trait to describe an object which can get user secrets and key material.
- */
-typedef struct LDKKeysInterface {
- void *this_arg;
- /**
- * Get node secret key (aka node_id or network_key)
- */
- struct LDKSecretKey (*get_node_secret)(const void *this_arg);
- /**
- * Get destination redeemScript to encumber static protocol exit points.
- */
- LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
- /**
- * Get shutdown_pubkey to use as PublicKey at channel closure
- */
- struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
- /**
- * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
- * restarted with some stale data!
- */
- struct LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
- /**
- * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
- * onion packets and for temporary channel IDs. There is no requirement that these be
- * persisted anywhere, though they must be unique across restarts.
- */
- struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
- /**
- * Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream.
- * This is only called during deserialization of other objects which contain
- * `ChannelKeys`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s).
- * The bytes are exactly those which `<Self::ChanKeySigner as Writeable>::write()` writes, and
- * contain no versioning scheme. You may wish to include your own version prefix and ensure
- * you've read all of the provided bytes to ensure no corruption occurred.
- */
- LDKCResult_ChanKeySignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader);
- void (*free)(void *this_arg);
-} LDKKeysInterface;
+} LDKCResultPtr_C2TupleTempl_ThirtyTwoBytes__ChannelMonitor_____DecodeError;
+
+typedef struct LDKCResultTempl_C2TupleTempl_ThirtyTwoBytes__ChannelMonitor_____DecodeError {
+ union LDKCResultPtr_C2TupleTempl_ThirtyTwoBytes__ChannelMonitor_____DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_C2TupleTempl_ThirtyTwoBytes__ChannelMonitor_____DecodeError;
+
+typedef struct LDKCResultTempl_C2TupleTempl_ThirtyTwoBytes__ChannelMonitor_____DecodeError LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ;
+
+typedef union LDKCResultPtr_SpendableOutputDescriptor__DecodeError {
+ struct LDKSpendableOutputDescriptor *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_SpendableOutputDescriptor__DecodeError;
+
+typedef struct LDKCResultTempl_SpendableOutputDescriptor__DecodeError {
+ union LDKCResultPtr_SpendableOutputDescriptor__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_SpendableOutputDescriptor__DecodeError;
+
+typedef struct LDKCResultTempl_SpendableOutputDescriptor__DecodeError LDKCResult_SpendableOutputDescriptorDecodeErrorZ;
bool is_owned;
} LDKInMemoryChannelKeys;
+typedef union LDKCResultPtr_InMemoryChannelKeys__DecodeError {
+ struct LDKInMemoryChannelKeys *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_InMemoryChannelKeys__DecodeError;
+
+typedef struct LDKCResultTempl_InMemoryChannelKeys__DecodeError {
+ union LDKCResultPtr_InMemoryChannelKeys__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_InMemoryChannelKeys__DecodeError;
+
+typedef struct LDKCResultTempl_InMemoryChannelKeys__DecodeError LDKCResult_InMemoryChannelKeysDecodeErrorZ;
+
/**
-/**
- * Manager which keeps track of a number of channels and sends messages to the appropriate
- * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
- *
- * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
- * to individual Channels.
- *
- * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
- * all peers during write/read (though does not modify this instance, only the instance being
- * serialized). This will result in any channels which have not yet exchanged funding_created (ie
- * called funding_transaction_generated for outbound channels).
- *
- * Note that you can be a bit lazier about writing out ChannelManager than you can be with
- * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
- * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
- * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
- * the serialization process). If the deserialized version is out-of-date compared to the
- * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
- * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
- *
- * Note that the deserializer is only implemented for (Sha256dHash, ChannelManager), which
- * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
- * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
- * block_connected() to step towards your best block) upon deserialization before using the
- * object!
- *
- * Note that ChannelManager is responsible for tracking liveness of its channels and generating
- * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
- * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
- * offline for a full minute. In order to track this, you must call
- * timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfect.
- *
- * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
- * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
- * essentially you should default to using a SimpleRefChannelManager, and use a
- * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
- * you're using lightning-net-tokio.
- */
-typedef struct MUST_USE_STRUCT LDKChannelManager {
- /**
- * Nearly everywhere, inner must be non-null, however in places where
- * the Rust equivalent takes an Option, it may be set to null to indicate None.
- */
- LDKnativeChannelManager *inner;
- bool is_owned;
-} LDKChannelManager;
-
-
-
/**
* Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
*/
typedef struct LDKCVecTempl_ChannelMonitor LDKCVec_ChannelMonitorZ;
+typedef union LDKCResultPtr_C2TupleTempl_ThirtyTwoBytes__ChannelManager_____DecodeError {
+ struct LDKC2TupleTempl_ThirtyTwoBytes__ChannelManager *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_C2TupleTempl_ThirtyTwoBytes__ChannelManager_____DecodeError;
+
+typedef struct LDKCResultTempl_C2TupleTempl_ThirtyTwoBytes__ChannelManager_____DecodeError {
+ union LDKCResultPtr_C2TupleTempl_ThirtyTwoBytes__ChannelManager_____DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_C2TupleTempl_ThirtyTwoBytes__ChannelManager_____DecodeError;
+
+typedef struct LDKCResultTempl_C2TupleTempl_ThirtyTwoBytes__ChannelManager_____DecodeError LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ;
+
/**
bool is_owned;
} LDKDataLossProtect;
+typedef union LDKCResultPtr_NetAddress__u8 {
+ struct LDKNetAddress *result;
+ uint8_t *err;
+} LDKCResultPtr_NetAddress__u8;
+
+typedef struct LDKCResultTempl_NetAddress__u8 {
+ union LDKCResultPtr_NetAddress__u8 contents;
+ bool result_ok;
+} LDKCResultTempl_NetAddress__u8;
+
+typedef union LDKCResultPtr_CResultTempl_NetAddress__u8_____DecodeError {
+ struct LDKCResultTempl_NetAddress__u8 *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_CResultTempl_NetAddress__u8_____DecodeError;
+
+typedef struct LDKCResultTempl_CResultTempl_NetAddress__u8_____DecodeError {
+ union LDKCResultPtr_CResultTempl_NetAddress__u8_____DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_CResultTempl_NetAddress__u8_____DecodeError;
+
+typedef struct LDKCResultTempl_CResultTempl_NetAddress__u8_____DecodeError LDKCResult_CResult_NetAddressu8ZDecodeErrorZ;
+
/**
void (*free)(void *this_arg);
} LDKRoutingMessageHandler;
+typedef union LDKCResultPtr_ChannelReestablish__DecodeError {
+ struct LDKChannelReestablish *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_ChannelReestablish__DecodeError;
+
+typedef struct LDKCResultTempl_ChannelReestablish__DecodeError {
+ union LDKCResultPtr_ChannelReestablish__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_ChannelReestablish__DecodeError;
+
+typedef struct LDKCResultTempl_ChannelReestablish__DecodeError LDKCResult_ChannelReestablishDecodeErrorZ;
+
+typedef union LDKCResultPtr_Init__DecodeError {
+ struct LDKInit *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_Init__DecodeError;
+
+typedef struct LDKCResultTempl_Init__DecodeError {
+ union LDKCResultPtr_Init__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_Init__DecodeError;
+
+typedef struct LDKCResultTempl_Init__DecodeError LDKCResult_InitDecodeErrorZ;
+
+typedef union LDKCResultPtr_Ping__DecodeError {
+ struct LDKPing *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_Ping__DecodeError;
+
+typedef struct LDKCResultTempl_Ping__DecodeError {
+ union LDKCResultPtr_Ping__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_Ping__DecodeError;
+
+typedef struct LDKCResultTempl_Ping__DecodeError LDKCResult_PingDecodeErrorZ;
+
+typedef union LDKCResultPtr_Pong__DecodeError {
+ struct LDKPong *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_Pong__DecodeError;
+
+typedef struct LDKCResultTempl_Pong__DecodeError {
+ union LDKCResultPtr_Pong__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_Pong__DecodeError;
+
+typedef struct LDKCResultTempl_Pong__DecodeError LDKCResult_PongDecodeErrorZ;
+
+typedef union LDKCResultPtr_UnsignedChannelAnnouncement__DecodeError {
+ struct LDKUnsignedChannelAnnouncement *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_UnsignedChannelAnnouncement__DecodeError;
+
+typedef struct LDKCResultTempl_UnsignedChannelAnnouncement__DecodeError {
+ union LDKCResultPtr_UnsignedChannelAnnouncement__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_UnsignedChannelAnnouncement__DecodeError;
+
+typedef struct LDKCResultTempl_UnsignedChannelAnnouncement__DecodeError LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ;
+
+typedef union LDKCResultPtr_UnsignedChannelUpdate__DecodeError {
+ struct LDKUnsignedChannelUpdate *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_UnsignedChannelUpdate__DecodeError;
+
+typedef struct LDKCResultTempl_UnsignedChannelUpdate__DecodeError {
+ union LDKCResultPtr_UnsignedChannelUpdate__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_UnsignedChannelUpdate__DecodeError;
+
+typedef struct LDKCResultTempl_UnsignedChannelUpdate__DecodeError LDKCResult_UnsignedChannelUpdateDecodeErrorZ;
+
+typedef union LDKCResultPtr_ErrorMessage__DecodeError {
+ struct LDKErrorMessage *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_ErrorMessage__DecodeError;
+
+typedef struct LDKCResultTempl_ErrorMessage__DecodeError {
+ union LDKCResultPtr_ErrorMessage__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_ErrorMessage__DecodeError;
+
+typedef struct LDKCResultTempl_ErrorMessage__DecodeError LDKCResult_ErrorMessageDecodeErrorZ;
+
+typedef union LDKCResultPtr_UnsignedNodeAnnouncement__DecodeError {
+ struct LDKUnsignedNodeAnnouncement *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_UnsignedNodeAnnouncement__DecodeError;
+
+typedef struct LDKCResultTempl_UnsignedNodeAnnouncement__DecodeError {
+ union LDKCResultPtr_UnsignedNodeAnnouncement__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_UnsignedNodeAnnouncement__DecodeError;
+
+typedef struct LDKCResultTempl_UnsignedNodeAnnouncement__DecodeError LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ;
+
+typedef union LDKCResultPtr_QueryShortChannelIds__DecodeError {
+ struct LDKQueryShortChannelIds *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_QueryShortChannelIds__DecodeError;
+
+typedef struct LDKCResultTempl_QueryShortChannelIds__DecodeError {
+ union LDKCResultPtr_QueryShortChannelIds__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_QueryShortChannelIds__DecodeError;
+
+typedef struct LDKCResultTempl_QueryShortChannelIds__DecodeError LDKCResult_QueryShortChannelIdsDecodeErrorZ;
+
+typedef union LDKCResultPtr_ReplyShortChannelIdsEnd__DecodeError {
+ struct LDKReplyShortChannelIdsEnd *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_ReplyShortChannelIdsEnd__DecodeError;
+
+typedef struct LDKCResultTempl_ReplyShortChannelIdsEnd__DecodeError {
+ union LDKCResultPtr_ReplyShortChannelIdsEnd__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_ReplyShortChannelIdsEnd__DecodeError;
+
+typedef struct LDKCResultTempl_ReplyShortChannelIdsEnd__DecodeError LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ;
+
+typedef union LDKCResultPtr_QueryChannelRange__DecodeError {
+ struct LDKQueryChannelRange *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_QueryChannelRange__DecodeError;
+
+typedef struct LDKCResultTempl_QueryChannelRange__DecodeError {
+ union LDKCResultPtr_QueryChannelRange__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_QueryChannelRange__DecodeError;
+
+typedef struct LDKCResultTempl_QueryChannelRange__DecodeError LDKCResult_QueryChannelRangeDecodeErrorZ;
+
+typedef union LDKCResultPtr_ReplyChannelRange__DecodeError {
+ struct LDKReplyChannelRange *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_ReplyChannelRange__DecodeError;
+
+typedef struct LDKCResultTempl_ReplyChannelRange__DecodeError {
+ union LDKCResultPtr_ReplyChannelRange__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_ReplyChannelRange__DecodeError;
+
+typedef struct LDKCResultTempl_ReplyChannelRange__DecodeError LDKCResult_ReplyChannelRangeDecodeErrorZ;
+
+typedef union LDKCResultPtr_GossipTimestampFilter__DecodeError {
+ struct LDKGossipTimestampFilter *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_GossipTimestampFilter__DecodeError;
+
+typedef struct LDKCResultTempl_GossipTimestampFilter__DecodeError {
+ union LDKCResultPtr_GossipTimestampFilter__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_GossipTimestampFilter__DecodeError;
+
+typedef struct LDKCResultTempl_GossipTimestampFilter__DecodeError LDKCResult_GossipTimestampFilterDecodeErrorZ;
+
/**
typedef struct LDKCVecTempl_CVecTempl_RouteHop LDKCVec_CVec_RouteHopZZ;
+typedef union LDKCResultPtr_Route__DecodeError {
+ struct LDKRoute *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_Route__DecodeError;
+
+typedef struct LDKCResultTempl_Route__DecodeError {
+ union LDKCResultPtr_Route__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_Route__DecodeError;
+
+typedef struct LDKCResultTempl_Route__DecodeError LDKCResult_RouteDecodeErrorZ;
+
/**
bool is_owned;
} LDKChannelInfo;
+typedef union LDKCResultPtr_RoutingFees__DecodeError {
+ struct LDKRoutingFees *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_RoutingFees__DecodeError;
+
+typedef struct LDKCResultTempl_RoutingFees__DecodeError {
+ union LDKCResultPtr_RoutingFees__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_RoutingFees__DecodeError;
+
+typedef struct LDKCResultTempl_RoutingFees__DecodeError LDKCResult_RoutingFeesDecodeErrorZ;
+
/**
bool is_owned;
} LDKNodeAnnouncementInfo;
+typedef union LDKCResultPtr_NodeAnnouncementInfo__DecodeError {
+ struct LDKNodeAnnouncementInfo *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_NodeAnnouncementInfo__DecodeError;
+
+typedef struct LDKCResultTempl_NodeAnnouncementInfo__DecodeError {
+ union LDKCResultPtr_NodeAnnouncementInfo__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_NodeAnnouncementInfo__DecodeError;
+
+typedef struct LDKCResultTempl_NodeAnnouncementInfo__DecodeError LDKCResult_NodeAnnouncementInfoDecodeErrorZ;
+
/**
bool is_owned;
} LDKNodeInfo;
+typedef union LDKCResultPtr_NodeInfo__DecodeError {
+ struct LDKNodeInfo *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_NodeInfo__DecodeError;
+
+typedef struct LDKCResultTempl_NodeInfo__DecodeError {
+ union LDKCResultPtr_NodeInfo__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_NodeInfo__DecodeError;
+
+typedef struct LDKCResultTempl_NodeInfo__DecodeError LDKCResult_NodeInfoDecodeErrorZ;
+
+typedef union LDKCResultPtr_NetworkGraph__DecodeError {
+ struct LDKNetworkGraph *result;
+ struct LDKDecodeError *err;
+} LDKCResultPtr_NetworkGraph__DecodeError;
+
+typedef struct LDKCResultTempl_NetworkGraph__DecodeError {
+ union LDKCResultPtr_NetworkGraph__DecodeError contents;
+ bool result_ok;
+} LDKCResultTempl_NetworkGraph__DecodeError;
+
+typedef struct LDKCResultTempl_NetworkGraph__DecodeError LDKCResult_NetworkGraphDecodeErrorZ;
+
+typedef struct LDKCResultTempl_NetAddress__u8 LDKCResult_NetAddressu8Z;
+
typedef struct LDKCVecTempl_RouteHop LDKCVec_RouteHopZ;
extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ);
extern const void (*CVec_MonitorEventZ_free)(LDKCVec_MonitorEventZ);
+extern const void (*CResult_ChannelMonitorUpdateDecodeErrorZ_free)(LDKCResult_ChannelMonitorUpdateDecodeErrorZ);
+
+extern const LDKCResult_ChannelMonitorUpdateDecodeErrorZ (*CResult_ChannelMonitorUpdateDecodeErrorZ_ok)(struct LDKChannelMonitorUpdate);
+
+extern const LDKCResult_ChannelMonitorUpdateDecodeErrorZ (*CResult_ChannelMonitorUpdateDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*CResult_NoneMonitorUpdateErrorZ_free)(LDKCResult_NoneMonitorUpdateErrorZ);
extern const LDKCResult_NoneMonitorUpdateErrorZ (*CResult_NoneMonitorUpdateErrorZ_err)(struct LDKMonitorUpdateError);
extern const void (*CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free)(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ);
+extern const void (*C2Tuple_BlockHashChannelMonitorZ_free)(LDKC2Tuple_BlockHashChannelMonitorZ);
+
+extern const void (*CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free)(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ);
+
+extern const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ (*CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok)(LDKC2Tuple_BlockHashChannelMonitorZ);
+
+extern const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ (*CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*C2Tuple_u64u64Z_free)(LDKC2Tuple_u64u64Z);
+extern const void (*CResult_SpendableOutputDescriptorDecodeErrorZ_free)(LDKCResult_SpendableOutputDescriptorDecodeErrorZ);
+
+extern const LDKCResult_SpendableOutputDescriptorDecodeErrorZ (*CResult_SpendableOutputDescriptorDecodeErrorZ_ok)(struct LDKSpendableOutputDescriptor);
+
+extern const LDKCResult_SpendableOutputDescriptorDecodeErrorZ (*CResult_SpendableOutputDescriptorDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*CVec_SignatureZ_free)(LDKCVec_SignatureZ);
extern const void (*C2Tuple_SignatureCVec_SignatureZZ_free)(LDKC2Tuple_SignatureCVec_SignatureZZ);
extern const LDKCResult_ChanKeySignerDecodeErrorZ (*CResult_ChanKeySignerDecodeErrorZ_err)(struct LDKDecodeError);
+extern const void (*CResult_InMemoryChannelKeysDecodeErrorZ_free)(LDKCResult_InMemoryChannelKeysDecodeErrorZ);
+
+extern const LDKCResult_InMemoryChannelKeysDecodeErrorZ (*CResult_InMemoryChannelKeysDecodeErrorZ_ok)(struct LDKInMemoryChannelKeys);
+
+extern const LDKCResult_InMemoryChannelKeysDecodeErrorZ (*CResult_InMemoryChannelKeysDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*CResult_TxOutAccessErrorZ_free)(LDKCResult_TxOutAccessErrorZ);
extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_ok)(struct LDKTxOut);
extern const void (*CVec_ChannelMonitorZ_free)(LDKCVec_ChannelMonitorZ);
+extern const void (*C2Tuple_BlockHashChannelManagerZ_free)(LDKC2Tuple_BlockHashChannelManagerZ);
+
+extern const void (*CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free)(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ);
+
+extern const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ (*CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok)(LDKC2Tuple_BlockHashChannelManagerZ);
+
+extern const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ (*CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_NetAddressu8Z_free)(LDKCResult_NetAddressu8Z);
+
+extern const LDKCResult_NetAddressu8Z (*CResult_NetAddressu8Z_ok)(struct LDKNetAddress);
+
+extern const LDKCResult_NetAddressu8Z (*CResult_NetAddressu8Z_err)(uint8_t);
+
+extern const void (*CResult_CResult_NetAddressu8ZDecodeErrorZ_free)(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ);
+
+extern const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ (*CResult_CResult_NetAddressu8ZDecodeErrorZ_ok)(LDKCResult_NetAddressu8Z);
+
+extern const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ (*CResult_CResult_NetAddressu8ZDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*CVec_u64Z_free)(LDKCVec_u64Z);
extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ);
extern const LDKCResult_NoneLightningErrorZ (*CResult_NoneLightningErrorZ_err)(struct LDKLightningError);
+extern const void (*CResult_ChannelReestablishDecodeErrorZ_free)(LDKCResult_ChannelReestablishDecodeErrorZ);
+
+extern const LDKCResult_ChannelReestablishDecodeErrorZ (*CResult_ChannelReestablishDecodeErrorZ_ok)(struct LDKChannelReestablish);
+
+extern const LDKCResult_ChannelReestablishDecodeErrorZ (*CResult_ChannelReestablishDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_InitDecodeErrorZ_free)(LDKCResult_InitDecodeErrorZ);
+
+extern const LDKCResult_InitDecodeErrorZ (*CResult_InitDecodeErrorZ_ok)(struct LDKInit);
+
+extern const LDKCResult_InitDecodeErrorZ (*CResult_InitDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_PingDecodeErrorZ_free)(LDKCResult_PingDecodeErrorZ);
+
+extern const LDKCResult_PingDecodeErrorZ (*CResult_PingDecodeErrorZ_ok)(struct LDKPing);
+
+extern const LDKCResult_PingDecodeErrorZ (*CResult_PingDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_PongDecodeErrorZ_free)(LDKCResult_PongDecodeErrorZ);
+
+extern const LDKCResult_PongDecodeErrorZ (*CResult_PongDecodeErrorZ_ok)(struct LDKPong);
+
+extern const LDKCResult_PongDecodeErrorZ (*CResult_PongDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_UnsignedChannelAnnouncementDecodeErrorZ_free)(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ);
+
+extern const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ (*CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok)(struct LDKUnsignedChannelAnnouncement);
+
+extern const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ (*CResult_UnsignedChannelAnnouncementDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_UnsignedChannelUpdateDecodeErrorZ_free)(LDKCResult_UnsignedChannelUpdateDecodeErrorZ);
+
+extern const LDKCResult_UnsignedChannelUpdateDecodeErrorZ (*CResult_UnsignedChannelUpdateDecodeErrorZ_ok)(struct LDKUnsignedChannelUpdate);
+
+extern const LDKCResult_UnsignedChannelUpdateDecodeErrorZ (*CResult_UnsignedChannelUpdateDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_ErrorMessageDecodeErrorZ_free)(LDKCResult_ErrorMessageDecodeErrorZ);
+
+extern const LDKCResult_ErrorMessageDecodeErrorZ (*CResult_ErrorMessageDecodeErrorZ_ok)(struct LDKErrorMessage);
+
+extern const LDKCResult_ErrorMessageDecodeErrorZ (*CResult_ErrorMessageDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_UnsignedNodeAnnouncementDecodeErrorZ_free)(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ);
+
+extern const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ (*CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok)(struct LDKUnsignedNodeAnnouncement);
+
+extern const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ (*CResult_UnsignedNodeAnnouncementDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_QueryShortChannelIdsDecodeErrorZ_free)(LDKCResult_QueryShortChannelIdsDecodeErrorZ);
+
+extern const LDKCResult_QueryShortChannelIdsDecodeErrorZ (*CResult_QueryShortChannelIdsDecodeErrorZ_ok)(struct LDKQueryShortChannelIds);
+
+extern const LDKCResult_QueryShortChannelIdsDecodeErrorZ (*CResult_QueryShortChannelIdsDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_ReplyShortChannelIdsEndDecodeErrorZ_free)(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ);
+
+extern const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ (*CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok)(struct LDKReplyShortChannelIdsEnd);
+
+extern const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ (*CResult_ReplyShortChannelIdsEndDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_QueryChannelRangeDecodeErrorZ_free)(LDKCResult_QueryChannelRangeDecodeErrorZ);
+
+extern const LDKCResult_QueryChannelRangeDecodeErrorZ (*CResult_QueryChannelRangeDecodeErrorZ_ok)(struct LDKQueryChannelRange);
+
+extern const LDKCResult_QueryChannelRangeDecodeErrorZ (*CResult_QueryChannelRangeDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_ReplyChannelRangeDecodeErrorZ_free)(LDKCResult_ReplyChannelRangeDecodeErrorZ);
+
+extern const LDKCResult_ReplyChannelRangeDecodeErrorZ (*CResult_ReplyChannelRangeDecodeErrorZ_ok)(struct LDKReplyChannelRange);
+
+extern const LDKCResult_ReplyChannelRangeDecodeErrorZ (*CResult_ReplyChannelRangeDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_GossipTimestampFilterDecodeErrorZ_free)(LDKCResult_GossipTimestampFilterDecodeErrorZ);
+
+extern const LDKCResult_GossipTimestampFilterDecodeErrorZ (*CResult_GossipTimestampFilterDecodeErrorZ_ok)(struct LDKGossipTimestampFilter);
+
+extern const LDKCResult_GossipTimestampFilterDecodeErrorZ (*CResult_GossipTimestampFilterDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*CVec_PublicKeyZ_free)(LDKCVec_PublicKeyZ);
extern const void (*CVec_u8Z_free)(LDKCVec_u8Z);
extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ);
+extern const void (*CResult_RouteDecodeErrorZ_free)(LDKCResult_RouteDecodeErrorZ);
+
+extern const LDKCResult_RouteDecodeErrorZ (*CResult_RouteDecodeErrorZ_ok)(struct LDKRoute);
+
+extern const LDKCResult_RouteDecodeErrorZ (*CResult_RouteDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const void (*CVec_RouteHintZ_free)(LDKCVec_RouteHintZ);
extern const void (*CResult_RouteLightningErrorZ_free)(LDKCResult_RouteLightningErrorZ);
extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_err)(struct LDKLightningError);
+extern const void (*CResult_RoutingFeesDecodeErrorZ_free)(LDKCResult_RoutingFeesDecodeErrorZ);
+
+extern const LDKCResult_RoutingFeesDecodeErrorZ (*CResult_RoutingFeesDecodeErrorZ_ok)(struct LDKRoutingFees);
+
+extern const LDKCResult_RoutingFeesDecodeErrorZ (*CResult_RoutingFeesDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_NodeAnnouncementInfoDecodeErrorZ_free)(LDKCResult_NodeAnnouncementInfoDecodeErrorZ);
+
+extern const LDKCResult_NodeAnnouncementInfoDecodeErrorZ (*CResult_NodeAnnouncementInfoDecodeErrorZ_ok)(struct LDKNodeAnnouncementInfo);
+
+extern const LDKCResult_NodeAnnouncementInfoDecodeErrorZ (*CResult_NodeAnnouncementInfoDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_NodeInfoDecodeErrorZ_free)(LDKCResult_NodeInfoDecodeErrorZ);
+
+extern const LDKCResult_NodeInfoDecodeErrorZ (*CResult_NodeInfoDecodeErrorZ_ok)(struct LDKNodeInfo);
+
+extern const LDKCResult_NodeInfoDecodeErrorZ (*CResult_NodeInfoDecodeErrorZ_err)(struct LDKDecodeError);
+
+extern const void (*CResult_NetworkGraphDecodeErrorZ_free)(LDKCResult_NetworkGraphDecodeErrorZ);
+
+extern const LDKCResult_NetworkGraphDecodeErrorZ (*CResult_NetworkGraphDecodeErrorZ_ok)(struct LDKNetworkGraph);
+
+extern const LDKCResult_NetworkGraphDecodeErrorZ (*CResult_NetworkGraphDecodeErrorZ_err)(struct LDKDecodeError);
+
extern const uintptr_t MAX_BUF_SIZE;
extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, LDKCVec_C2Tuple_u32TxOutZZ b);
+LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b);
+
LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b);
LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, LDKCVec_SignatureZ b);
LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void);
+LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b);
+
LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c);
LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void);
struct LDKEvent Event_clone(const struct LDKEvent *orig);
+LDKCVec_u8Z Event_write(const struct LDKEvent *obj);
+
void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr);
struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *orig);
LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *obj);
-struct LDKChannelMonitorUpdate ChannelMonitorUpdate_read(struct LDKu8slice ser);
+LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser);
enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *orig);
void ChannelMonitor_free(struct LDKChannelMonitor this_ptr);
+LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *obj);
+
/**
* Updates a ChannelMonitor on the basis of some new information provided by the Channel
* itself.
*/
void Persist_free(struct LDKPersist this_ptr);
+LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *arg);
+
void OutPoint_free(struct LDKOutPoint this_ptr);
struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *orig);
struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *orig);
+LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *obj);
+
+LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser);
+
struct LDKChannelKeys ChannelKeys_clone(const struct LDKChannelKeys *orig);
/**
LDKCVec_u8Z InMemoryChannelKeys_write(const struct LDKInMemoryChannelKeys *obj);
-struct LDKInMemoryChannelKeys InMemoryChannelKeys_read(struct LDKu8slice ser);
+LDKCResult_InMemoryChannelKeysDecodeErrorZ InMemoryChannelKeys_read(struct LDKu8slice ser);
void KeysManager_free(struct LDKKeysManager this_ptr);
struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *this_arg);
+LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *obj);
+
void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_ptr);
/**
*/
MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors);
+LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg);
+
void DecodeError_free(struct LDKDecodeError this_ptr);
void Init_free(struct LDKInit this_ptr);
struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *orig);
+LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *obj);
+
+LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser);
+
void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_ptr);
struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *orig);
LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *obj);
-struct LDKChannelReestablish ChannelReestablish_read(struct LDKu8slice ser);
+LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser);
LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *obj);
LDKCVec_u8Z Init_write(const struct LDKInit *obj);
-struct LDKInit Init_read(struct LDKu8slice ser);
+LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser);
LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *obj);
LDKCVec_u8Z Ping_write(const struct LDKPing *obj);
-struct LDKPing Ping_read(struct LDKu8slice ser);
+LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser);
LDKCVec_u8Z Pong_write(const struct LDKPong *obj);
-struct LDKPong Pong_read(struct LDKu8slice ser);
+LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser);
LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *obj);
-struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_read(struct LDKu8slice ser);
+LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser);
LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *obj);
LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *obj);
-struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_read(struct LDKu8slice ser);
+LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser);
LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *obj);
LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *obj);
-struct LDKErrorMessage ErrorMessage_read(struct LDKu8slice ser);
+LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser);
LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *obj);
-struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_read(struct LDKu8slice ser);
+LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser);
LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *obj);
struct LDKNodeAnnouncement NodeAnnouncement_read(struct LDKu8slice ser);
-struct LDKQueryShortChannelIds QueryShortChannelIds_read(struct LDKu8slice ser);
+LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser);
LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *obj);
-struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_read(struct LDKu8slice ser);
+LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser);
LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *obj);
-struct LDKQueryChannelRange QueryChannelRange_read(struct LDKu8slice ser);
+LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser);
LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *obj);
-struct LDKReplyChannelRange ReplyChannelRange_read(struct LDKu8slice ser);
+LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser);
LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *obj);
-struct LDKGossipTimestampFilter GossipTimestampFilter_read(struct LDKu8slice ser);
+LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser);
LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *obj);
LDKCVec_u8Z Route_write(const struct LDKRoute *obj);
-struct LDKRoute Route_read(struct LDKu8slice ser);
+LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser);
void RouteHint_free(struct LDKRouteHint this_ptr);
MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg);
-struct LDKRoutingFees RoutingFees_read(struct LDKu8slice ser);
+LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser);
LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *obj);
LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *obj);
-struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(struct LDKu8slice ser);
+LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser);
void NodeInfo_free(struct LDKNodeInfo this_ptr);
LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *obj);
-struct LDKNodeInfo NodeInfo_read(struct LDKu8slice ser);
+LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser);
LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *obj);
-struct LDKNetworkGraph NetworkGraph_read(struct LDKu8slice ser);
+LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser);
/**
* Creates a new, empty, network graph.