From: Matt Corallo Date: Thu, 29 Apr 2021 18:58:26 +0000 (+0000) Subject: Update auto-generated bindings with lightning-invoice X-Git-Tag: v0.0.98~10^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=5a2c2e157fd16d664a28bf3f7fe58d2216dd43d7;p=ldk-c-bindings Update auto-generated bindings with lightning-invoice --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 4ae3d0b..fba5cc1 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -1,7 +1,7 @@ #ifndef LDK_C_BINDINGS_H #define LDK_C_BINDINGS_H -/* Generated with cbindgen:0.16.0 */ +/* Generated with cbindgen:0.19.0 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -121,6 +121,58 @@ typedef enum LDKConfirmationTarget { LDKConfirmationTarget_Sentinel, } LDKConfirmationTarget; +/** + * Errors that may occur when constructing a new `RawInvoice` or `Invoice` + */ +typedef enum LDKCreationError { + /** + * The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new)) + */ + LDKCreationError_DescriptionTooLong, + /** + * The specified route has too many hops and can't be encoded + */ + LDKCreationError_RouteTooLong, + /** + * The unix timestamp of the supplied date is <0 or can't be represented as `SystemTime` + */ + LDKCreationError_TimestampOutOfBounds, + /** + * The supplied expiry time could cause an overflow if added to a `PositiveTimestamp` + */ + LDKCreationError_ExpiryTimeOutOfBounds, + /** + * Must be last for serialization purposes + */ + LDKCreationError_Sentinel, +} LDKCreationError; + +/** + * Enum representing the crypto currencies (or networks) supported by this library + */ +typedef enum LDKCurrency { + /** + * Bitcoin mainnet + */ + LDKCurrency_Bitcoin, + /** + * Bitcoin testnet + */ + LDKCurrency_BitcoinTestnet, + /** + * Bitcoin regtest + */ + LDKCurrency_Regtest, + /** + * Bitcoin simnet/signet + */ + LDKCurrency_Simnet, + /** + * Must be last for serialization purposes + */ + LDKCurrency_Sentinel, +} LDKCurrency; + /** * Represents an IO Error. Note that some information is lost in the conversion from Rust. */ @@ -255,6 +307,67 @@ typedef enum LDKSecp256k1Error { LDKSecp256k1Error_Sentinel, } LDKSecp256k1Error; +/** + * Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the + * requirements sections in BOLT #11 + */ +typedef enum LDKSemanticError { + /** + * The invoice is missing the mandatory payment hash + */ + LDKSemanticError_NoPaymentHash, + /** + * The invoice has multiple payment hashes which isn't allowed + */ + LDKSemanticError_MultiplePaymentHashes, + /** + * No description or description hash are part of the invoice + */ + LDKSemanticError_NoDescription, + /** + * The invoice contains multiple descriptions and/or description hashes which isn't allowed + */ + LDKSemanticError_MultipleDescriptions, + /** + * The recovery id doesn't fit the signature/pub key + */ + LDKSemanticError_InvalidRecoveryId, + /** + * The invoice's signature is invalid + */ + LDKSemanticError_InvalidSignature, + /** + * Must be last for serialization purposes + */ + LDKSemanticError_Sentinel, +} LDKSemanticError; + +/** + * SI prefixes for the human readable part + */ +typedef enum LDKSiPrefix { + /** + * 10^-3 + */ + LDKSiPrefix_Milli, + /** + * 10^-6 + */ + LDKSiPrefix_Micro, + /** + * 10^-9 + */ + LDKSiPrefix_Nano, + /** + * 10^-12 + */ + LDKSiPrefix_Pico, + /** + * Must be last for serialization purposes + */ + LDKSiPrefix_Sentinel, +} LDKSiPrefix; + /** * A serialized transaction, in (pointer, length) form. * @@ -318,6 +431,25 @@ typedef struct LDKTxOut { uint64_t value; } LDKTxOut; +/** + * 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 { + /** + * A pointer to the string's bytes, in UTF8 encoding + */ + const uint8_t *chars; + /** + * The number of bytes (not characters!) pointed to by `chars` + */ + uintptr_t len; + /** + * Whether the data pointed to by `chars` should be freed or not. + */ + bool chars_is_owned; +} LDKStr; + /** @@ -1154,14656 +1286,16199 @@ typedef struct LDKCResult_CVec_SignatureZNoneZ { bool result_ok; } LDKCResult_CVec_SignatureZNoneZ; -/** - * The contents of CResult_StringErrorZ - */ -typedef union LDKCResult_StringErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKCVec_u8Z *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKSecp256k1Error *err; -} LDKCResult_StringErrorZPtr; + /** - * A CResult_StringErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_u8Z on success and a crate::c_types::Secp256k1Error on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * SHA-256 hash */ -typedef struct LDKCResult_StringErrorZ { +typedef struct MUST_USE_STRUCT LDKSha256 { /** - * The contents of this CResult_StringErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_StringErrorZPtr contents; + LDKnativeSha256 *inner; /** - * Whether this CResult_StringErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_StringErrorZ; + bool is_owned; +} LDKSha256; /** - * An update generated by the underlying Channel itself which contains some new information the - * ChannelMonitor should be made aware of. + * Description string + * + * # Invariants + * The description can be at most 639 __bytes__ long */ -typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { +typedef struct MUST_USE_STRUCT LDKDescription { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativeDescription *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelMonitorUpdate; +} LDKDescription; + + /** - * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + * Payee public key */ -typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKPayeePubKey { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKChannelMonitorUpdate *result; + LDKnativePayeePubKey *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; + bool is_owned; +} LDKPayeePubKey; + + /** - * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Positive duration that defines when (relatively to the timestamp) in the future the invoice + * expires + * + * # Invariants + * The number of seconds this expiry time represents has to be in the range + * `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a + * timestamp */ -typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKExpiryTime { /** - * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; + LDKnativeExpiryTime *inner; /** - * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; + bool is_owned; +} LDKExpiryTime; /** - * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on - * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the - * preimage claim backward will lead to loss of funds. + * `min_final_cltv_expiry` to use for the last HTLC in the route */ -typedef struct MUST_USE_STRUCT LDKHTLCUpdate { +typedef struct MUST_USE_STRUCT LDKMinFinalCltvExpiry { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeHTLCUpdate *inner; + LDKnativeMinFinalCltvExpiry *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKHTLCUpdate; +} LDKMinFinalCltvExpiry; /** - * The contents of CResult_HTLCUpdateDecodeErrorZ + * Integer in the range `0..32` */ -typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKHTLCUpdate *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_HTLCUpdateDecodeErrorZPtr; +typedef struct LDKu5 { + uint8_t _0; +} LDKu5; /** - * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A 20-byte byte array. */ -typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { +typedef struct LDKTwentyBytes { /** - * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The twenty bytes */ - union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; + uint8_t data[20]; +} LDKTwentyBytes; + +/** + * Fallback address in case no LN payment is possible + */ +typedef enum LDKFallback_Tag { + LDKFallback_SegWitProgram, + LDKFallback_PubKeyHash, + LDKFallback_ScriptHash, /** - * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_HTLCUpdateDecodeErrorZ; + LDKFallback_Sentinel, +} LDKFallback_Tag; + +typedef struct LDKFallback_LDKSegWitProgram_Body { + struct LDKu5 version; + struct LDKCVec_u8Z program; +} LDKFallback_LDKSegWitProgram_Body; + +typedef struct MUST_USE_STRUCT LDKFallback { + LDKFallback_Tag tag; + union { + LDKFallback_LDKSegWitProgram_Body seg_wit_program; + struct { + struct LDKTwentyBytes pub_key_hash; + }; + struct { + struct LDKTwentyBytes script_hash; + }; + }; +} LDKFallback; /** - * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is - * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this - * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was - * corrupted. - * Contains a developer-readable error message. + * Private routing information + * + * # Invariants + * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) + * */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateError { +typedef struct MUST_USE_STRUCT LDKRouteHint { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMonitorUpdateError *inner; + LDKnativeRouteHint *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKMonitorUpdateError; +} LDKRouteHint; + + /** - * The contents of CResult_NoneMonitorUpdateErrorZ + * 256-bit payment secret */ -typedef union LDKCResult_NoneMonitorUpdateErrorZPtr { +typedef struct MUST_USE_STRUCT LDKPaymentSecret { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *result; + LDKnativePaymentSecret *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKMonitorUpdateError *err; -} LDKCResult_NoneMonitorUpdateErrorZPtr; + bool is_owned; +} LDKPaymentSecret; + + /** - * A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::chain::channelmonitor::MonitorUpdateError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Features used within an invoice. */ -typedef struct LDKCResult_NoneMonitorUpdateErrorZ { +typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { /** - * The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_NoneMonitorUpdateErrorZPtr contents; + LDKnativeInvoiceFeatures *inner; /** - * Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_NoneMonitorUpdateErrorZ; + bool is_owned; +} LDKInvoiceFeatures; /** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_OutPointScriptZ { - /** - * The element at position 0 - */ - struct LDKOutPoint a; + * Tagged field with known tag + * + * For descriptions of the enum values please refer to the enclosed type's docs. + */ +typedef enum LDKTaggedField_Tag { + LDKTaggedField_PaymentHash, + LDKTaggedField_Description, + LDKTaggedField_PayeePubKey, + LDKTaggedField_DescriptionHash, + LDKTaggedField_ExpiryTime, + LDKTaggedField_MinFinalCltvExpiry, + LDKTaggedField_Fallback, + LDKTaggedField_Route, + LDKTaggedField_PaymentSecret, + LDKTaggedField_Features, /** - * The element at position 1 + * Must be last for serialization purposes */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_OutPointScriptZ; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_u32ScriptZ { - /** - * The element at position 0 - */ - uint32_t a; - /** - * The element at position 1 - */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_u32ScriptZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_u32ScriptZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_u32ScriptZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32ScriptZZ; - -/** - * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to - * look up the corresponding function in rust-lightning's docs. - */ -typedef struct LDKThirtyTwoBytes { - /** - * The thirty-two bytes - */ - uint8_t data[32]; -} LDKThirtyTwoBytes; + LDKTaggedField_Sentinel, +} LDKTaggedField_Tag; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKCVec_C2Tuple_u32ScriptZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; +typedef struct MUST_USE_STRUCT LDKTaggedField { + LDKTaggedField_Tag tag; + union { + struct { + struct LDKSha256 payment_hash; + }; + struct { + struct LDKDescription description; + }; + struct { + struct LDKPayeePubKey payee_pub_key; + }; + struct { + struct LDKSha256 description_hash; + }; + struct { + struct LDKExpiryTime expiry_time; + }; + struct { + struct LDKMinFinalCltvExpiry min_final_cltv_expiry; + }; + struct { + struct LDKFallback fallback; + }; + struct { + struct LDKRouteHint route; + }; + struct { + struct LDKPaymentSecret payment_secret; + }; + struct { + struct LDKInvoiceFeatures features; + }; + }; +} LDKTaggedField; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::u5s of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +typedef struct LDKCVec_u5Z { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; + struct LDKu5 *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; +} LDKCVec_u5Z; /** - * An event to be processed by the ChannelManager. + * Tagged field which may have an unknown tag */ -typedef enum LDKMonitorEvent_Tag { +typedef enum LDKRawTaggedField_Tag { /** - * A monitor event containing an HTLCUpdate. + * Parsed tagged field with known tag */ - LDKMonitorEvent_HTLCEvent, + LDKRawTaggedField_KnownSemantics, /** - * A monitor event that the Channel's commitment transaction was broadcasted. + * tagged field which was not parsed due to an unknown tag or undefined field semantics */ - LDKMonitorEvent_CommitmentTxBroadcasted, + LDKRawTaggedField_UnknownSemantics, /** * Must be last for serialization purposes */ - LDKMonitorEvent_Sentinel, -} LDKMonitorEvent_Tag; + LDKRawTaggedField_Sentinel, +} LDKRawTaggedField_Tag; -typedef struct MUST_USE_STRUCT LDKMonitorEvent { - LDKMonitorEvent_Tag tag; +typedef struct MUST_USE_STRUCT LDKRawTaggedField { + LDKRawTaggedField_Tag tag; union { struct { - struct LDKHTLCUpdate htlc_event; + struct LDKTaggedField known_semantics; }; struct { - struct LDKOutPoint commitment_tx_broadcasted; + struct LDKCVec_u5Z unknown_semantics; }; }; -} LDKMonitorEvent; +} LDKRawTaggedField; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. + * A dynamically-allocated array of crate::lightning_invoice::RawTaggedFields of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_MonitorEventZ { +typedef struct LDKCVec_RawTaggedFieldZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKMonitorEvent *data; + struct LDKRawTaggedField *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_MonitorEventZ; +} LDKCVec_RawTaggedFieldZ; /** - * Information about a spendable output to a P2WSH script. See - * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. + * Represents an syntactically correct Invoice for a payment on the lightning network, + * but without the signature information. + * De- and encoding should not lead to information loss but may lead to different hashes. + * + * For methods without docs see the corresponding methods in `Invoice`. */ -typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKRawInvoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDelayedPaymentOutputDescriptor *inner; + LDKnativeRawInvoice *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDelayedPaymentOutputDescriptor; +} LDKRawInvoice; + +/** + * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to + * look up the corresponding function in rust-lightning's docs. + */ +typedef struct LDKThirtyTwoBytes { + /** + * The thirty-two bytes + */ + uint8_t data[32]; +} LDKThirtyTwoBytes; /** - * Information about a spendable output to our \"payment key\". See - * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. + * Recoverable signature */ -typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKInvoiceSignature { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeStaticPaymentOutputDescriptor *inner; + LDKnativeInvoiceSignature *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKStaticPaymentOutputDescriptor; +} LDKInvoiceSignature; /** - * 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 tuple of 3 elements. See the individual fields for the types contained. */ -typedef enum LDKSpendableOutputDescriptor_Tag { +typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { /** - * An output to a script which was provided via KeysInterface directly, either from - * `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to - * spend it. No secret keys are provided as rust-lightning was never given any key. - * These may include outputs from a transaction punishing our counterparty or claiming an HTLC - * on-chain using the payment preimage or after it has timed out. + * The element at position 0 */ - LDKSpendableOutputDescriptor_StaticOutput, + struct LDKRawInvoice a; /** - * An output to a P2WSH script which can be spent with a single signature after a CSV delay. - * - * The witness in the spending input should be: - * (MINIMALIF standard rule) - * - * Note that the nSequence field in the spending input must be set to to_self_delay - * (which means the transaction is not broadcastable until at least to_self_delay - * blocks after the outpoint confirms). - * - * These are generally the result of a \"revocable\" output to us, spendable only by us unless - * it is an output from an old state which we broadcast (which should never happen). - * - * To derive the delayed_payment key which is used to sign for this input, you must pass the - * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in - * Sign::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to - * chan_utils::derive_private_key. The public key can be generated without the secret key - * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in - * Sign::pubkeys(). - * - * To derive the revocation_pubkey provided here (which is used in the witness - * script generation), you must pass the counterparty revocation_basepoint (which appears in the - * call to Sign::ready_channel) and the provided per_commitment point - * to chan_utils::derive_public_revocation_key. - * - * The witness script which is hashed and included in the output script_pubkey may be - * regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey - * (derived as above), and the to_self_delay contained here to - * chan_utils::get_revokeable_redeemscript. + * The element at position 1 */ - LDKSpendableOutputDescriptor_DelayedPaymentOutput, + struct LDKThirtyTwoBytes b; /** - * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which - * corresponds to the public key in Sign::pubkeys().payment_point). - * The witness in the spending input, is, thus, simply: - * - * - * These are generally the result of our counterparty having broadcast the current state, - * allowing us to claim the non-HTLC-encumbered outputs immediately. + * The element at position 2 */ - LDKSpendableOutputDescriptor_StaticPaymentOutput, + struct LDKInvoiceSignature c; +} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; + +/** + * The contents of CResult_PayeePubKeyErrorZ + */ +typedef union LDKCResult_PayeePubKeyErrorZPtr { /** - * Must be last for serialization purposes + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKSpendableOutputDescriptor_Sentinel, -} LDKSpendableOutputDescriptor_Tag; + struct LDKPayeePubKey *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKSecp256k1Error *err; +} LDKCResult_PayeePubKeyErrorZPtr; -typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { +/** + * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PayeePubKeyErrorZ { /** - * The outpoint which is spendable + * The contents of this CResult_PayeePubKeyErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKOutPoint outpoint; + union LDKCResult_PayeePubKeyErrorZPtr contents; /** - * The output which is referenced by the given outpoint. + * Whether this CResult_PayeePubKeyErrorZ represents a success state. */ - struct LDKTxOut output; -} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; - -typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { - LDKSpendableOutputDescriptor_Tag tag; - union { - LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; - struct { - struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; - }; - struct { - struct LDKStaticPaymentOutputDescriptor static_payment_output; - }; - }; -} LDKSpendableOutputDescriptor; + bool result_ok; +} LDKCResult_PayeePubKeyErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. + * A dynamically-allocated array of crate::lightning_invoice::RouteHints of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_SpendableOutputDescriptorZ { +typedef struct LDKCVec_RouteHintZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKSpendableOutputDescriptor *data; + struct LDKRouteHint *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_SpendableOutputDescriptorZ; +} LDKCVec_RouteHintZ; /** - * 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). + * An enum which can either contain a u64 or not */ -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, +typedef enum LDKCOption_u64Z_Tag { /** - * 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. + * When we're in this state, this COption_u64Z contains a u64 */ - LDKEvent_PaymentReceived, + LDKCOption_u64Z_Some, /** - * 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)! + * When we're in this state, this COption_u64Z contains nothing */ - LDKEvent_PaymentSent, + LDKCOption_u64Z_None, /** - * 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)! + * Must be last for serialization purposes */ - LDKEvent_PaymentFailed, - /** - * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a - * time in the future. - */ - LDKEvent_PendingHTLCsForwardable, - /** - * Used to indicate that an output was generated on-chain which you should know how to spend. - * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your - * counterparty spending them due to some kind of timeout. Thus, you need to store them - * somewhere and spend them when you create on-chain transactions. - */ - LDKEvent_SpendableOutputs, - /** - * Must be last for serialization purposes - */ - LDKEvent_Sentinel, -} LDKEvent_Tag; + LDKCOption_u64Z_Sentinel, +} LDKCOption_u64Z_Tag; -typedef struct LDKEvent_LDKFundingGenerationReady_Body { - /** - * The random channel_id we picked which you'll need to pass into - * ChannelManager::funding_transaction_generated. - */ - struct LDKThirtyTwoBytes temporary_channel_id; - /** - * The value, in satoshis, that the output should have. - */ - uint64_t channel_value_satoshis; +typedef struct LDKCOption_u64Z { + LDKCOption_u64Z_Tag tag; + union { + struct { + uint64_t some; + }; + }; +} LDKCOption_u64Z; + + + +/** + * A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX + * timestamp is positive. + * + * # Invariants + * The UNIX timestamp representing the stored time has to be positive and small enough so that + * a `EpiryTime` can be added to it without an overflow. + */ +typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { /** - * The script which should be used in the transaction output. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKCVec_u8Z output_script; + LDKnativePositiveTimestamp *inner; /** - * The value passed in to ChannelManager::create_channel + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uint64_t user_channel_id; -} LDKEvent_LDKFundingGenerationReady_Body; + bool is_owned; +} LDKPositiveTimestamp; -typedef struct LDKEvent_LDKPaymentReceived_Body { +/** + * The contents of CResult_PositiveTimestampCreationErrorZ + */ +typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { /** - * The hash for which the preimage should be handed to the ChannelManager. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes payment_hash; + struct LDKPositiveTimestamp *result; /** - * The \"payment secret\". This authenticates the sender to the recipient, preventing a - * number of deanonymization attacks during the routing process. - * As nodes upgrade, the invoices you provide should likely migrate to setting the - * payment_secret feature to required, at which point you should fail_backwards any HTLCs - * which have a None here. - * Until then, however, values of None should be ignored, and only incorrect Some values - * should result in an HTLC fail_backwards. - * Note that, in any case, this value must be passed as-is to any fail or claim calls as - * the HTLC index includes this value. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKThirtyTwoBytes payment_secret; + enum LDKCreationError *err; +} LDKCResult_PositiveTimestampCreationErrorZPtr; + +/** + * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PositiveTimestampCreationErrorZ { /** - * The value, in thousandths of a satoshi, that this payment is for. Note that you must - * compare this to the expected value before accepting the payment (as otherwise you are - * providing proof-of-payment for less than the value you expected!). + * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint64_t amt; -} LDKEvent_LDKPaymentReceived_Body; - -typedef struct LDKEvent_LDKPaymentSent_Body { + union LDKCResult_PositiveTimestampCreationErrorZPtr contents; /** - * The preimage to the hash given to ChannelManager::send_payment. - * Note that this serves as a payment receipt, if you wish to have such a thing, you must - * store it somehow! + * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. */ - struct LDKThirtyTwoBytes payment_preimage; -} LDKEvent_LDKPaymentSent_Body; + bool result_ok; +} LDKCResult_PositiveTimestampCreationErrorZ; -typedef struct LDKEvent_LDKPaymentFailed_Body { +/** + * The contents of CResult_NoneSemanticErrorZ + */ +typedef union LDKCResult_NoneSemanticErrorZPtr { /** - * The hash which was given to ChannelManager::send_payment. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKThirtyTwoBytes payment_hash; + void *result; /** - * Indicates the payment was rejected for some reason by the recipient. This implies that - * the payment has failed, not just the route in question. If this is not set, you may - * retry the payment via a different route. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool rejected_by_dest; -} LDKEvent_LDKPaymentFailed_Body; + enum LDKSemanticError *err; +} LDKCResult_NoneSemanticErrorZPtr; -typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { +/** + * A CResult_NoneSemanticErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneSemanticErrorZ { /** - * The minimum amount of time that should be waited prior to calling - * process_pending_htlc_forwards. To increase the effort required to correlate payments, - * you should wait a random amount of time in roughly the range (now + time_forwardable, - * now + 5*time_forwardable). + * The contents of this CResult_NoneSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint64_t time_forwardable; -} LDKEvent_LDKPendingHTLCsForwardable_Body; - -typedef struct LDKEvent_LDKSpendableOutputs_Body { + union LDKCResult_NoneSemanticErrorZPtr contents; /** - * The outputs which you should store as spendable by you. + * Whether this CResult_NoneSemanticErrorZ represents a success state. */ - struct LDKCVec_SpendableOutputDescriptorZ outputs; -} LDKEvent_LDKSpendableOutputs_Body; + bool result_ok; +} LDKCResult_NoneSemanticErrorZ; + -typedef struct MUST_USE_STRUCT LDKEvent { - LDKEvent_Tag tag; - union { - LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; - LDKEvent_LDKPaymentReceived_Body payment_received; - LDKEvent_LDKPaymentSent_Body payment_sent; - LDKEvent_LDKPaymentFailed_Body payment_failed; - LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; - LDKEvent_LDKSpendableOutputs_Body spendable_outputs; - }; -} LDKEvent; /** - * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. - * This corresponds to std::vector in C++ + * Represents a syntactically and semantically correct lightning BOLT11 invoice. + * + * There are three ways to construct an `Invoice`: + * 1. using `InvoiceBuilder` + * 2. using `Invoice::from_signed(SignedRawInvoice)` + * 3. using `str::parse::(&str)` */ -typedef struct LDKCVec_EventZ { +typedef struct MUST_USE_STRUCT LDKInvoice { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKEvent *data; + LDKnativeInvoice *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_EventZ; + bool is_owned; +} LDKInvoice; /** - * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_InvoiceSemanticErrorZ */ -typedef struct LDKCVec_TransactionZ { +typedef union LDKCResult_InvoiceSemanticErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTransaction *data; + struct LDKInvoice *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_TransactionZ; + enum LDKSemanticError *err; +} LDKCResult_InvoiceSemanticErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_usizeTransactionZ { +typedef struct LDKCResult_InvoiceSemanticErrorZ { /** - * The element at position 0 + * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uintptr_t a; + union LDKCResult_InvoiceSemanticErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_InvoiceSemanticErrorZ represents a success state. */ - struct LDKTransaction b; -} LDKC2Tuple_usizeTransactionZ; + bool result_ok; +} LDKCResult_InvoiceSemanticErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_DescriptionCreationErrorZ */ -typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { +typedef union LDKCResult_DescriptionCreationErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_usizeTransactionZ *data; + struct LDKDescription *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_usizeTransactionZZ; + enum LDKCreationError *err; +} LDKCResult_DescriptionCreationErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_u32TxOutZ { +typedef struct LDKCResult_DescriptionCreationErrorZ { /** - * The element at position 0 + * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint32_t a; + union LDKCResult_DescriptionCreationErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_DescriptionCreationErrorZ represents a success state. */ - struct LDKTxOut b; -} LDKC2Tuple_u32TxOutZ; + bool result_ok; +} LDKCResult_DescriptionCreationErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_ExpiryTimeCreationErrorZ */ -typedef struct LDKCVec_C2Tuple_u32TxOutZZ { +typedef union LDKCResult_ExpiryTimeCreationErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_u32TxOutZ *data; + struct LDKExpiryTime *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32TxOutZZ; + enum LDKCreationError *err; +} LDKCResult_ExpiryTimeCreationErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_ExpiryTimeCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::ExpiryTime on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { +typedef struct LDKCResult_ExpiryTimeCreationErrorZ { /** - * The element at position 0 + * The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes a; + union LDKCResult_ExpiryTimeCreationErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_ExpiryTimeCreationErrorZ represents a success state. */ - struct LDKCVec_C2Tuple_u32TxOutZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; + bool result_ok; +} LDKCResult_ExpiryTimeCreationErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A channel descriptor which provides a last-hop route to get_route */ -typedef struct LDKCVec_TransactionOutputsZ { +typedef struct MUST_USE_STRUCT LDKRouteHintHop { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; + LDKnativeRouteHintHop *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_TransactionOutputsZ; + bool is_owned; +} LDKRouteHintHop; /** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_TxidZ { +typedef struct LDKCVec_RouteHintHopZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKThirtyTwoBytes *data; + struct LDKRouteHintHop *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_TxidZ; +} LDKCVec_RouteHintHopZ; /** - * The contents of CResult_NoneChannelMonitorUpdateErrZ + * The contents of CResult_RouteHintCreationErrorZ */ -typedef union LDKCResult_NoneChannelMonitorUpdateErrZPtr { +typedef union LDKCResult_RouteHintCreationErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKRouteHint *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKChannelMonitorUpdateErr *err; -} LDKCResult_NoneChannelMonitorUpdateErrZPtr; + enum LDKCreationError *err; +} LDKCResult_RouteHintCreationErrorZPtr; /** - * A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr on failure. + * A CResult_RouteHintCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::RouteHint on success and a crate::lightning_invoice::CreationError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { +typedef struct LDKCResult_RouteHintCreationErrorZ { /** - * The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either + * The contents of this CResult_RouteHintCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneChannelMonitorUpdateErrZPtr contents; + union LDKCResult_RouteHintCreationErrorZPtr contents; /** - * Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. + * Whether this CResult_RouteHintCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneChannelMonitorUpdateErrZ; +} LDKCResult_RouteHintCreationErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_StringErrorZ */ -typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { +typedef union LDKCResult_StringErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSignature a; + struct LDKCVec_u8Z *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_SignatureZ b; -} LDKC2Tuple_SignatureCVec_SignatureZZ; + enum LDKSecp256k1Error *err; +} LDKCResult_StringErrorZPtr; /** - * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ + * A CResult_StringErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { +typedef struct LDKCResult_StringErrorZ { + /** + * The contents of this CResult_StringErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_StringErrorZPtr contents; + /** + * Whether this CResult_StringErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_StringErrorZ; + + + +/** + * An update generated by the underlying Channel itself which contains some new information the + * ChannelMonitor should be made aware of. + */ +typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelMonitorUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelMonitorUpdate; + +/** + * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + */ +typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; + struct LDKChannelMonitorUpdate *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; /** - * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. + * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either + * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; + union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; + + /** - * The contents of CResult_SignatureNoneZ + * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on + * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the + * preimage claim backward will lead to loss of funds. */ -typedef union LDKCResult_SignatureNoneZPtr { +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeHTLCUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKHTLCUpdate; + +/** + * The contents of CResult_HTLCUpdateDecodeErrorZ + */ +typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSignature *result; + struct LDKHTLCUpdate *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_SignatureNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_HTLCUpdateDecodeErrorZPtr; /** - * A CResult_SignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Signature on success and a () on failure. + * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignatureNoneZ { +typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { /** - * The contents of this CResult_SignatureNoneZ, accessible via either + * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignatureNoneZPtr contents; + union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_SignatureNoneZ represents a success state. + * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignatureNoneZ; +} LDKCResult_HTLCUpdateDecodeErrorZ; /** - * The unsigned part of a channel_announcement + * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is + * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this + * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was + * corrupted. + * Contains a developer-readable error message. */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { +typedef struct MUST_USE_STRUCT LDKMonitorUpdateError { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUnsignedChannelAnnouncement *inner; + LDKnativeMonitorUpdateError *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUnsignedChannelAnnouncement; +} LDKMonitorUpdateError; /** - * A trait to sign lightning channel transactions as described in BOLT 3. - * - * Signing services could be implemented on a hardware wallet. In this case, - * the current Sign would be a front-end on top of a communication - * channel connected to your secure device and lightning key material wouldn't - * reside on a hot server. Nevertheless, a this deployment would still need - * to trust the ChannelManager to avoid loss of funds as this latest component - * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys. - * - * A more secure iteration would be to use hashlock (or payment points) to pair - * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager - * at the price of more state and computation on the hardware wallet side. In the future, - * we are looking forward to design such interface. - * - * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted - * to act, as liveness and breach reply correctness are always going to be hard requirements - * of LN security model, orthogonal of key management issues. + * The contents of CResult_NoneMonitorUpdateErrorZ */ -typedef struct LDKBaseSign { +typedef union LDKCResult_NoneMonitorUpdateErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * Note that this value is always NULL, as there are no contents in the OK variant */ - void *this_arg; + void *result; /** - * Gets the per-commitment point for a specific commitment number - * - * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + struct LDKMonitorUpdateError *err; +} LDKCResult_NoneMonitorUpdateErrorZPtr; + +/** + * A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::chain::channelmonitor::MonitorUpdateError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneMonitorUpdateErrorZ { /** - * Gets the commitment secret for a specific commitment number as part of the revocation process - * - * An external signer implementation should error here if the commitment was already signed - * and should refuse to sign it in the future. - * - * May be called more than once for the same index. - * - * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. + * The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); + union LDKCResult_NoneMonitorUpdateErrorZPtr contents; /** - * Gets the holder's channel public keys and basepoints + * Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. */ - struct LDKChannelPublicKeys pubkeys; + bool result_ok; +} LDKCResult_NoneMonitorUpdateErrorZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OutPointScriptZ { /** - * 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. + * The element at position 0 */ - void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); + struct LDKOutPoint a; /** - * Gets an arbitrary identifier describing the set of keys which are provided back to you in - * some SpendableOutputDescriptor types. This should be sufficient to identify this - * Sign object uniquely and lookup or re-derive its keys. + * The element at position 1 */ - struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); + struct LDKCVec_u8Z b; +} LDKC2Tuple_OutPointScriptZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_u32ScriptZ { /** - * 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. + * The element at position 0 */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx); + uint32_t a; /** - * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. - * This will only ever be called with a non-revoked commitment_tx. This will be called with the - * latest commitment_tx when we initiate a force-close. - * This will be called with the previous latest, just to get claiming HTLC signatures, if we are - * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to - * the latest. - * This may be called multiple times for the same transaction. - * - * An external signer implementation should check that the commitment has not been revoked. - * - * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. + * The element at position 1 */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); + struct LDKCVec_u8Z b; +} LDKC2Tuple_u32ScriptZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_u32ScriptZZ { /** - * Create a signature for the given input in a transaction spending an HTLC or commitment - * transaction output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiples outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiples time for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. - * - * per_commitment_key is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder revocation_secret to do - * so). - * - * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus - * changing the format of the witness script (which is committed to in the BIP 143 - * signatures). + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + struct LDKC2Tuple_u32ScriptZ *data; /** - * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment - * transaction, either offered or received. - * - * Such a transaction may claim multiples offered outputs at same time if we know the - * preimage for each when we create it, but only the input at index `input` should be - * signed for here. It may be called multiple times for same output(s) if a fee-bump is - * needed with regards to an upcoming timelock expiration. - * - * Witness_script is either a offered or received script as defined in BOLT3 for HTLC - * outputs. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. - * - * Per_commitment_point is the dynamic point corresponding to the channel state - * detected onchain. It has been generated by our counterparty and is used to derive - * channel state keys, which are then included in the witness script and committed to in the - * BIP 143 signature. + * The number of elements pointed to by `data`. */ - struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + uintptr_t datalen; +} LDKCVec_C2Tuple_u32ScriptZZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { /** - * Create a signature for a (proposed) closing transaction. - * - * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have - * chosen to forgo their output as dust. + * The element at position 0 */ - struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx); + struct LDKThirtyTwoBytes a; /** - * Signs a channel announcement message with our funding key, proving it comes from one - * of the channel participants. - * - * Note that if this fails or is rejected, the channel will not be publicly announced and - * our counterparty may (though likely will not) close the channel on us for violating the - * protocol. + * The element at position 1 */ - struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + struct LDKCVec_C2Tuple_u32ScriptZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { /** - * Set the counterparty static channel data, including basepoints, - * counterparty_selected/holder_selected_contest_delay and funding outpoint. - * This is done as soon as the funding outpoint is known. Since these are static channel data, - * they MUST NOT be allowed to change to different values once set. - * - * channel_parameters.is_populated() MUST be true. - * - * We bind holder_selected_contest_delay late here for API convenience. - * - * Will be called before any signatures are applied. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The number of elements pointed to by `data`. */ - void (*free)(void *this_arg); -} LDKBaseSign; + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; /** - * A cloneable signer. - * - * Although we require signers to be cloneable, it may be useful for developers to be able to use - * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, - * which implies Sized, into this derived trait. + * An event to be processed by the ChannelManager. */ -typedef struct LDKSign { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef enum LDKMonitorEvent_Tag { /** - * Implementation of BaseSign for this object. + * A monitor event containing an HTLCUpdate. */ - struct LDKBaseSign BaseSign; + LDKMonitorEvent_HTLCEvent, /** - * Creates a copy of the BaseSign, for a copy of this Sign. - * Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here. + * A monitor event that the Channel's commitment transaction was broadcasted. */ - struct LDKBaseSign (*BaseSign_clone)(const struct LDKBaseSign *NONNULL_PTR orig_BaseSign); + LDKMonitorEvent_CommitmentTxBroadcasted, /** - * Serialize the object into a byte array + * Must be last for serialization purposes */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + LDKMonitorEvent_Sentinel, +} LDKMonitorEvent_Tag; + +typedef struct MUST_USE_STRUCT LDKMonitorEvent { + LDKMonitorEvent_Tag tag; + union { + struct { + struct LDKHTLCUpdate htlc_event; + }; + struct { + struct LDKOutPoint commitment_tx_broadcasted; + }; + }; +} LDKMonitorEvent; + +/** + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_MonitorEventZ { /** - * Creates a copy of the object pointed to by this_arg, for a copy of this Sign. - * Note that the ultimate copy of the Sign will have all function pointers the same as the original. - * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void *(*clone)(const void *this_arg); + struct LDKMonitorEvent *data; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The number of elements pointed to by `data`. */ - void (*free)(void *this_arg); -} LDKSign; + uintptr_t datalen; +} LDKCVec_MonitorEventZ; /** - * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates - * on-chain transactions to ensure no loss of funds occurs. - * - * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date - * information and are actively monitoring the chain. - * - * Pending Events or updated HTLCs which have not yet been read out by - * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and - * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events - * gotten are fully handled before re-serializing the new state. - * - * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the - * returned block hash and the the current chain and then reconnecting blocks to get to the - * best chain) upon deserializing the object! + * Information about a spendable output to a P2WSH script. See + * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKChannelMonitor { +typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelMonitor *inner; + LDKnativeDelayedPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelMonitor; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKChannelMonitor b; -} LDKC2Tuple_BlockHashChannelMonitorZ; - -/** - * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ - */ -typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; - -/** - * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - /** - * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; - /** - * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; +} LDKDelayedPaymentOutputDescriptor; /** - * A hop in a route + * Information about a spendable output to our \"payment key\". See + * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKRouteHop { +typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeRouteHop *inner; + LDKnativeStaticPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKRouteHop; +} LDKStaticPaymentOutputDescriptor; /** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. - * This corresponds to std::vector in C++ + * 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 struct LDKCVec_RouteHopZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHop *data; +typedef enum LDKSpendableOutputDescriptor_Tag { /** - * The number of elements pointed to by `data`. + * An output to a script which was provided via KeysInterface directly, either from + * `get_destination_script()` or `get_shutdown_pubkey()`, thus you should already know how to + * spend it. No secret keys are provided as rust-lightning was never given any key. + * These may include outputs from a transaction punishing our counterparty or claiming an HTLC + * on-chain using the payment preimage or after it has timed out. */ - uintptr_t datalen; -} LDKCVec_RouteHopZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_CVec_RouteHopZZ { + LDKSpendableOutputDescriptor_StaticOutput, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * An output to a P2WSH script which can be spent with a single signature after a CSV delay. + * + * The witness in the spending input should be: + * (MINIMALIF standard rule) + * + * Note that the nSequence field in the spending input must be set to to_self_delay + * (which means the transaction is not broadcastable until at least to_self_delay + * blocks after the outpoint confirms). + * + * These are generally the result of a \"revocable\" output to us, spendable only by us unless + * it is an output from an old state which we broadcast (which should never happen). + * + * To derive the delayed_payment key which is used to sign for this input, you must pass the + * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in + * Sign::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to + * chan_utils::derive_private_key. The public key can be generated without the secret key + * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in + * Sign::pubkeys(). + * + * To derive the revocation_pubkey provided here (which is used in the witness + * script generation), you must pass the counterparty revocation_basepoint (which appears in the + * call to Sign::ready_channel) and the provided per_commitment point + * to chan_utils::derive_public_revocation_key. + * + * The witness script which is hashed and included in the output script_pubkey may be + * regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey + * (derived as above), and the to_self_delay contained here to + * chan_utils::get_revokeable_redeemscript. */ - struct LDKCVec_RouteHopZ *data; + LDKSpendableOutputDescriptor_DelayedPaymentOutput, /** - * The number of elements pointed to by `data`. + * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which + * corresponds to the public key in Sign::pubkeys().payment_point). + * The witness in the spending input, is, thus, simply: + * + * + * These are generally the result of our counterparty having broadcast the current state, + * allowing us to claim the non-HTLC-encumbered outputs immediately. */ - uintptr_t datalen; -} LDKCVec_CVec_RouteHopZZ; + LDKSpendableOutputDescriptor_StaticPaymentOutput, + /** + * Must be last for serialization purposes + */ + LDKSpendableOutputDescriptor_Sentinel, +} LDKSpendableOutputDescriptor_Tag; +typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { + /** + * The outpoint which is spendable + */ + struct LDKOutPoint outpoint; + /** + * The output which is referenced by the given outpoint. + */ + struct LDKTxOut output; +} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; +typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { + LDKSpendableOutputDescriptor_Tag tag; + union { + LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; + struct { + struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; + }; + struct { + struct LDKStaticPaymentOutputDescriptor static_payment_output; + }; + }; +} LDKSpendableOutputDescriptor; /** - * A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP, - * it can take multiple paths. Each path is composed of one or more hops through the network. + * A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKRoute { +typedef struct LDKCVec_SpendableOutputDescriptorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeRoute *inner; + struct LDKSpendableOutputDescriptor *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKRoute; + uintptr_t datalen; +} LDKCVec_SpendableOutputDescriptorZ; /** - * The contents of CResult_RouteDecodeErrorZ + * 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 union LDKCResult_RouteDecodeErrorZPtr { +typedef enum LDKEvent_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that 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! */ - struct LDKRoute *result; + LDKEvent_FundingGenerationReady, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * 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. */ - struct LDKDecodeError *err; -} LDKCResult_RouteDecodeErrorZPtr; - -/** - * A CResult_RouteDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_RouteDecodeErrorZ { + LDKEvent_PaymentReceived, /** - * The contents of this CResult_RouteDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * 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)! */ - union LDKCResult_RouteDecodeErrorZPtr contents; + LDKEvent_PaymentSent, /** - * Whether this CResult_RouteDecodeErrorZ represents a success state. + * Indicates an outbound payment we made failed. Probably some intermediary node dropped + * something. You may wish to retry with a different route. + * Note that duplicative PaymentFailed Events may be generated - it is your responsibility to + * deduplicate them by payment_hash (which MUST be unique)! */ - bool result_ok; -} LDKCResult_RouteDecodeErrorZ; - -/** - * An enum which can either contain a u64 or not - */ -typedef enum LDKCOption_u64Z_Tag { + LDKEvent_PaymentFailed, /** - * When we're in this state, this COption_u64Z contains a u64 + * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a + * time in the future. */ - LDKCOption_u64Z_Some, + LDKEvent_PendingHTLCsForwardable, /** - * When we're in this state, this COption_u64Z contains nothing + * 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. */ - LDKCOption_u64Z_None, + LDKEvent_SpendableOutputs, /** * Must be last for serialization purposes */ - LDKCOption_u64Z_Sentinel, -} LDKCOption_u64Z_Tag; - -typedef struct LDKCOption_u64Z { - LDKCOption_u64Z_Tag tag; - union { - struct { - uint64_t some; - }; - }; -} LDKCOption_u64Z; - - + LDKEvent_Sentinel, +} LDKEvent_Tag; -/** - * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels - */ -typedef struct MUST_USE_STRUCT LDKChannelDetails { +typedef struct LDKEvent_LDKFundingGenerationReady_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The random channel_id we picked which you'll need to pass into + * ChannelManager::funding_transaction_generated. */ - LDKnativeChannelDetails *inner; + struct LDKThirtyTwoBytes temporary_channel_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The value, in satoshis, that the output should have. */ - bool is_owned; -} LDKChannelDetails; - -/** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_ChannelDetailsZ { + uint64_t channel_value_satoshis; /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The script which should be used in the transaction output. */ - struct LDKChannelDetails *data; + struct LDKCVec_u8Z output_script; /** - * The number of elements pointed to by `data`. + * The value passed in to ChannelManager::create_channel */ - uintptr_t datalen; -} LDKCVec_ChannelDetailsZ; - - + uint64_t user_channel_id; +} LDKEvent_LDKFundingGenerationReady_Body; -/** - * A channel descriptor which provides a last-hop route to get_route - */ -typedef struct MUST_USE_STRUCT LDKRouteHintHop { +typedef struct LDKEvent_LDKPaymentReceived_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The hash for which the preimage should be handed to the ChannelManager. */ - LDKnativeRouteHintHop *inner; + struct LDKThirtyTwoBytes payment_hash; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The preimage to the payment_hash, if the payment hash (and secret) were fetched via + * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to + * [`ChannelManager::claim_funds`]. + * + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ - bool is_owned; -} LDKRouteHintHop; - -/** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHintHopZ { + struct LDKThirtyTwoBytes payment_preimage; /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The \"payment secret\". This authenticates the sender to the recipient, preventing a + * number of deanonymization attacks during the routing process. + * It is provided here for your reference, however its accuracy is enforced directly by + * [`ChannelManager`] using the values you previously provided to + * [`ChannelManager::create_inbound_payment`] or + * [`ChannelManager::create_inbound_payment_for_hash`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash */ - struct LDKRouteHintHop *data; + struct LDKThirtyTwoBytes payment_secret; /** - * The number of elements pointed to by `data`. + * The value, in thousandths of a satoshi, that this payment is for. Note that you must + * compare this to the expected value before accepting the payment (as otherwise you are + * providing proof-of-payment for less than the value you expected!). */ - uintptr_t datalen; -} LDKCVec_RouteHintHopZ; - - - -/** - * An Err type for failure to process messages. - */ -typedef struct MUST_USE_STRUCT LDKLightningError { + uint64_t amt; /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * This is the `user_payment_id` which was provided to + * [`ChannelManager::create_inbound_payment_for_hash`] or + * [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is + * simply copied here. It may be used to correlate PaymentReceived events with invoice + * metadata stored elsewhere. + * + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash */ - LDKnativeLightningError *inner; + uint64_t user_payment_id; +} LDKEvent_LDKPaymentReceived_Body; + +typedef struct LDKEvent_LDKPaymentSent_Body { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The preimage to the hash given to ChannelManager::send_payment. + * Note that this serves as a payment receipt, if you wish to have such a thing, you must + * store it somehow! */ - bool is_owned; -} LDKLightningError; + struct LDKThirtyTwoBytes payment_preimage; +} LDKEvent_LDKPaymentSent_Body; -/** - * The contents of CResult_RouteLightningErrorZ - */ -typedef union LDKCResult_RouteLightningErrorZPtr { +typedef struct LDKEvent_LDKPaymentFailed_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The hash which was given to ChannelManager::send_payment. */ - struct LDKRoute *result; + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates the payment was rejected for some reason by the recipient. This implies that + * the payment has failed, not just the route in question. If this is not set, you may + * retry the payment via a different route. */ - struct LDKLightningError *err; -} LDKCResult_RouteLightningErrorZPtr; + bool rejected_by_dest; +} LDKEvent_LDKPaymentFailed_Body; -/** - * A CResult_RouteLightningErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_RouteLightningErrorZ { +typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { /** - * The contents of this CResult_RouteLightningErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The minimum amount of time that should be waited prior to calling + * process_pending_htlc_forwards. To increase the effort required to correlate payments, + * you should wait a random amount of time in roughly the range (now + time_forwardable, + * now + 5*time_forwardable). */ - union LDKCResult_RouteLightningErrorZPtr contents; + uint64_t time_forwardable; +} LDKEvent_LDKPendingHTLCsForwardable_Body; + +typedef struct LDKEvent_LDKSpendableOutputs_Body { /** - * Whether this CResult_RouteLightningErrorZ represents a success state. + * The outputs which you should store as spendable by you. */ - bool result_ok; -} LDKCResult_RouteLightningErrorZ; - + struct LDKCVec_SpendableOutputDescriptorZ outputs; +} LDKEvent_LDKSpendableOutputs_Body; +typedef struct MUST_USE_STRUCT LDKEvent { + LDKEvent_Tag tag; + union { + LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + LDKEvent_LDKPaymentReceived_Body payment_received; + LDKEvent_LDKPaymentSent_Body payment_sent; + LDKEvent_LDKPaymentFailed_Body payment_failed; + LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; + LDKEvent_LDKSpendableOutputs_Body spendable_outputs; + }; +} LDKEvent; /** - * An accept_channel message to be sent or received from a peer + * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKAcceptChannel { +typedef struct LDKCVec_EventZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeAcceptChannel *inner; + struct LDKEvent *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKAcceptChannel; - - + uintptr_t datalen; +} LDKCVec_EventZ; /** - * An open_channel message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKOpenChannel { +typedef struct LDKCVec_TransactionZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeOpenChannel *inner; + struct LDKTransaction *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKOpenChannel; - - + uintptr_t datalen; +} LDKCVec_TransactionZ; /** - * A funding_created message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKFundingCreated { +typedef struct LDKC2Tuple_usizeTransactionZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeFundingCreated *inner; + uintptr_t a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKFundingCreated; - - + struct LDKTransaction b; +} LDKC2Tuple_usizeTransactionZ; /** - * A funding_signed message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKFundingSigned { +typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeFundingSigned *inner; + struct LDKC2Tuple_usizeTransactionZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKFundingSigned; - - + uintptr_t datalen; +} LDKCVec_C2Tuple_usizeTransactionZZ; /** - * A funding_locked message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKFundingLocked { +typedef struct LDKC2Tuple_u32TxOutZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeFundingLocked *inner; + uint32_t a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKFundingLocked; - - + struct LDKTxOut b; +} LDKC2Tuple_u32TxOutZ; /** - * An announcement_signatures message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { +typedef struct LDKCVec_C2Tuple_u32TxOutZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeAnnouncementSignatures *inner; + struct LDKC2Tuple_u32TxOutZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKAnnouncementSignatures; - - + uintptr_t datalen; +} LDKCVec_C2Tuple_u32TxOutZZ; /** - * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment - * transaction updates if they were pending. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeCommitmentUpdate *inner; + struct LDKThirtyTwoBytes a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKCommitmentUpdate; - - + struct LDKCVec_C2Tuple_u32TxOutZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; /** - * A revoke_and_ack message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKRevokeAndACK { +typedef struct LDKCVec_TransactionOutputsZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeRevokeAndACK *inner; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKRevokeAndACK; - - + uintptr_t datalen; +} LDKCVec_TransactionOutputsZ; /** - * A closing_signed message to be sent or received from a peer + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKClosingSigned { +typedef struct LDKCVec_TxidZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeClosingSigned *inner; + struct LDKThirtyTwoBytes *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKClosingSigned; - - + uintptr_t datalen; +} LDKCVec_TxidZ; /** - * A shutdown message to be sent or received from a peer + * The contents of CResult_NoneChannelMonitorUpdateErrZ */ -typedef struct MUST_USE_STRUCT LDKShutdown { +typedef union LDKCResult_NoneChannelMonitorUpdateErrZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKnativeShutdown *inner; + void *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKShutdown; - - + enum LDKChannelMonitorUpdateErr *err; +} LDKCResult_NoneChannelMonitorUpdateErrZPtr; /** - * A channel_reestablish message to be sent or received from a peer + * A CResult_NoneChannelMonitorUpdateErrZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::chain::channelmonitor::ChannelMonitorUpdateErr on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKChannelReestablish { +typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_NoneChannelMonitorUpdateErrZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeChannelReestablish *inner; + union LDKCResult_NoneChannelMonitorUpdateErrZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_NoneChannelMonitorUpdateErrZ represents a success state. */ - bool is_owned; -} LDKChannelReestablish; - - + bool result_ok; +} LDKCResult_NoneChannelMonitorUpdateErrZ; /** - * A channel_announcement message to be sent or received from a peer + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { +typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeChannelAnnouncement *inner; + struct LDKSignature a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKChannelAnnouncement; - - + struct LDKCVec_SignatureZ b; +} LDKC2Tuple_SignatureCVec_SignatureZZ; /** - * A channel_update message to be sent or received from a peer + * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ */ -typedef struct MUST_USE_STRUCT LDKChannelUpdate { +typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeChannelUpdate *inner; + struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Note that this value is always NULL, as there are no contents in the Err variant */ - bool is_owned; -} LDKChannelUpdate; + void *err; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; +/** + * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + /** + * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; + /** + * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; +/** + * The contents of CResult_SignatureNoneZ + */ +typedef union LDKCResult_SignatureNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKSignature *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_SignatureNoneZPtr; /** - * A node_announcement message to be sent or received from a peer + * A CResult_SignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Signature on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { +typedef struct LDKCResult_SignatureNoneZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_SignatureNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeNodeAnnouncement *inner; + union LDKCResult_SignatureNoneZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_SignatureNoneZ represents a success state. */ - bool is_owned; -} LDKNodeAnnouncement; + bool result_ok; +} LDKCResult_SignatureNoneZ; /** - * An error message to be sent or received from a peer + * The unsigned part of a channel_announcement */ -typedef struct MUST_USE_STRUCT LDKErrorMessage { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeErrorMessage *inner; + LDKnativeUnsignedChannelAnnouncement *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKErrorMessage; +} LDKUnsignedChannelAnnouncement; /** - * Used to put an error message in a LightningError + * A trait to sign lightning channel transactions as described in BOLT 3. + * + * Signing services could be implemented on a hardware wallet. In this case, + * the current Sign would be a front-end on top of a communication + * channel connected to your secure device and lightning key material wouldn't + * reside on a hot server. Nevertheless, a this deployment would still need + * to trust the ChannelManager to avoid loss of funds as this latest component + * could ask to sign commitment transaction with HTLCs paying to attacker pubkeys. + * + * A more secure iteration would be to use hashlock (or payment points) to pair + * invoice/incoming HTLCs with outgoing HTLCs to implement a no-trust-ChannelManager + * at the price of more state and computation on the hardware wallet side. In the future, + * we are looking forward to design such interface. + * + * In any case, ChannelMonitor or fallback watchtowers are always going to be trusted + * to act, as liveness and breach reply correctness are always going to be hard requirements + * of LN security model, orthogonal of key management issues. */ -typedef enum LDKErrorAction_Tag { +typedef struct LDKBaseSign { /** - * The peer took some action which made us think they were useless. Disconnect them. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKErrorAction_DisconnectPeer, + void *this_arg; /** - * The peer did something harmless that we weren't able to process, just log and ignore + * Gets the per-commitment point for a specific commitment number + * + * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. */ - LDKErrorAction_IgnoreError, + struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); /** - * The peer did something incorrect. Tell them. + * 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. */ - LDKErrorAction_SendErrorMessage, + struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** - * Must be last for serialization purposes + * Gets the holder's channel public keys and basepoints */ - LDKErrorAction_Sentinel, -} LDKErrorAction_Tag; - -typedef struct LDKErrorAction_LDKDisconnectPeer_Body { + struct LDKChannelPublicKeys pubkeys; /** - * An error message which we should make an effort to send before we disconnect. + * Fill in the pubkeys field as a reference to it will be given to Rust after this returns + * Note that this takes a pointer to this object, not the this_ptr like other methods do + * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKDisconnectPeer_Body; - -typedef struct LDKErrorAction_LDKSendErrorMessage_Body { + void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); /** - * The message to send. + * Gets an arbitrary identifier describing the set of keys which are provided back to you in + * some SpendableOutputDescriptor types. This should be sufficient to identify this + * Sign object uniquely and lookup or re-derive its keys. */ - struct 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 { + struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); /** - * We received an error which included a full ChannelUpdate message. + * 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. */ - LDKHTLCFailChannelUpdate_ChannelUpdateMessage, + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx); /** - * We received an error which indicated only that a channel has been closed + * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. + * This will only ever be called with a non-revoked commitment_tx. This will be called with the + * latest commitment_tx when we initiate a force-close. + * This will be called with the previous latest, just to get claiming HTLC signatures, if we are + * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to + * the latest. + * This may be called multiple times for the same transaction. + * + * An external signer implementation should check that the commitment has not been revoked. + * + * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. */ - LDKHTLCFailChannelUpdate_ChannelClosed, + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); /** - * We received an error which indicated only that a node has failed + * 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). */ - LDKHTLCFailChannelUpdate_NodeFailure, + struct LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * Must be last for serialization purposes + * 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. */ - LDKHTLCFailChannelUpdate_Sentinel, -} LDKHTLCFailChannelUpdate_Tag; - -typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body { + struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * The unwrapped message we received + * 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. */ - struct LDKChannelUpdate msg; -} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body; - -typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body { + struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx); /** - * The short_channel_id which has now closed. + * 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. */ - uint64_t short_channel_id; + struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); /** - * when this true, this channel should be permanently removed from the - * consideration. Otherwise, this channel can be restored as new channel_update is received + * 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. */ - bool is_permanent; -} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body; + void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKBaseSign; -typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body { +/** + * A cloneable signer. + * + * Although we require signers to be cloneable, it may be useful for developers to be able to use + * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait, + * which implies Sized, into this derived trait. + */ +typedef struct LDKSign { /** - * The node_id that has failed. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKPublicKey node_id; + void *this_arg; /** - * when this true, node should be permanently removed from the - * consideration. Otherwise, the channels connected to this node can be - * restored as new channel_update is received + * Implementation of BaseSign for this object. */ - 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; + struct LDKBaseSign BaseSign; + /** + * Creates a copy of the BaseSign, for a copy of this Sign. + * Because BaseSign doesn't natively support copying itself, you have to provide a full copy implementation here. + */ + struct LDKBaseSign (*BaseSign_clone)(const struct LDKBaseSign *NONNULL_PTR orig_BaseSign); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Creates a copy of the object pointed to by this_arg, for a copy of this Sign. + * Note that the ultimate copy of the Sign will have all function pointers the same as the original. + * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new Sign. + */ + void *(*clone)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSign; /** - * 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 ChannelMonitor handles chain events (blocks connected and disconnected) and generates + * on-chain transactions to ensure no loss of funds occurs. + * + * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date + * information and are actively monitoring the chain. + * + * Pending Events or updated HTLCs which have not yet been read out by + * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and + * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events + * gotten are fully handled before re-serializing the new state. + * + * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the + * returned block hash and the the current chain and then reconnecting blocks to get to the + * best chain) upon deserializing the object! */ -typedef struct MUST_USE_STRUCT LDKQueryChannelRange { +typedef struct MUST_USE_STRUCT LDKChannelMonitor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeQueryChannelRange *inner; + LDKnativeChannelMonitor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKQueryChannelRange; +} LDKChannelMonitor; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKChannelMonitor b; +} LDKC2Tuple_BlockHashChannelMonitorZ; +/** + * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ + */ +typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC2Tuple_BlockHashChannelMonitorZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; /** - * 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. + * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { +typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeQueryShortChannelIds *inner; + union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKQueryShortChannelIds; + bool result_ok; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; /** - * A reply_channel_range message is a reply to a query_channel_range - * message. Multiple reply_channel_range messages can be sent in reply - * to a single query_channel_range message. The query recipient makes a - * best effort to respond based on their local network view which may - * not be a perfect view of the network. The short_channel_ids in the - * reply are encoded. We only support encoding_type=0 uncompressed - * serialization and do not support encoding_type=1 zlib serialization. + * A hop in a route */ -typedef struct MUST_USE_STRUCT LDKReplyChannelRange { +typedef struct MUST_USE_STRUCT LDKRouteHop { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeReplyChannelRange *inner; + LDKnativeRouteHop *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKReplyChannelRange; +} LDKRouteHop; /** - * 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. + * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. + * This corresponds to std::vector in C++ */ -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, +typedef struct LDKCVec_RouteHopZ { /** - * Used to indicate that a funding_created message should be sent to the peer with the given node_id. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKMessageSendEvent_SendFundingCreated, + struct LDKRouteHop *data; /** - * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + * The number of elements pointed to by `data`. */ - LDKMessageSendEvent_SendFundingSigned, + uintptr_t datalen; +} LDKCVec_RouteHopZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_CVec_RouteHopZZ { /** - * Used to indicate that a funding_locked message should be sent to the peer with the given node_id. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKMessageSendEvent_SendFundingLocked, + struct LDKCVec_RouteHopZ *data; /** - * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + * The number of elements pointed to by `data`. */ - LDKMessageSendEvent_SendAnnouncementSignatures, + uintptr_t datalen; +} LDKCVec_CVec_RouteHopZZ; + + + +/** + * A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP, + * it can take multiple paths. Each path is composed of one or more hops through the network. + */ +typedef struct MUST_USE_STRUCT LDKRoute { /** - * 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. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKMessageSendEvent_UpdateHTLCs, + LDKnativeRoute *inner; /** - * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKMessageSendEvent_SendRevokeAndACK, + bool is_owned; +} LDKRoute; + +/** + * The contents of CResult_RouteDecodeErrorZ + */ +typedef union LDKCResult_RouteDecodeErrorZPtr { /** - * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKMessageSendEvent_SendClosingSigned, + struct LDKRoute *result; /** - * Used to indicate that a shutdown message should be sent to the peer with the given node_id. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKMessageSendEvent_SendShutdown, + struct LDKDecodeError *err; +} LDKCResult_RouteDecodeErrorZPtr; + +/** + * A CResult_RouteDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RouteDecodeErrorZ { /** - * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + * The contents of this CResult_RouteDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKMessageSendEvent_SendChannelReestablish, + union LDKCResult_RouteDecodeErrorZPtr contents; /** - * Used to indicate that a channel_announcement and channel_update should be broadcast to all - * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). - * - * Note that after doing so, you very likely (unless you did so very recently) want to call - * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event. - * This ensures that any nodes which see our channel_announcement also have a relevant - * node_announcement, including relevant feature flags which may be important for routing - * through or to us. + * Whether this CResult_RouteDecodeErrorZ represents a success state. */ - LDKMessageSendEvent_BroadcastChannelAnnouncement, + bool result_ok; +} LDKCResult_RouteDecodeErrorZ; + + + +/** + * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels + */ +typedef struct MUST_USE_STRUCT LDKChannelDetails { /** - * Used to indicate that a node_announcement should be broadcast to all peers. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKMessageSendEvent_BroadcastNodeAnnouncement, + LDKnativeChannelDetails *inner; /** - * Used to indicate that a channel_update should be broadcast to all peers. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKMessageSendEvent_BroadcastChannelUpdate, + bool is_owned; +} LDKChannelDetails; + +/** + * A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_ChannelDetailsZ { /** - * Broadcast an error downstream to be handled + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKMessageSendEvent_HandleError, + struct LDKChannelDetails *data; /** - * When a payment fails we may receive updates back from the hop where it failed. In such - * cases this event is generated so that we can inform the network graph of this information. + * The number of elements pointed to by `data`. */ - LDKMessageSendEvent_PaymentFailureNetworkUpdate, + uintptr_t datalen; +} LDKCVec_ChannelDetailsZ; + + + +/** + * An Err type for failure to process messages. + */ +typedef struct MUST_USE_STRUCT LDKLightningError { /** - * Query a peer for channels with funding transaction UTXOs in a block range. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKMessageSendEvent_SendChannelRangeQuery, + LDKnativeLightningError *inner; /** - * Request routing gossip messages from a peer for a list of channels identified by - * their short_channel_ids. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKMessageSendEvent_SendShortIdsQuery, + bool is_owned; +} LDKLightningError; + +/** + * The contents of CResult_RouteLightningErrorZ + */ +typedef union LDKCResult_RouteLightningErrorZPtr { /** - * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - * emitted during processing of the query. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKMessageSendEvent_SendReplyChannelRange, + struct LDKRoute *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKMessageSendEvent_Sentinel, -} LDKMessageSendEvent_Tag; + struct LDKLightningError *err; +} LDKCResult_RouteLightningErrorZPtr; -typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { +/** + * A CResult_RouteLightningErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RouteLightningErrorZ { /** - * The node_id of the node which should receive this message + * The contents of this CResult_RouteLightningErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey node_id; + union LDKCResult_RouteLightningErrorZPtr contents; /** - * The message which should be sent. + * Whether this CResult_RouteLightningErrorZ represents a success state. */ - struct LDKAcceptChannel msg; -} LDKMessageSendEvent_LDKSendAcceptChannel_Body; + bool result_ok; +} LDKCResult_RouteLightningErrorZ; -typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { + + +/** + * An accept_channel message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKAcceptChannel { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeAcceptChannel *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKOpenChannel msg; -} LDKMessageSendEvent_LDKSendOpenChannel_Body; + bool is_owned; +} LDKAcceptChannel; -typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { + + +/** + * An open_channel message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKOpenChannel { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeOpenChannel *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKFundingCreated msg; -} LDKMessageSendEvent_LDKSendFundingCreated_Body; + bool is_owned; +} LDKOpenChannel; -typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { + + +/** + * A funding_created message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKFundingCreated { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeFundingCreated *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKFundingSigned msg; -} LDKMessageSendEvent_LDKSendFundingSigned_Body; + bool is_owned; +} LDKFundingCreated; -typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { + + +/** + * A funding_signed message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKFundingSigned { /** - * The node_id of the node which should receive these message(s) + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeFundingSigned *inner; /** - * The funding_locked message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKFundingLocked msg; -} LDKMessageSendEvent_LDKSendFundingLocked_Body; + bool is_owned; +} LDKFundingSigned; -typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { + + +/** + * A funding_locked message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKFundingLocked { /** - * The node_id of the node which should receive these message(s) + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeFundingLocked *inner; /** - * The announcement_signatures message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKAnnouncementSignatures msg; -} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; + bool is_owned; +} LDKFundingLocked; -typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { + + +/** + * An announcement_signatures message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { /** - * The node_id of the node which should receive these message(s) + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeAnnouncementSignatures *inner; /** - * The update messages which should be sent. ALL messages in the struct should be sent! + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCommitmentUpdate updates; -} LDKMessageSendEvent_LDKUpdateHTLCs_Body; + bool is_owned; +} LDKAnnouncementSignatures; -typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { + + +/** + * 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 { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeCommitmentUpdate *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKRevokeAndACK msg; -} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; + bool is_owned; +} LDKCommitmentUpdate; -typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { + + +/** + * A revoke_and_ack message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKRevokeAndACK { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeRevokeAndACK *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKClosingSigned msg; -} LDKMessageSendEvent_LDKSendClosingSigned_Body; + bool is_owned; +} LDKRevokeAndACK; -typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { + + +/** + * A closing_signed message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKClosingSigned { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeClosingSigned *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKShutdown msg; -} LDKMessageSendEvent_LDKSendShutdown_Body; + bool is_owned; +} LDKClosingSigned; -typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { + + +/** + * A shutdown message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKShutdown { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeShutdown *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKChannelReestablish msg; -} LDKMessageSendEvent_LDKSendChannelReestablish_Body; + bool is_owned; +} LDKShutdown; -typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { + + +/** + * A channel_reestablish message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKChannelReestablish { /** - * The channel_announcement which should be sent. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKChannelAnnouncement msg; + LDKnativeChannelReestablish *inner; /** - * The followup channel_update which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; + bool is_owned; +} LDKChannelReestablish; -typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { + + +/** + * A channel_announcement message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { /** - * The node_announcement which should be sent. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKNodeAnnouncement msg; -} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; - -typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { + LDKnativeChannelAnnouncement *inner; /** - * The channel_update which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKChannelUpdate msg; -} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; + bool is_owned; +} LDKChannelAnnouncement; -typedef struct LDKMessageSendEvent_LDKHandleError_Body { + + +/** + * A channel_update message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKChannelUpdate { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeChannelUpdate *inner; /** - * The action which should be taken. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKErrorAction action; -} LDKMessageSendEvent_LDKHandleError_Body; + bool is_owned; +} LDKChannelUpdate; -typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body { - /** - * The channel/node update which should be sent to NetGraphMsgHandler - */ - struct LDKHTLCFailChannelUpdate update; -} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body; -typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { + +/** + * A node_announcement message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { /** - * The node_id of this message recipient + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeNodeAnnouncement *inner; /** - * The query_channel_range which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKQueryChannelRange msg; -} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; + bool is_owned; +} LDKNodeAnnouncement; -typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { + + +/** + * An error message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKErrorMessage { /** - * The node_id of this message recipient + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeErrorMessage *inner; /** - * The query_short_channel_ids which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKQueryShortChannelIds msg; -} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; + bool is_owned; +} LDKErrorMessage; -typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { +/** + * Used to put an error message in a LightningError + */ +typedef enum LDKErrorAction_Tag { /** - * The node_id of this message recipient + * The peer took some action which made us think they were useless. Disconnect them. */ - struct LDKPublicKey node_id; + LDKErrorAction_DisconnectPeer, /** - * The reply_channel_range which should be sent. + * The peer did something harmless that we weren't able to process, just log and ignore */ - struct LDKReplyChannelRange msg; -} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; - -typedef struct MUST_USE_STRUCT LDKMessageSendEvent { - LDKMessageSendEvent_Tag tag; - union { - LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; - LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; - LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; - LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; - LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked; - LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; - LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; - LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; - LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; - LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; - LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; - LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; - LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; - LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; - LDKMessageSendEvent_LDKHandleError_Body handle_error; - LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update; - LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; - LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; - LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; - }; -} LDKMessageSendEvent; - -/** - * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_MessageSendEventZ { + LDKErrorAction_IgnoreError, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The peer did something incorrect. Tell them. */ - struct LDKMessageSendEvent *data; + LDKErrorAction_SendErrorMessage, /** - * The number of elements pointed to by `data`. + * Must be last for serialization purposes */ - uintptr_t datalen; -} LDKCVec_MessageSendEventZ; + LDKErrorAction_Sentinel, +} LDKErrorAction_Tag; -/** - * The contents of CResult_boolLightningErrorZ - */ -typedef union LDKCResult_boolLightningErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - bool *result; +typedef struct LDKErrorAction_LDKDisconnectPeer_Body { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An error message which we should make an effort to send before we disconnect. */ - struct LDKLightningError *err; -} LDKCResult_boolLightningErrorZPtr; + struct LDKErrorMessage msg; +} LDKErrorAction_LDKDisconnectPeer_Body; -/** - * A CResult_boolLightningErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_boolLightningErrorZ { - /** - * The contents of this CResult_boolLightningErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_boolLightningErrorZPtr contents; +typedef struct LDKErrorAction_LDKSendErrorMessage_Body { /** - * Whether this CResult_boolLightningErrorZ represents a success state. + * The message to send. */ - bool result_ok; -} LDKCResult_boolLightningErrorZ; + 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; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * 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 struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { +typedef enum LDKHTLCFailChannelUpdate_Tag { /** - * The element at position 0 + * We received an error which included a full ChannelUpdate message. */ - struct LDKChannelAnnouncement a; + LDKHTLCFailChannelUpdate_ChannelUpdateMessage, /** - * The element at position 1 + * We received an error which indicated only that a channel has been closed */ - struct LDKChannelUpdate b; + LDKHTLCFailChannelUpdate_ChannelClosed, /** - * The element at position 2 + * We received an error which indicated only that a node has failed */ - struct LDKChannelUpdate c; -} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + LDKHTLCFailChannelUpdate_NodeFailure, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Must be last for serialization purposes */ - struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data; + LDKHTLCFailChannelUpdate_Sentinel, +} LDKHTLCFailChannelUpdate_Tag; + +typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body { /** - * The number of elements pointed to by `data`. + * The unwrapped message we received */ - uintptr_t datalen; -} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; + struct LDKChannelUpdate msg; +} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body; -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NodeAnnouncementZ { +typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The short_channel_id which has now closed. */ - struct LDKNodeAnnouncement *data; + uint64_t short_channel_id; /** - * The number of elements pointed to by `data`. + * when this true, this channel should be permanently removed from the + * consideration. Otherwise, this channel can be restored as new channel_update is received */ - uintptr_t datalen; -} LDKCVec_NodeAnnouncementZ; + bool is_permanent; +} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body; -/** - * The contents of CResult_NoneLightningErrorZ - */ -typedef union LDKCResult_NoneLightningErrorZPtr { +typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * The node_id that has failed. */ - void *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * when this true, node should be permanently removed from the + * consideration. Otherwise, the channels connected to this node can be + * restored as new channel_update is received */ - struct LDKLightningError *err; -} LDKCResult_NoneLightningErrorZPtr; + 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 CResult_NoneLightningErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * 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 LDKCResult_NoneLightningErrorZ { +typedef struct MUST_USE_STRUCT LDKQueryChannelRange { /** - * The contents of this CResult_NoneLightningErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_NoneLightningErrorZPtr contents; + LDKnativeQueryChannelRange *inner; /** - * Whether this CResult_NoneLightningErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_NoneLightningErrorZ; + bool is_owned; +} LDKQueryChannelRange; + + /** - * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. - * This corresponds to std::vector in C++ + * A query_short_channel_ids message is used to query a peer for + * routing gossip messages related to one or more short_channel_ids. + * The query recipient will reply with the latest, if available, + * channel_announcement, channel_update and node_announcement messages + * it maintains for the requested short_channel_ids followed by a + * reply_short_channel_ids_end message. The short_channel_ids sent in + * this query are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. */ -typedef struct LDKCVec_PublicKeyZ { +typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey *data; + LDKnativeQueryShortChannelIds *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_PublicKeyZ; + bool is_owned; +} LDKQueryShortChannelIds; /** - * Error for PeerManager errors. If you get one of these, you must disconnect the socket and - * generate no further read_event/write_buffer_space_avail/socket_disconnected calls for the - * descriptor. + * A reply_channel_range message is a reply to a query_channel_range + * message. Multiple reply_channel_range messages can be sent in reply + * to a single query_channel_range message. The query recipient makes a + * best effort to respond based on their local network view which may + * not be a perfect view of the network. The short_channel_ids in the + * reply are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. */ -typedef struct MUST_USE_STRUCT LDKPeerHandleError { +typedef struct MUST_USE_STRUCT LDKReplyChannelRange { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePeerHandleError *inner; + LDKnativeReplyChannelRange *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPeerHandleError; +} LDKReplyChannelRange; /** - * The contents of CResult_CVec_u8ZPeerHandleErrorZ + * An event generated by ChannelManager which indicates a message should be sent to a peer (or + * broadcast to most peers). + * These events are handled by PeerManager::process_events if you are using a PeerManager. */ -typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { +typedef enum LDKMessageSendEvent_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that we've accepted a channel open and should send the accept_channel + * message provided to the given peer. */ - struct LDKCVec_u8Z *result; + LDKMessageSendEvent_SendAcceptChannel, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKPeerHandleError *err; -} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; - -/** - * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { + * Used to indicate that we've initiated a channel open and should send the open_channel + * message provided to the given peer. + */ + LDKMessageSendEvent_SendOpenChannel, /** - * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Used to indicate that a funding_created message should be sent to the peer with the given node_id. */ - union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; + LDKMessageSendEvent_SendFundingCreated, /** - * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. */ - bool result_ok; -} LDKCResult_CVec_u8ZPeerHandleErrorZ; - -/** - * The contents of CResult_NonePeerHandleErrorZ - */ -typedef union LDKCResult_NonePeerHandleErrorZPtr { + LDKMessageSendEvent_SendFundingSigned, /** - * Note that this value is always NULL, as there are no contents in the OK variant + * Used to indicate that a funding_locked message should be sent to the peer with the given node_id. */ - void *result; + LDKMessageSendEvent_SendFundingLocked, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. */ - struct LDKPeerHandleError *err; -} LDKCResult_NonePeerHandleErrorZPtr; - -/** - * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NonePeerHandleErrorZ { + LDKMessageSendEvent_SendAnnouncementSignatures, /** - * The contents of this CResult_NonePeerHandleErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * 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. */ - union LDKCResult_NonePeerHandleErrorZPtr contents; + LDKMessageSendEvent_UpdateHTLCs, /** - * Whether this CResult_NonePeerHandleErrorZ represents a success state. + * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. */ - bool result_ok; -} LDKCResult_NonePeerHandleErrorZ; - -/** - * The contents of CResult_boolPeerHandleErrorZ - */ -typedef union LDKCResult_boolPeerHandleErrorZPtr { + LDKMessageSendEvent_SendRevokeAndACK, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. */ - bool *result; + LDKMessageSendEvent_SendClosingSigned, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that a shutdown message should be sent to the peer with the given node_id. */ - struct LDKPeerHandleError *err; -} LDKCResult_boolPeerHandleErrorZPtr; - -/** - * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_boolPeerHandleErrorZ { + LDKMessageSendEvent_SendShutdown, /** - * The contents of this CResult_boolPeerHandleErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. */ - union LDKCResult_boolPeerHandleErrorZPtr contents; + LDKMessageSendEvent_SendChannelReestablish, /** - * Whether this CResult_boolPeerHandleErrorZ represents a success state. + * Used to indicate that a channel_announcement and channel_update should be broadcast to all + * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). + * + * Note that after doing so, you very likely (unless you did so very recently) want to call + * ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event. + * This ensures that any nodes which see our channel_announcement also have a relevant + * node_announcement, including relevant feature flags which may be important for routing + * through or to us. */ - bool result_ok; -} LDKCResult_boolPeerHandleErrorZ; - -/** - * The contents of CResult_TxOutAccessErrorZ - */ -typedef union LDKCResult_TxOutAccessErrorZPtr { + LDKMessageSendEvent_BroadcastChannelAnnouncement, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that a node_announcement should be broadcast to all peers. */ - struct LDKTxOut *result; + LDKMessageSendEvent_BroadcastNodeAnnouncement, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that a channel_update should be broadcast to all peers. */ - enum LDKAccessError *err; -} LDKCResult_TxOutAccessErrorZPtr; - -/** - * A CResult_TxOutAccessErrorZ represents the result of a fallible operation, - * containing a crate::c_types::TxOut on success and a crate::lightning::chain::AccessError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_TxOutAccessErrorZ { + LDKMessageSendEvent_BroadcastChannelUpdate, /** - * The contents of this CResult_TxOutAccessErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Broadcast an error downstream to be handled */ - union LDKCResult_TxOutAccessErrorZPtr contents; + LDKMessageSendEvent_HandleError, /** - * Whether this CResult_TxOutAccessErrorZ represents a success state. + * 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. */ - bool result_ok; -} LDKCResult_TxOutAccessErrorZ; - -/** - * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not - */ -typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag { + LDKMessageSendEvent_PaymentFailureNetworkUpdate, /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ + * Query a peer for channels with funding transaction UTXOs in a block range. */ - LDKCOption_C2Tuple_usizeTransactionZZ_Some, + LDKMessageSendEvent_SendChannelRangeQuery, /** - * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing + * Request routing gossip messages from a peer for a list of channels identified by + * their short_channel_ids. */ - LDKCOption_C2Tuple_usizeTransactionZZ_None, + LDKMessageSendEvent_SendShortIdsQuery, + /** + * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + * emitted during processing of the query. + */ + LDKMessageSendEvent_SendReplyChannelRange, /** * Must be last for serialization purposes */ - LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel, -} LDKCOption_C2Tuple_usizeTransactionZZ_Tag; - -typedef struct LDKCOption_C2Tuple_usizeTransactionZZ { - LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag; - union { - struct { - struct LDKC2Tuple_usizeTransactionZ some; - }; - }; -} LDKCOption_C2Tuple_usizeTransactionZZ; - - + LDKMessageSendEvent_Sentinel, +} LDKMessageSendEvent_Tag; -/** - * Details about one direction of a channel. Received - * within a channel update. - */ -typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo { +typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeDirectionalChannelInfo *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKDirectionalChannelInfo; + struct LDKAcceptChannel msg; +} LDKMessageSendEvent_LDKSendAcceptChannel_Body; -/** - * The contents of CResult_DirectionalChannelInfoDecodeErrorZ - */ -typedef union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive this message */ - struct LDKDirectionalChannelInfo *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The message which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_DirectionalChannelInfoDecodeErrorZPtr; + struct LDKOpenChannel msg; +} LDKMessageSendEvent_LDKSendOpenChannel_Body; -/** - * A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::DirectionalChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_DirectionalChannelInfoDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { /** - * The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive this message */ - union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. + * The message which should be sent. */ - bool result_ok; -} LDKCResult_DirectionalChannelInfoDecodeErrorZ; - - + struct LDKFundingCreated msg; +} LDKMessageSendEvent_LDKSendFundingCreated_Body; -/** - * Details about a channel (both directions). - * Received within a channel announcement. - */ -typedef struct MUST_USE_STRUCT LDKChannelInfo { +typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeChannelInfo *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKChannelInfo; + struct LDKFundingSigned msg; +} LDKMessageSendEvent_LDKSendFundingSigned_Body; -/** - * The contents of CResult_ChannelInfoDecodeErrorZ - */ -typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive these message(s) */ - struct LDKChannelInfo *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The funding_locked message which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelInfoDecodeErrorZPtr; + struct LDKFundingLocked msg; +} LDKMessageSendEvent_LDKSendFundingLocked_Body; -/** - * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelInfoDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { /** - * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive these message(s) */ - union LDKCResult_ChannelInfoDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. + * The announcement_signatures message which should be sent. */ - bool result_ok; -} LDKCResult_ChannelInfoDecodeErrorZ; - - + struct LDKAnnouncementSignatures msg; +} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; -/** - * Fees for routing via a given channel or a node - */ -typedef struct MUST_USE_STRUCT LDKRoutingFees { +typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive these message(s) */ - LDKnativeRoutingFees *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The update messages which should be sent. ALL messages in the struct should be sent! */ - bool is_owned; -} LDKRoutingFees; + struct LDKCommitmentUpdate updates; +} LDKMessageSendEvent_LDKUpdateHTLCs_Body; -/** - * The contents of CResult_RoutingFeesDecodeErrorZ - */ -typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive this message */ - struct LDKRoutingFees *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The message which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_RoutingFeesDecodeErrorZPtr; + struct LDKRevokeAndACK msg; +} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; -/** - * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_RoutingFeesDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { /** - * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive this message */ - union LDKCResult_RoutingFeesDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + * The message which should be sent. */ - bool result_ok; -} LDKCResult_RoutingFeesDecodeErrorZ; + struct LDKClosingSigned msg; +} LDKMessageSendEvent_LDKSendClosingSigned_Body; -/** - * A 4-byte byte array. - */ -typedef struct LDKFourBytes { +typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { /** - * The four bytes + * The node_id of the node which should receive this message */ - uint8_t data[4]; -} LDKFourBytes; - -/** - * A 16-byte byte array. - */ -typedef struct LDKSixteenBytes { + struct LDKPublicKey node_id; /** - * The sixteen bytes + * The message which should be sent. */ - uint8_t data[16]; -} LDKSixteenBytes; + struct LDKShutdown msg; +} LDKMessageSendEvent_LDKSendShutdown_Body; -/** - * A 10-byte byte array. - */ -typedef struct LDKTenBytes { +typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { /** - * The ten bytes + * The node_id of the node which should receive this message */ - uint8_t data[10]; -} LDKTenBytes; - -/** - * An address which can be used to connect to a remote peer - */ -typedef enum LDKNetAddress_Tag { + struct LDKPublicKey node_id; /** - * An IPv4 address/port on which the peer is listening. + * The message which should be sent. */ - LDKNetAddress_IPv4, + struct LDKChannelReestablish msg; +} LDKMessageSendEvent_LDKSendChannelReestablish_Body; + +typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { /** - * An IPv6 address/port on which the peer is listening. + * The channel_announcement which should be sent. */ - LDKNetAddress_IPv6, + struct LDKChannelAnnouncement msg; /** - * An old-style Tor onion address/port on which the peer is listening. + * The followup channel_update which should be sent. */ - LDKNetAddress_OnionV2, + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; + +typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { /** - * A new-style Tor onion address/port on which the peer is listening. - * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version, - * wrap as base32 and append \".onion\". + * The node_announcement which should be sent. */ - LDKNetAddress_OnionV3, + struct LDKNodeAnnouncement msg; +} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; + +typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { /** - * Must be last for serialization purposes + * The channel_update which should be sent. */ - LDKNetAddress_Sentinel, -} LDKNetAddress_Tag; + struct LDKChannelUpdate msg; +} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; -typedef struct LDKNetAddress_LDKIPv4_Body { +typedef struct LDKMessageSendEvent_LDKHandleError_Body { /** - * The 4-byte IPv4 address + * The node_id of the node which should receive this message */ - struct LDKFourBytes addr; + struct LDKPublicKey node_id; /** - * The port on which the node is listening + * The action which should be taken. */ - uint16_t port; -} LDKNetAddress_LDKIPv4_Body; + struct LDKErrorAction action; +} LDKMessageSendEvent_LDKHandleError_Body; -typedef struct LDKNetAddress_LDKIPv6_Body { - /** - * The 16-byte IPv6 address - */ - struct LDKSixteenBytes addr; +typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body { /** - * The port on which the node is listening + * The channel/node update which should be sent to NetGraphMsgHandler */ - uint16_t port; -} LDKNetAddress_LDKIPv6_Body; + struct LDKHTLCFailChannelUpdate update; +} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body; -typedef struct LDKNetAddress_LDKOnionV2_Body { +typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { /** - * The bytes (usually encoded in base32 with \".onion\" appended) + * The node_id of this message recipient */ - struct LDKTenBytes addr; + struct LDKPublicKey node_id; /** - * The port on which the node is listening + * The query_channel_range which should be sent. */ - uint16_t port; -} LDKNetAddress_LDKOnionV2_Body; + struct LDKQueryChannelRange msg; +} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; -typedef struct LDKNetAddress_LDKOnionV3_Body { +typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { /** - * The ed25519 long-term public key of the peer + * The node_id of this message recipient */ - struct LDKThirtyTwoBytes ed25519_pubkey; + struct LDKPublicKey node_id; /** - * The checksum of the pubkey and version, as included in the onion address + * The query_short_channel_ids which should be sent. */ - uint16_t checksum; + struct LDKQueryShortChannelIds msg; +} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; + +typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { /** - * The version byte, as defined by the Tor Onion v3 spec. + * The node_id of this message recipient */ - uint8_t version; + struct LDKPublicKey node_id; /** - * The port on which the node is listening + * The reply_channel_range which should be sent. */ - uint16_t port; -} LDKNetAddress_LDKOnionV3_Body; + struct LDKReplyChannelRange msg; +} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; -typedef struct MUST_USE_STRUCT LDKNetAddress { - LDKNetAddress_Tag tag; +typedef struct MUST_USE_STRUCT LDKMessageSendEvent { + LDKMessageSendEvent_Tag tag; union { - LDKNetAddress_LDKIPv4_Body i_pv4; - LDKNetAddress_LDKIPv6_Body i_pv6; - LDKNetAddress_LDKOnionV2_Body onion_v2; - LDKNetAddress_LDKOnionV3_Body onion_v3; + LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; + LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; + LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; + LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; + LDKMessageSendEvent_LDKSendFundingLocked_Body send_funding_locked; + LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; + LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; + LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; + LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; + LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; + LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; + LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; + LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; + LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; + LDKMessageSendEvent_LDKHandleError_Body handle_error; + LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update; + LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; + LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; + LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; }; -} LDKNetAddress; +} LDKMessageSendEvent; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. + * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_NetAddressZ { +typedef struct LDKCVec_MessageSendEventZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKNetAddress *data; + struct LDKMessageSendEvent *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_NetAddressZ; - - +} LDKCVec_MessageSendEventZ; /** - * Information received in the latest node_announcement from this node. + * The contents of CResult_boolLightningErrorZ */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { +typedef union LDKCResult_boolLightningErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeNodeAnnouncementInfo *inner; + bool *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKNodeAnnouncementInfo; + struct LDKLightningError *err; +} LDKCResult_boolLightningErrorZPtr; /** - * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ + * A CResult_boolLightningErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { +typedef struct LDKCResult_boolLightningErrorZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The contents of this CResult_boolLightningErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKNodeAnnouncementInfo *result; + union LDKCResult_boolLightningErrorZPtr contents; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Whether this CResult_boolLightningErrorZ represents a success state. */ - struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; + bool result_ok; +} LDKCResult_boolLightningErrorZ; /** - * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A tuple of 3 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { +typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { /** - * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; + struct LDKChannelAnnouncement a; /** - * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; + struct LDKChannelUpdate b; + /** + * The element at position 2 + */ + struct LDKChannelUpdate c; +} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; /** - * A dynamically-allocated array of u64s of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_u64Z { +typedef struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - uint64_t *data; + struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_u64Z; - - +} LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; /** - * Details about a node in the network, known from the network announcement. + * A dynamically-allocated array of crate::lightning::ln::msgs::NodeAnnouncements of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKNodeInfo { +typedef struct LDKCVec_NodeAnnouncementZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeNodeInfo *inner; + struct LDKNodeAnnouncement *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKNodeInfo; + uintptr_t datalen; +} LDKCVec_NodeAnnouncementZ; /** - * The contents of CResult_NodeInfoDecodeErrorZ + * The contents of CResult_NoneLightningErrorZ */ -typedef union LDKCResult_NodeInfoDecodeErrorZPtr { +typedef union LDKCResult_NoneLightningErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKNodeInfo *result; + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_NodeInfoDecodeErrorZPtr; + struct LDKLightningError *err; +} LDKCResult_NoneLightningErrorZPtr; /** - * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NoneLightningErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeInfoDecodeErrorZ { +typedef struct LDKCResult_NoneLightningErrorZ { /** - * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either + * The contents of this CResult_NoneLightningErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeInfoDecodeErrorZPtr contents; + union LDKCResult_NoneLightningErrorZPtr contents; /** - * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + * Whether this CResult_NoneLightningErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeInfoDecodeErrorZ; +} LDKCResult_NoneLightningErrorZ; + +/** + * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PublicKeyZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPublicKey *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PublicKeyZ; /** - * Represents the network as nodes and channels between them + * Error for PeerManager errors. If you get one of these, you must disconnect the socket and + * generate no further read_event/write_buffer_space_avail/socket_disconnected calls for the + * descriptor. */ -typedef struct MUST_USE_STRUCT LDKNetworkGraph { +typedef struct MUST_USE_STRUCT LDKPeerHandleError { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNetworkGraph *inner; + LDKnativePeerHandleError *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNetworkGraph; +} LDKPeerHandleError; /** - * The contents of CResult_NetworkGraphDecodeErrorZ + * The contents of CResult_CVec_u8ZPeerHandleErrorZ */ -typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { +typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNetworkGraph *result; + struct LDKCVec_u8Z *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_NetworkGraphDecodeErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; /** - * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NetworkGraphDecodeErrorZ { +typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { /** - * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either + * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NetworkGraphDecodeErrorZPtr contents; + union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; /** - * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NetworkGraphDecodeErrorZ; - +} LDKCResult_CVec_u8ZPeerHandleErrorZ; +/** + * The contents of CResult_NonePeerHandleErrorZ + */ +typedef union LDKCResult_NonePeerHandleErrorZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKPeerHandleError *err; +} LDKCResult_NonePeerHandleErrorZPtr; /** - * Features used within an `init` message. + * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKInitFeatures { +typedef struct LDKCResult_NonePeerHandleErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_NonePeerHandleErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeInitFeatures *inner; + union LDKCResult_NonePeerHandleErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_NonePeerHandleErrorZ represents a success state. */ - bool is_owned; -} LDKInitFeatures; + bool result_ok; +} LDKCResult_NonePeerHandleErrorZ; /** - * The contents of CResult_InitFeaturesDecodeErrorZ + * The contents of CResult_boolPeerHandleErrorZ */ -typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { +typedef union LDKCResult_boolPeerHandleErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInitFeatures *result; + bool *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_InitFeaturesDecodeErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_boolPeerHandleErrorZPtr; /** - * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InitFeaturesDecodeErrorZ { +typedef struct LDKCResult_boolPeerHandleErrorZ { /** - * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_boolPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InitFeaturesDecodeErrorZPtr contents; + union LDKCResult_boolPeerHandleErrorZPtr contents; /** - * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_boolPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InitFeaturesDecodeErrorZ; - - - -/** - * Features used within a `node_announcement` message. - */ -typedef struct MUST_USE_STRUCT LDKNodeFeatures { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeNodeFeatures *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKNodeFeatures; +} LDKCResult_boolPeerHandleErrorZ; /** - * The contents of CResult_NodeFeaturesDecodeErrorZ + * The contents of CResult_TxOutAccessErrorZ */ -typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { +typedef union LDKCResult_TxOutAccessErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeFeatures *result; + struct LDKTxOut *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_NodeFeaturesDecodeErrorZPtr; + enum LDKAccessError *err; +} LDKCResult_TxOutAccessErrorZPtr; /** - * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_TxOutAccessErrorZ represents the result of a fallible operation, + * containing a crate::c_types::TxOut on success and a crate::lightning::chain::AccessError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { +typedef struct LDKCResult_TxOutAccessErrorZ { /** - * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_TxOutAccessErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; + union LDKCResult_TxOutAccessErrorZPtr contents; /** - * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_TxOutAccessErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeFeaturesDecodeErrorZ; +} LDKCResult_TxOutAccessErrorZ; + +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_usizeTransactionZ or not + */ +typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains a crate::c_types::derived::C2Tuple_usizeTransactionZ + */ + LDKCOption_C2Tuple_usizeTransactionZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_usizeTransactionZZ contains nothing + */ + LDKCOption_C2Tuple_usizeTransactionZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel, +} LDKCOption_C2Tuple_usizeTransactionZZ_Tag; + +typedef struct LDKCOption_C2Tuple_usizeTransactionZZ { + LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_usizeTransactionZ some; + }; + }; +} LDKCOption_C2Tuple_usizeTransactionZZ; /** - * Features used within a `channel_announcement` message. + * Details about one direction of a channel. Received + * within a channel update. */ -typedef struct MUST_USE_STRUCT LDKChannelFeatures { +typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelFeatures *inner; + LDKnativeDirectionalChannelInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelFeatures; +} LDKDirectionalChannelInfo; /** - * The contents of CResult_ChannelFeaturesDecodeErrorZ + * The contents of CResult_DirectionalChannelInfoDecodeErrorZ */ -typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { +typedef union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelFeatures *result; + struct LDKDirectionalChannelInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelFeaturesDecodeErrorZPtr; +} LDKCResult_DirectionalChannelInfoDecodeErrorZPtr; /** - * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::DirectionalChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { +typedef struct LDKCResult_DirectionalChannelInfoDecodeErrorZ { /** - * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents; + union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelFeaturesDecodeErrorZ; +} LDKCResult_DirectionalChannelInfoDecodeErrorZ; /** - * Features used within an invoice. + * Details about a channel (both directions). + * Received within a channel announcement. */ -typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { +typedef struct MUST_USE_STRUCT LDKChannelInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceFeatures *inner; + LDKnativeChannelInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceFeatures; +} LDKChannelInfo; /** - * The contents of CResult_InvoiceFeaturesDecodeErrorZ + * The contents of CResult_ChannelInfoDecodeErrorZ */ -typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { +typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoiceFeatures *result; + struct LDKChannelInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; +} LDKCResult_ChannelInfoDecodeErrorZPtr; /** - * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { +typedef struct LDKCResult_ChannelInfoDecodeErrorZ { /** - * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; + union LDKCResult_ChannelInfoDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceFeaturesDecodeErrorZ; +} LDKCResult_ChannelInfoDecodeErrorZ; + -/** - * The contents of CResult_NetAddressu8Z - */ -typedef union LDKCResult_NetAddressu8ZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKNetAddress *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - uint8_t *err; -} LDKCResult_NetAddressu8ZPtr; /** - * A CResult_NetAddressu8Z represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NetAddress on success and a u8 on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Fees for routing via a given channel or a node */ -typedef struct LDKCResult_NetAddressu8Z { +typedef struct MUST_USE_STRUCT LDKRoutingFees { /** - * The contents of this CResult_NetAddressu8Z, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_NetAddressu8ZPtr contents; + LDKnativeRoutingFees *inner; /** - * Whether this CResult_NetAddressu8Z represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_NetAddressu8Z; + bool is_owned; +} LDKRoutingFees; /** - * The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ + * The contents of CResult_RoutingFeesDecodeErrorZ */ -typedef union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr { +typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NetAddressu8Z *result; + struct LDKRoutingFees *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr; +} LDKCResult_RoutingFeesDecodeErrorZPtr; /** - * A CResult_CResult_NetAddressu8ZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CResult_NetAddressu8Z on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ { +typedef struct LDKCResult_RoutingFeesDecodeErrorZ { /** - * The contents of this CResult_CResult_NetAddressu8ZDecodeErrorZ, accessible via either + * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr contents; + union LDKCResult_RoutingFeesDecodeErrorZPtr contents; /** - * Whether this CResult_CResult_NetAddressu8ZDecodeErrorZ represents a success state. + * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CResult_NetAddressu8ZDecodeErrorZ; - - +} LDKCResult_RoutingFeesDecodeErrorZ; /** - * An update_add_htlc message to be sent or received from a peer + * A 4-byte byte array. */ -typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUpdateAddHTLC *inner; +typedef struct LDKFourBytes { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The four bytes */ - bool is_owned; -} LDKUpdateAddHTLC; + uint8_t data[4]; +} LDKFourBytes; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * A 16-byte byte array. */ -typedef struct LDKCVec_UpdateAddHTLCZ { +typedef struct LDKSixteenBytes { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The sixteen bytes */ - struct LDKUpdateAddHTLC *data; + uint8_t data[16]; +} LDKSixteenBytes; + +/** + * A 10-byte byte array. + */ +typedef struct LDKTenBytes { /** - * The number of elements pointed to by `data`. + * The ten bytes */ - uintptr_t datalen; -} LDKCVec_UpdateAddHTLCZ; - - + uint8_t data[10]; +} LDKTenBytes; /** - * An update_fulfill_htlc message to be sent or received from a peer + * An address which can be used to connect to a remote peer */ -typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { +typedef enum LDKNetAddress_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An IPv4 address/port on which the peer is listening. */ - LDKnativeUpdateFulfillHTLC *inner; + LDKNetAddress_IPv4, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An IPv6 address/port on which the peer is listening. */ - bool is_owned; -} LDKUpdateFulfillHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFulfillHTLCZ { + LDKNetAddress_IPv6, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * An old-style Tor onion address/port on which the peer is listening. */ - struct LDKUpdateFulfillHTLC *data; + LDKNetAddress_OnionV2, /** - * The number of elements pointed to by `data`. + * A new-style Tor onion address/port on which the peer is listening. + * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version, + * wrap as base32 and append \".onion\". */ - uintptr_t datalen; -} LDKCVec_UpdateFulfillHTLCZ; - - + LDKNetAddress_OnionV3, + /** + * Must be last for serialization purposes + */ + LDKNetAddress_Sentinel, +} LDKNetAddress_Tag; -/** - * An update_fail_htlc message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { +typedef struct LDKNetAddress_LDKIPv4_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The 4-byte IPv4 address */ - LDKnativeUpdateFailHTLC *inner; + struct LDKFourBytes addr; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The port on which the node is listening */ - bool is_owned; -} LDKUpdateFailHTLC; + uint16_t port; +} LDKNetAddress_LDKIPv4_Body; -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. +typedef struct LDKNetAddress_LDKIPv6_Body { + /** + * The 16-byte IPv6 address + */ + struct LDKSixteenBytes addr; + /** + * The port on which the node is listening + */ + uint16_t port; +} LDKNetAddress_LDKIPv6_Body; + +typedef struct LDKNetAddress_LDKOnionV2_Body { + /** + * The bytes (usually encoded in base32 with \".onion\" appended) + */ + struct LDKTenBytes addr; + /** + * The port on which the node is listening + */ + uint16_t port; +} LDKNetAddress_LDKOnionV2_Body; + +typedef struct LDKNetAddress_LDKOnionV3_Body { + /** + * The ed25519 long-term public key of the peer + */ + struct LDKThirtyTwoBytes ed25519_pubkey; + /** + * The checksum of the pubkey and version, as included in the onion address + */ + uint16_t checksum; + /** + * The version byte, as defined by the Tor Onion v3 spec. + */ + uint8_t version; + /** + * The port on which the node is listening + */ + uint16_t port; +} LDKNetAddress_LDKOnionV3_Body; + +typedef struct MUST_USE_STRUCT LDKNetAddress { + LDKNetAddress_Tag tag; + union { + LDKNetAddress_LDKIPv4_Body i_pv4; + LDKNetAddress_LDKIPv6_Body i_pv6; + LDKNetAddress_LDKOnionV2_Body onion_v2; + LDKNetAddress_LDKOnionV3_Body onion_v3; + }; +} LDKNetAddress; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_UpdateFailHTLCZ { +typedef struct LDKCVec_NetAddressZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKUpdateFailHTLC *data; + struct LDKNetAddress *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_UpdateFailHTLCZ; +} LDKCVec_NetAddressZ; /** - * An update_fail_malformed_htlc message to be sent or received from a peer + * Information received in the latest node_announcement from this node. */ -typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateFailMalformedHTLC *inner; + LDKnativeNodeAnnouncementInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateFailMalformedHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFailMalformedHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateFailMalformedHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateFailMalformedHTLCZ; +} LDKNodeAnnouncementInfo; /** - * The contents of CResult_AcceptChannelDecodeErrorZ + * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ */ -typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { +typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKAcceptChannel *result; + struct LDKNodeAnnouncementInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_AcceptChannelDecodeErrorZPtr; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; /** - * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_AcceptChannelDecodeErrorZ { +typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { /** - * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_AcceptChannelDecodeErrorZPtr contents; + union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; /** - * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_AcceptChannelDecodeErrorZ; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; /** - * The contents of CResult_AnnouncementSignaturesDecodeErrorZ + * A dynamically-allocated array of u64s of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { +typedef struct LDKCVec_u64Z { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKAnnouncementSignatures *result; + uint64_t *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_u64Z; + + /** - * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Details about a node in the network, known from the network announcement. */ -typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKNodeInfo { /** - * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; + LDKnativeNodeInfo *inner; /** - * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_AnnouncementSignaturesDecodeErrorZ; + bool is_owned; +} LDKNodeInfo; /** - * The contents of CResult_ChannelReestablishDecodeErrorZ + * The contents of CResult_NodeInfoDecodeErrorZ */ -typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { +typedef union LDKCResult_NodeInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelReestablish *result; + struct LDKNodeInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelReestablishDecodeErrorZPtr; +} LDKCResult_NodeInfoDecodeErrorZPtr; /** - * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { +typedef struct LDKCResult_NodeInfoDecodeErrorZ { /** - * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; + union LDKCResult_NodeInfoDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelReestablishDecodeErrorZ; +} LDKCResult_NodeInfoDecodeErrorZ; + + /** - * The contents of CResult_ClosingSignedDecodeErrorZ + * Represents the network as nodes and channels between them */ -typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKNetworkGraph { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeNetworkGraph *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKNetworkGraph; + +/** + * The contents of CResult_NetworkGraphDecodeErrorZ + */ +typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKClosingSigned *result; + struct LDKNetworkGraph *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ClosingSignedDecodeErrorZPtr; +} LDKCResult_NetworkGraphDecodeErrorZPtr; /** - * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ClosingSignedDecodeErrorZ { +typedef struct LDKCResult_NetworkGraphDecodeErrorZ { /** - * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either + * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ClosingSignedDecodeErrorZPtr contents; + union LDKCResult_NetworkGraphDecodeErrorZPtr contents; /** - * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ClosingSignedDecodeErrorZ; +} LDKCResult_NetworkGraphDecodeErrorZ; /** - * A commitment_signed message to be sent or received from a peer + * Features used within an `init` message. */ -typedef struct MUST_USE_STRUCT LDKCommitmentSigned { +typedef struct MUST_USE_STRUCT LDKInitFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeCommitmentSigned *inner; + LDKnativeInitFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKCommitmentSigned; +} LDKInitFeatures; /** - * The contents of CResult_CommitmentSignedDecodeErrorZ + * The contents of CResult_InitFeaturesDecodeErrorZ */ -typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { +typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCommitmentSigned *result; + struct LDKInitFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_CommitmentSignedDecodeErrorZPtr; +} LDKCResult_InitFeaturesDecodeErrorZPtr; /** - * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { +typedef struct LDKCResult_InitFeaturesDecodeErrorZ { /** - * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; + union LDKCResult_InitFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CommitmentSignedDecodeErrorZ; +} LDKCResult_InitFeaturesDecodeErrorZ; + + /** - * The contents of CResult_FundingCreatedDecodeErrorZ + * Features used within a `node_announcement` message. */ -typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKNodeFeatures { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKFundingCreated *result; + LDKnativeNodeFeatures *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_FundingCreatedDecodeErrorZPtr; - -/** - * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_FundingCreatedDecodeErrorZ { - /** - * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_FundingCreatedDecodeErrorZPtr contents; - /** - * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_FundingCreatedDecodeErrorZ; - -/** - * The contents of CResult_FundingSignedDecodeErrorZ - */ -typedef union LDKCResult_FundingSignedDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKFundingSigned *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_FundingSignedDecodeErrorZPtr; - -/** - * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_FundingSignedDecodeErrorZ { - /** - * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_FundingSignedDecodeErrorZPtr contents; - /** - * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_FundingSignedDecodeErrorZ; + bool is_owned; +} LDKNodeFeatures; /** - * The contents of CResult_FundingLockedDecodeErrorZ + * The contents of CResult_NodeFeaturesDecodeErrorZ */ -typedef union LDKCResult_FundingLockedDecodeErrorZPtr { +typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKFundingLocked *result; + struct LDKNodeFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_FundingLockedDecodeErrorZPtr; +} LDKCResult_NodeFeaturesDecodeErrorZPtr; /** - * A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_FundingLockedDecodeErrorZ { +typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { /** - * The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either + * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_FundingLockedDecodeErrorZPtr contents; + union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_FundingLockedDecodeErrorZ represents a success state. + * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_FundingLockedDecodeErrorZ; +} LDKCResult_NodeFeaturesDecodeErrorZ; /** - * An init message to be sent or received from a peer + * Features used within a `channel_announcement` message. */ -typedef struct MUST_USE_STRUCT LDKInit { +typedef struct MUST_USE_STRUCT LDKChannelFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInit *inner; + LDKnativeChannelFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInit; +} LDKChannelFeatures; /** - * The contents of CResult_InitDecodeErrorZ + * The contents of CResult_ChannelFeaturesDecodeErrorZ */ -typedef union LDKCResult_InitDecodeErrorZPtr { +typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInit *result; + struct LDKChannelFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InitDecodeErrorZPtr; +} LDKCResult_ChannelFeaturesDecodeErrorZPtr; /** - * A CResult_InitDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InitDecodeErrorZ { +typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { /** - * The contents of this CResult_InitDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InitDecodeErrorZPtr contents; + union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_InitDecodeErrorZ represents a success state. + * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InitDecodeErrorZ; +} LDKCResult_ChannelFeaturesDecodeErrorZ; /** - * The contents of CResult_OpenChannelDecodeErrorZ + * The contents of CResult_InvoiceFeaturesDecodeErrorZ */ -typedef union LDKCResult_OpenChannelDecodeErrorZPtr { +typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOpenChannel *result; + struct LDKInvoiceFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_OpenChannelDecodeErrorZPtr; +} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; /** - * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_OpenChannelDecodeErrorZ { +typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { /** - * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either + * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_OpenChannelDecodeErrorZPtr contents; + union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_OpenChannelDecodeErrorZ; +} LDKCResult_InvoiceFeaturesDecodeErrorZ; /** - * The contents of CResult_RevokeAndACKDecodeErrorZ + * The contents of CResult_NetAddressu8Z */ -typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { +typedef union LDKCResult_NetAddressu8ZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRevokeAndACK *result; + struct LDKNetAddress *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_RevokeAndACKDecodeErrorZPtr; + uint8_t *err; +} LDKCResult_NetAddressu8ZPtr; /** - * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NetAddressu8Z represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NetAddress on success and a u8 on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { +typedef struct LDKCResult_NetAddressu8Z { /** - * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + * The contents of this CResult_NetAddressu8Z, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; + union LDKCResult_NetAddressu8ZPtr contents; /** - * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + * Whether this CResult_NetAddressu8Z represents a success state. */ bool result_ok; -} LDKCResult_RevokeAndACKDecodeErrorZ; +} LDKCResult_NetAddressu8Z; /** - * The contents of CResult_ShutdownDecodeErrorZ + * The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ */ -typedef union LDKCResult_ShutdownDecodeErrorZPtr { +typedef union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKShutdown *result; + struct LDKCResult_NetAddressu8Z *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ShutdownDecodeErrorZPtr; +} LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr; /** - * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CResult_NetAddressu8ZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CResult_NetAddressu8Z on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ShutdownDecodeErrorZ { +typedef struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ { /** - * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + * The contents of this CResult_CResult_NetAddressu8ZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ShutdownDecodeErrorZPtr contents; + union LDKCResult_CResult_NetAddressu8ZDecodeErrorZPtr contents; /** - * Whether this CResult_ShutdownDecodeErrorZ represents a success state. + * Whether this CResult_CResult_NetAddressu8ZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ShutdownDecodeErrorZ; +} LDKCResult_CResult_NetAddressu8ZDecodeErrorZ; -/** - * The contents of CResult_UpdateFailHTLCDecodeErrorZ - */ -typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKUpdateFailHTLC *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; -/** - * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { - /** - * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; - /** - * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_UpdateFailHTLCDecodeErrorZ; /** - * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ + * An update_add_htlc message to be sent or received from a peer */ -typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKUpdateFailMalformedHTLC *result; + LDKnativeUpdateAddHTLC *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; + bool is_owned; +} LDKUpdateAddHTLC; /** - * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { +typedef struct LDKCVec_UpdateAddHTLCZ { /** - * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; + struct LDKUpdateAddHTLC *data; /** - * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_UpdateAddHTLCZ; /** - * An update_fee message to be sent or received from a peer + * An update_fulfill_htlc message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKUpdateFee { +typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateFee *inner; + LDKnativeUpdateFulfillHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateFee; +} LDKUpdateFulfillHTLC; /** - * The contents of CResult_UpdateFeeDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { +typedef struct LDKCVec_UpdateFulfillHTLCZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKUpdateFee *result; + struct LDKUpdateFulfillHTLC *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFeeDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_UpdateFulfillHTLCZ; + + /** - * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An update_fail_htlc message to be sent or received from a peer */ -typedef struct LDKCResult_UpdateFeeDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { /** - * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_UpdateFeeDecodeErrorZPtr contents; + LDKnativeUpdateFailHTLC *inner; /** - * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_UpdateFeeDecodeErrorZ; + bool is_owned; +} LDKUpdateFailHTLC; /** - * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { +typedef struct LDKCVec_UpdateFailHTLCZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKUpdateFailHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_UpdateFailHTLCZ; + + + +/** + * An update_fail_malformed_htlc message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUpdateFailMalformedHTLC *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUpdateFailMalformedHTLC; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_UpdateFailMalformedHTLCZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKUpdateFailMalformedHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_UpdateFailMalformedHTLCZ; + +/** + * The contents of CResult_AcceptChannelDecodeErrorZ + */ +typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFulfillHTLC *result; + struct LDKAcceptChannel *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; +} LDKCResult_AcceptChannelDecodeErrorZPtr; /** - * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { +typedef struct LDKCResult_AcceptChannelDecodeErrorZ { /** - * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; + union LDKCResult_AcceptChannelDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; +} LDKCResult_AcceptChannelDecodeErrorZ; /** - * The contents of CResult_UpdateAddHTLCDecodeErrorZ + * The contents of CResult_AnnouncementSignaturesDecodeErrorZ */ -typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { +typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateAddHTLC *result; + struct LDKAnnouncementSignatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; +} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; /** - * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { +typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { /** - * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either + * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; + union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; /** - * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UpdateAddHTLCDecodeErrorZ; - +} LDKCResult_AnnouncementSignaturesDecodeErrorZ; +/** + * The contents of CResult_ChannelReestablishDecodeErrorZ + */ +typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelReestablish *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelReestablishDecodeErrorZPtr; /** - * A ping message to be sent or received from a peer + * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKPing { +typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativePing *inner; + union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKPing; + bool result_ok; +} LDKCResult_ChannelReestablishDecodeErrorZ; /** - * The contents of CResult_PingDecodeErrorZ + * The contents of CResult_ClosingSignedDecodeErrorZ */ -typedef union LDKCResult_PingDecodeErrorZPtr { +typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPing *result; + struct LDKClosingSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_PingDecodeErrorZPtr; +} LDKCResult_ClosingSignedDecodeErrorZPtr; /** - * A CResult_PingDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PingDecodeErrorZ { +typedef struct LDKCResult_ClosingSignedDecodeErrorZ { /** - * The contents of this CResult_PingDecodeErrorZ, accessible via either + * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PingDecodeErrorZPtr contents; + union LDKCResult_ClosingSignedDecodeErrorZPtr contents; /** - * Whether this CResult_PingDecodeErrorZ represents a success state. + * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PingDecodeErrorZ; +} LDKCResult_ClosingSignedDecodeErrorZ; /** - * A pong message to be sent or received from a peer + * A commitment_signed message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKPong { +typedef struct MUST_USE_STRUCT LDKCommitmentSigned { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePong *inner; + LDKnativeCommitmentSigned *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPong; +} LDKCommitmentSigned; /** - * The contents of CResult_PongDecodeErrorZ + * The contents of CResult_CommitmentSignedDecodeErrorZ */ -typedef union LDKCResult_PongDecodeErrorZPtr { +typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPong *result; + struct LDKCommitmentSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_PongDecodeErrorZPtr; +} LDKCResult_CommitmentSignedDecodeErrorZPtr; /** - * A CResult_PongDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PongDecodeErrorZ { +typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { /** - * The contents of this CResult_PongDecodeErrorZ, accessible via either + * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PongDecodeErrorZPtr contents; + union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; /** - * Whether this CResult_PongDecodeErrorZ represents a success state. + * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PongDecodeErrorZ; +} LDKCResult_CommitmentSignedDecodeErrorZ; /** - * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ + * The contents of CResult_FundingCreatedDecodeErrorZ */ -typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUnsignedChannelAnnouncement *result; + struct LDKFundingCreated *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; +} LDKCResult_FundingCreatedDecodeErrorZPtr; /** - * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { +typedef struct LDKCResult_FundingCreatedDecodeErrorZ { /** - * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; + union LDKCResult_FundingCreatedDecodeErrorZPtr contents; /** - * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; +} LDKCResult_FundingCreatedDecodeErrorZ; /** - * The contents of CResult_ChannelAnnouncementDecodeErrorZ + * The contents of CResult_FundingSignedDecodeErrorZ */ -typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_FundingSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelAnnouncement *result; + struct LDKFundingSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; +} LDKCResult_FundingSignedDecodeErrorZPtr; /** - * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { +typedef struct LDKCResult_FundingSignedDecodeErrorZ { /** - * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; + union LDKCResult_FundingSignedDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelAnnouncementDecodeErrorZ; +} LDKCResult_FundingSignedDecodeErrorZ; + +/** + * The contents of CResult_FundingLockedDecodeErrorZ + */ +typedef union LDKCResult_FundingLockedDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKFundingLocked *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_FundingLockedDecodeErrorZPtr; + +/** + * A CResult_FundingLockedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_FundingLockedDecodeErrorZ { + /** + * The contents of this CResult_FundingLockedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_FundingLockedDecodeErrorZPtr contents; + /** + * Whether this CResult_FundingLockedDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_FundingLockedDecodeErrorZ; /** - * The unsigned part of a channel_update + * An init message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { +typedef struct MUST_USE_STRUCT LDKInit { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUnsignedChannelUpdate *inner; + LDKnativeInit *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUnsignedChannelUpdate; +} LDKInit; /** - * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ + * The contents of CResult_InitDecodeErrorZ */ -typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { +typedef union LDKCResult_InitDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUnsignedChannelUpdate *result; + struct LDKInit *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; +} LDKCResult_InitDecodeErrorZPtr; /** - * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InitDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { +typedef struct LDKCResult_InitDecodeErrorZ { /** - * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_InitDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; + union LDKCResult_InitDecodeErrorZPtr contents; /** - * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + * Whether this CResult_InitDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; +} LDKCResult_InitDecodeErrorZ; /** - * The contents of CResult_ChannelUpdateDecodeErrorZ + * The contents of CResult_OpenChannelDecodeErrorZ */ -typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { +typedef union LDKCResult_OpenChannelDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelUpdate *result; + struct LDKOpenChannel *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelUpdateDecodeErrorZPtr; +} LDKCResult_OpenChannelDecodeErrorZPtr; /** - * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { +typedef struct LDKCResult_OpenChannelDecodeErrorZ { /** - * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; + union LDKCResult_OpenChannelDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelUpdateDecodeErrorZ; +} LDKCResult_OpenChannelDecodeErrorZ; /** - * The contents of CResult_ErrorMessageDecodeErrorZ + * The contents of CResult_RevokeAndACKDecodeErrorZ */ -typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { +typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKErrorMessage *result; + struct LDKRevokeAndACK *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ErrorMessageDecodeErrorZPtr; +} LDKCResult_RevokeAndACKDecodeErrorZPtr; /** - * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ErrorMessageDecodeErrorZ { +typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { /** - * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either + * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ErrorMessageDecodeErrorZPtr contents; + union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; /** - * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ErrorMessageDecodeErrorZ; - - - -/** - * The unsigned part of a node_announcement - */ -typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUnsignedNodeAnnouncement *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKUnsignedNodeAnnouncement; +} LDKCResult_RevokeAndACKDecodeErrorZ; /** - * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ + * The contents of CResult_ShutdownDecodeErrorZ */ -typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_ShutdownDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUnsignedNodeAnnouncement *result; + struct LDKShutdown *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; +} LDKCResult_ShutdownDecodeErrorZPtr; /** - * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { +typedef struct LDKCResult_ShutdownDecodeErrorZ { /** - * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; + union LDKCResult_ShutdownDecodeErrorZPtr contents; /** - * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_ShutdownDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; +} LDKCResult_ShutdownDecodeErrorZ; /** - * The contents of CResult_NodeAnnouncementDecodeErrorZ + * The contents of CResult_UpdateFailHTLCDecodeErrorZ */ -typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { +typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeAnnouncement *result; + struct LDKUpdateFailHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementDecodeErrorZPtr; +} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; /** - * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { +typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { /** - * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; + union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeAnnouncementDecodeErrorZ; +} LDKCResult_UpdateFailHTLCDecodeErrorZ; /** - * The contents of CResult_QueryShortChannelIdsDecodeErrorZ + * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ */ -typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { +typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKQueryShortChannelIds *result; + struct LDKUpdateFailMalformedHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_QueryShortChannelIdsDecodeErrorZPtr; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; /** - * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { +typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { /** - * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; + union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_QueryShortChannelIdsDecodeErrorZ; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; /** - * A reply_short_channel_ids_end message is sent as a reply to a - * query_short_channel_ids message. The query recipient makes a best - * effort to respond based on their local network view which may not be - * a perfect view of the network. + * An update_fee message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { +typedef struct MUST_USE_STRUCT LDKUpdateFee { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeReplyShortChannelIdsEnd *inner; + LDKnativeUpdateFee *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKReplyShortChannelIdsEnd; +} LDKUpdateFee; /** - * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ + * The contents of CResult_UpdateFeeDecodeErrorZ */ -typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKReplyShortChannelIdsEnd *result; + struct LDKUpdateFee *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; +} LDKCResult_UpdateFeeDecodeErrorZPtr; /** - * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { +typedef struct LDKCResult_UpdateFeeDecodeErrorZ { /** - * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; + union LDKCResult_UpdateFeeDecodeErrorZPtr contents; /** - * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; +} LDKCResult_UpdateFeeDecodeErrorZ; /** - * The contents of CResult_QueryChannelRangeDecodeErrorZ + * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ */ -typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { +typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKQueryChannelRange *result; + struct LDKUpdateFulfillHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_QueryChannelRangeDecodeErrorZPtr; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; /** - * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { +typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { /** - * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; + union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_QueryChannelRangeDecodeErrorZ; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; /** - * The contents of CResult_ReplyChannelRangeDecodeErrorZ + * The contents of CResult_UpdateAddHTLCDecodeErrorZ */ -typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { +typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKReplyChannelRange *result; + struct LDKUpdateAddHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; +} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; /** - * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { +typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { /** - * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; + union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ReplyChannelRangeDecodeErrorZ; +} LDKCResult_UpdateAddHTLCDecodeErrorZ; /** - * A gossip_timestamp_filter message is used by a node to request - * gossip relay for messages in the requested time range when the - * gossip_queries feature has been negotiated. + * A ping message to be sent or received from a peer */ -typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { +typedef struct MUST_USE_STRUCT LDKPing { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeGossipTimestampFilter *inner; + LDKnativePing *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKGossipTimestampFilter; +} LDKPing; /** - * The contents of CResult_GossipTimestampFilterDecodeErrorZ + * The contents of CResult_PingDecodeErrorZ */ -typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { +typedef union LDKCResult_PingDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKGossipTimestampFilter *result; + struct LDKPing *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; +} LDKCResult_PingDecodeErrorZPtr; /** - * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PingDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { +typedef struct LDKCResult_PingDecodeErrorZ { /** - * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either + * The contents of this CResult_PingDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; + union LDKCResult_PingDecodeErrorZPtr contents; /** - * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + * Whether this CResult_PingDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_GossipTimestampFilterDecodeErrorZ; +} LDKCResult_PingDecodeErrorZ; + + /** - * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ + * A pong message to be sent or received from a peer */ -typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKPong { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePong *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPong; + +/** + * The contents of CResult_PongDecodeErrorZ + */ +typedef union LDKCResult_PongDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSpendableOutputDescriptor *result; + struct LDKPong *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; +} LDKCResult_PongDecodeErrorZPtr; /** - * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PongDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { +typedef struct LDKCResult_PongDecodeErrorZ { /** - * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either + * The contents of this CResult_PongDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; + union LDKCResult_PongDecodeErrorZPtr contents; /** - * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + * Whether this CResult_PongDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; +} LDKCResult_PongDecodeErrorZ; /** - * The contents of CResult_SignDecodeErrorZ + * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ */ -typedef union LDKCResult_SignDecodeErrorZPtr { +typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSign *result; + struct LDKUnsignedChannelAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_SignDecodeErrorZPtr; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; /** - * A CResult_SignDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignDecodeErrorZ { +typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { /** - * The contents of this CResult_SignDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignDecodeErrorZPtr contents; + union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_SignDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignDecodeErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_CVec_u8ZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKCVec_u8Z *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_CVec_u8ZZ; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; /** - * The contents of CResult_CVec_CVec_u8ZZNoneZ + * The contents of CResult_ChannelAnnouncementDecodeErrorZ */ -typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { +typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_CVec_u8ZZ *result; + struct LDKChannelAnnouncement *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_CVec_CVec_u8ZZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; /** - * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. + * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { +typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { /** - * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; + union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_CVec_u8ZZNoneZ; +} LDKCResult_ChannelAnnouncementDecodeErrorZ; /** - * A simple implementation of Sign that just keeps the private keys in memory. - * - * This implementation performs no policy checks and is insufficient by itself as - * a secure external signer. + * The unsigned part of a channel_update */ -typedef struct MUST_USE_STRUCT LDKInMemorySigner { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInMemorySigner *inner; + LDKnativeUnsignedChannelUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInMemorySigner; +} LDKUnsignedChannelUpdate; /** - * The contents of CResult_InMemorySignerDecodeErrorZ + * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ */ -typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { +typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInMemorySigner *result; + struct LDKUnsignedChannelUpdate *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InMemorySignerDecodeErrorZPtr; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; /** - * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InMemorySignerDecodeErrorZ { +typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { /** - * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InMemorySignerDecodeErrorZPtr contents; + union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InMemorySignerDecodeErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_TxOutZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKTxOut *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_TxOutZ; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; /** - * The contents of CResult_TransactionNoneZ + * The contents of CResult_ChannelUpdateDecodeErrorZ */ -typedef union LDKCResult_TransactionNoneZPtr { +typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTransaction *result; + struct LDKChannelUpdate *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_TransactionNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelUpdateDecodeErrorZPtr; /** - * A CResult_TransactionNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Transaction on success and a () on failure. + * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TransactionNoneZ { +typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { /** - * The contents of this CResult_TransactionNoneZ, accessible via either + * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TransactionNoneZPtr contents; + union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_TransactionNoneZ represents a success state. + * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TransactionNoneZ; +} LDKCResult_ChannelUpdateDecodeErrorZ; /** - * The contents of CResult_NoneErrorZ + * The contents of CResult_ErrorMessageDecodeErrorZ */ -typedef union LDKCResult_NoneErrorZPtr { +typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKErrorMessage *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKIOError *err; -} LDKCResult_NoneErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ErrorMessageDecodeErrorZPtr; /** - * A CResult_NoneErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::c_types::IOError on failure. + * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneErrorZ { +typedef struct LDKCResult_ErrorMessageDecodeErrorZ { /** - * The contents of this CResult_NoneErrorZ, accessible via either + * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneErrorZPtr contents; + union LDKCResult_ErrorMessageDecodeErrorZPtr contents; /** - * Whether this CResult_NoneErrorZ represents a success state. + * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneErrorZ; +} LDKCResult_ErrorMessageDecodeErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. - * This corresponds to std::vector in C++ + * The unsigned part of a node_announcement */ -typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { +typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *data; + LDKnativeUnsignedNodeAnnouncement *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; + bool is_owned; +} LDKUnsignedNodeAnnouncement; /** - * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ + * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ */ -typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; + struct LDKUnsignedNodeAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKIOError *err; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; /** - * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. + * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { /** - * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either + * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; + union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. + * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; /** - * A Rust str object, ie a reference to a UTF8-valid string. - * This is *not* null-terminated so cannot be used directly as a C string! + * The contents of CResult_NodeAnnouncementDecodeErrorZ */ -typedef struct LDKStr { +typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { /** - * A pointer to the string's bytes, in UTF8 encoding + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - const uint8_t *chars; + struct LDKNodeAnnouncement *result; /** - * The number of bytes (not characters!) pointed to by `chars` + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t len; -} LDKStr; + struct LDKDecodeError *err; +} LDKCResult_NodeAnnouncementDecodeErrorZPtr; /** - * Indicates an error on the client's part (usually some variant of attempting to use too-low or - * too-high values) + * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKAPIError_Tag { +typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { /** - * Indicates the API was wholly misused (see err for more). Cases where these can be returned - * are documented, but generally indicates some precondition of a function was violated. + * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKAPIError_APIMisuseError, + union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; /** - * Due to a high feerate, we were unable to complete the request. - * For example, this may be returned if the feerate implies we cannot open a channel at the - * requested value, but opening a larger channel would succeed. + * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. */ - LDKAPIError_FeeRateTooHigh, + bool result_ok; +} LDKCResult_NodeAnnouncementDecodeErrorZ; + +/** + * The contents of CResult_QueryShortChannelIdsDecodeErrorZ + */ +typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { /** - * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, - * too-many-hops, etc). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKAPIError_RouteError, + struct LDKQueryShortChannelIds *result; /** - * 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. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKAPIError_ChannelUnavailable, + struct LDKDecodeError *err; +} LDKCResult_QueryShortChannelIdsDecodeErrorZPtr; + +/** + * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { /** - * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the - * attempted action to fail. + * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKAPIError_MonitorUpdateFailed, + union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. */ - LDKAPIError_Sentinel, -} LDKAPIError_Tag; + bool result_ok; +} LDKCResult_QueryShortChannelIdsDecodeErrorZ; -typedef struct LDKAPIError_LDKAPIMisuseError_Body { - /** - * A human-readable error message - */ - struct LDKCVec_u8Z err; -} LDKAPIError_LDKAPIMisuseError_Body; -typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { - /** - * A human-readable error message - */ - struct LDKCVec_u8Z err; - /** - * The feerate which was too high. - */ - uint32_t feerate; -} LDKAPIError_LDKFeeRateTooHigh_Body; -typedef struct LDKAPIError_LDKRouteError_Body { +/** + * A reply_short_channel_ids_end message is sent as a reply to a + * query_short_channel_ids message. The query recipient makes a best + * effort to respond based on their local network view which may not be + * a perfect view of the network. + */ +typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { /** - * A human-readable error message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKStr err; -} LDKAPIError_LDKRouteError_Body; - -typedef struct LDKAPIError_LDKChannelUnavailable_Body { + LDKnativeReplyShortChannelIdsEnd *inner; /** - * A human-readable error message + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_u8Z err; -} LDKAPIError_LDKChannelUnavailable_Body; - -typedef struct MUST_USE_STRUCT LDKAPIError { - LDKAPIError_Tag tag; - union { - LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; - LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high; - LDKAPIError_LDKRouteError_Body route_error; - LDKAPIError_LDKChannelUnavailable_Body channel_unavailable; - }; -} LDKAPIError; + bool is_owned; +} LDKReplyShortChannelIdsEnd; /** - * The contents of CResult_NoneAPIErrorZ + * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ */ -typedef union LDKCResult_NoneAPIErrorZPtr { +typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKReplyShortChannelIdsEnd *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKAPIError *err; -} LDKCResult_NoneAPIErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; /** - * A CResult_NoneAPIErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneAPIErrorZ { +typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { /** - * The contents of this CResult_NoneAPIErrorZ, accessible via either + * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneAPIErrorZPtr contents; + union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; /** - * Whether this CResult_NoneAPIErrorZ represents a success state. + * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneAPIErrorZ; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_QueryChannelRangeDecodeErrorZ */ -typedef struct LDKCVec_CResult_NoneAPIErrorZZ { +typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NoneAPIErrorZ *data; + struct LDKQueryChannelRange *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_CResult_NoneAPIErrorZZ; + struct LDKDecodeError *err; +} LDKCResult_QueryChannelRangeDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_APIErrorZ { +typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKAPIError *data; + union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_APIErrorZ; + bool result_ok; +} LDKCResult_QueryChannelRangeDecodeErrorZ; /** - * 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. + * The contents of CResult_ReplyChannelRangeDecodeErrorZ */ -typedef enum LDKPaymentSendFailure_Tag { +typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { /** - * A parameter which was passed to send_payment was invalid, preventing us from attempting to - * send the payment at all. No channel state has been changed or messages sent to peers, and - * once you've changed the parameter at error, you can freely retry the payment in full. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKPaymentSendFailure_ParameterError, + struct LDKReplyChannelRange *result; /** - * A parameter in a single path which was passed to send_payment was invalid, preventing us - * from attempting to send the payment at all. No channel state has been changed or messages - * sent to peers, and once you've changed the parameter at error, you can freely retry the - * payment in full. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKPaymentSendFailure_PathParameterError, + struct LDKDecodeError *err; +} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; + +/** + * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { /** - * All paths which were attempted failed to send, with no channel state change taking place. - * You can freely retry the payment in full (though you probably want to do so over different - * paths than the ones selected). + * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKPaymentSendFailure_AllFailedRetrySafe, + union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; /** - * Some paths which were attempted failed to send, though possibly not all. At least some - * paths have irrevocably committed to the HTLC and retrying the payment in full would result - * in over-/re-payment. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely - * retried (though there is currently no API with which to do so). - * - * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried - * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the - * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel - * with the latest update_id. + * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. */ - LDKPaymentSendFailure_PartialFailure, + bool result_ok; +} LDKCResult_ReplyChannelRangeDecodeErrorZ; + + + +/** + * A gossip_timestamp_filter message is used by a node to request + * gossip relay for messages in the requested time range when the + * gossip_queries feature has been negotiated. + */ +typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { /** - * Must be last for serialization purposes + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKPaymentSendFailure_Sentinel, -} LDKPaymentSendFailure_Tag; - -typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { - LDKPaymentSendFailure_Tag tag; - union { - struct { - struct LDKAPIError parameter_error; - }; - struct { - struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; - }; - struct { - struct LDKCVec_APIErrorZ all_failed_retry_safe; - }; - struct { - struct LDKCVec_CResult_NoneAPIErrorZZ partial_failure; - }; - }; -} LDKPaymentSendFailure; + LDKnativeGossipTimestampFilter *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKGossipTimestampFilter; /** - * The contents of CResult_NonePaymentSendFailureZ + * The contents of CResult_GossipTimestampFilterDecodeErrorZ */ -typedef union LDKCResult_NonePaymentSendFailureZPtr { +typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKGossipTimestampFilter *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentSendFailure *err; -} LDKCResult_NonePaymentSendFailureZPtr; + struct LDKDecodeError *err; +} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; /** - * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. + * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NonePaymentSendFailureZ { +typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { /** - * The contents of this CResult_NonePaymentSendFailureZ, accessible via either + * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NonePaymentSendFailureZPtr contents; + union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; /** - * Whether this CResult_NonePaymentSendFailureZ represents a success state. + * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NonePaymentSendFailureZ; +} LDKCResult_GossipTimestampFilterDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ */ -typedef struct LDKCVec_ChannelMonitorZ { +typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelMonitor *data; + struct LDKSpendableOutputDescriptor *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_ChannelMonitorZ; + struct LDKDecodeError *err; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; /** - * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as - * blocks are connected and disconnected. - * - * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are - * responsible for maintaining a set of monitors such that they can be updated accordingly as - * channel state changes and HTLCs are resolved. See method documentation for specific - * requirements. - * - * Implementations **must** ensure that updates are successfully applied and persisted upon method - * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down - * without taking any further action such as persisting the current state. - * - * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing - * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it - * could result in a revoked transaction being broadcast, allowing the counterparty to claim all - * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle - * multiple instances. - * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr - * [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure + * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKWatch { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { /** - * Watches a channel identified by `funding_txo` using `monitor`. - * - * Implementations are responsible for watching the chain for the funding transaction along - * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means - * calling [`block_connected`] and [`block_disconnected`] on the monitor. - * - * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch - * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected - * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; /** - * Updates a channel identified by `funding_txo` by applying `update` to its monitor. - * - * Implementations must call [`update_monitor`] with the given update. See - * [`ChannelMonitorUpdateErr`] for invariants around returning an error. - * - * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor - * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr + * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); + bool result_ok; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; + +/** + * The contents of CResult_SignDecodeErrorZ + */ +typedef union LDKCResult_SignDecodeErrorZPtr { /** - * Returns any monitor events since the last call. Subsequent calls must only return new - * events. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); + struct LDKSign *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKWatch; + struct LDKDecodeError *err; +} LDKCResult_SignDecodeErrorZPtr; /** - * An interface to send a transaction to the Bitcoin network. + * A CResult_SignDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKBroadcasterInterface { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_SignDecodeErrorZ { /** - * Sends a transaction out to (hopefully) be mined. + * The contents of this CResult_SignDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + union LDKCResult_SignDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_SignDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKBroadcasterInterface; + bool result_ok; +} LDKCResult_SignDecodeErrorZ; /** - * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not - * own the memory pointed to by data. + * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKu8slice { +typedef struct LDKCVec_CVec_u8ZZ { /** - * A pointer to the byte buffer + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - const uint8_t *data; + struct LDKCVec_u8Z *data; /** - * The number of bytes pointed to by `data`. + * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKu8slice; +} LDKCVec_CVec_u8ZZ; /** - * A trait to describe an object which can get user secrets and key material. + * The contents of CResult_CVec_CVec_u8ZZNoneZ */ -typedef struct LDKKeysInterface { +typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKCVec_CVec_u8ZZ *result; /** - * Get node secret key (aka node_id or network_key). - * - * This method must return the same value each time it is called. - */ - struct LDKSecretKey (*get_node_secret)(const void *this_arg); - /** - * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. - */ - struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); - /** - * Get a public key which we will send funds to (in the form of a P2WPKH output) when closing - * a channel. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. - */ - struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); - /** - * Get a new set of Sign for per-channel secrets. These MUST be unique even if you - * restarted with some stale data! - * - * This method must return a different value each time it is called. - */ - struct LDKSign (*get_channel_signer)(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. - * - * This method must return a different value each time it is called. - */ - struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); - /** - * Reads a `Signer` for this `KeysInterface` from the given input stream. - * This is only called during deserialization of other objects which contain - * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). - * The bytes are exactly those which `::write()` writes, and - * contain no versioning scheme. You may wish to include your own version prefix and ensure - * you've read all of the provided bytes to ensure no corruption occurred. - */ - struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKKeysInterface; - -/** - * 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 { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Gets estimated satoshis of fee required per 1000 Weight-Units. - * - * 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); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*free)(void *this_arg); -} LDKFeeEstimator; + void *err; +} LDKCResult_CVec_CVec_u8ZZNoneZPtr; /** - * A trait encapsulating the operations required of a logger + * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKLogger { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { /** - * Logs the `Record` + * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*log)(const void *this_arg, const char *record); + union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. */ - void (*free)(void *this_arg); -} LDKLogger; + bool result_ok; +} LDKCResult_CVec_CVec_u8ZZNoneZ; /** - * Manager which keeps track of a number of channels and sends messages to the appropriate - * channel, also tracking HTLC preimages and forwarding onion packets appropriately. - * - * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through - * to individual Channels. - * - * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for - * all peers during write/read (though does not modify this instance, only the instance being - * serialized). This will result in any channels which have not yet exchanged funding_created (ie - * called funding_transaction_generated for outbound channels). - * - * Note that you can be a bit lazier about writing out ChannelManager than you can be with - * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before - * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates - * happens out-of-band (and will prevent any other ChannelManager operations from occurring during - * the serialization process). If the deserialized version is out-of-date compared to the - * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the - * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees). - * - * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call - * block_connected() to step towards your best block) upon deserialization before using the - * object! - * - * Note that ChannelManager is responsible for tracking liveness of its channels and generating - * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid - * spam due to quick disconnection/reconnection, updates are not sent until the channel has been - * offline for a full minute. In order to track this, you must call - * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect. + * A simple implementation of Sign that just keeps the private keys in memory. * - * 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. + * This implementation performs no policy checks and is insufficient by itself as + * a secure external signer. */ -typedef struct MUST_USE_STRUCT LDKChannelManager { +typedef struct MUST_USE_STRUCT LDKInMemorySigner { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelManager *inner; + LDKnativeInMemorySigner *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelManager; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_BlockHashChannelManagerZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKChannelManager b; -} LDKC2Tuple_BlockHashChannelManagerZ; +} LDKInMemorySigner; /** - * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + * The contents of CResult_InMemorySignerDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { +typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlockHashChannelManagerZ *result; + struct LDKInMemorySigner *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; +} LDKCResult_InMemorySignerDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +typedef struct LDKCResult_InMemorySignerDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; + union LDKCResult_InMemorySignerDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. + * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; +} LDKCResult_InMemorySignerDecodeErrorZ; /** - * A trait indicating an object may generate message send events + * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKMessageSendEventsProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCVec_TxOutZ { /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); + struct LDKTxOut *data; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The number of elements pointed to by `data`. */ - void (*free)(void *this_arg); -} LDKMessageSendEventsProvider; + uintptr_t datalen; +} LDKCVec_TxOutZ; /** - * A trait indicating an object may generate events + * The contents of CResult_TransactionNoneZ */ -typedef struct LDKEventsProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_TransactionNoneZPtr { /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg); + struct LDKTransaction *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*free)(void *this_arg); -} LDKEventsProvider; - - + void *err; +} LDKCResult_TransactionNoneZPtr; /** - * Configuration we set when applicable. - * - * Default::default() provides sane defaults. + * A CResult_TransactionNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Transaction on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { +typedef struct LDKCResult_TransactionNoneZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_TransactionNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeChannelHandshakeConfig *inner; + union LDKCResult_TransactionNoneZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_TransactionNoneZ represents a success state. */ - bool is_owned; -} LDKChannelHandshakeConfig; - - + bool result_ok; +} LDKCResult_TransactionNoneZ; /** - * Optional channel limits which are applied during channel creation. - * - * These limits are only applied to our counterparty's limits, not our own. - * - * Use 0/::max_value() as appropriate to skip checking. - * - * Provides sane defaults for most configurations. - * - * Most additional limits are disabled except those with which specify a default in individual - * field documentation. Note that this may result in barely-usable channels, but since they - * are applied mostly only to incoming channels that's not much of a problem. + * The contents of CResult_NoneErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { +typedef union LDKCResult_NoneErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKnativeChannelHandshakeLimits *inner; + void *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChannelHandshakeLimits; - - + enum LDKIOError *err; +} LDKCResult_NoneErrorZPtr; /** - * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. - * - * Default::default() provides sane defaults for most configurations - * (but currently with 0 relay fees!) + * A CResult_NoneErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::c_types::IOError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKUserConfig { +typedef struct LDKCResult_NoneErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_NoneErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeUserConfig *inner; + union LDKCResult_NoneErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_NoneErrorZ represents a success state. */ - bool is_owned; -} LDKUserConfig; + bool result_ok; +} LDKCResult_NoneErrorZ; /** - * The `Access` trait defines behavior for accessing chain data and state, such as blocks and - * UTXOs. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKAccess { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { /** - * 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 + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); + struct LDKC2Tuple_BlockHashChannelMonitorZ *data; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The number of elements pointed to by `data`. */ - void (*free)(void *this_arg); -} LDKAccess; + uintptr_t datalen; +} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; /** - * The `Listen` trait is used to notify when blocks have been connected or disconnected from the - * chain. - * - * Useful when needing to replay chain data upon startup or as new chain events occur. Clients - * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. - * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers - * when needed. + * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ */ -typedef struct LDKListen { +typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; /** - * Notifies the listener that a block was added at the given height. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); + enum LDKIOError *err; +} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; + +/** + * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { /** - * Notifies the listener that a block was removed at the given height. + * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKListen; + bool result_ok; +} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; /** - * The `Confirm` trait is used to notify when transactions have been confirmed on chain or - * unconfirmed during a chain reorganization. - * - * Clients sourcing chain data using a transaction-oriented API should prefer this interface over - * [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity - * related to registered transactions and outputs. Upon notification, it would pass along the - * matching transactions using this interface. - * - * # Use - * - * The intended use is as follows: - * - Call [`transactions_confirmed`] to process any on-chain activity of interest. - * - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`] - * that has been reorganized out of the chain. - * - Call [`best_block_updated`] whenever a new chain tip becomes available. - * - * # Order - * - * Clients must call these methods in chain order. Specifically: - * - Transactions confirmed in a block must be given before transactions confirmed in a later - * block. - * - Dependent transactions within the same block must be given in topological order, possibly in - * separate calls. - * - Unconfirmed transactions must be given after the original confirmations and before any - * reconfirmation. - * - * See individual method documentation for further details. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - * [`best_block_updated`]: Self::best_block_updated - * [`get_relevant_txids`]: Self::get_relevant_txids + * Indicates an error on the client's part (usually some variant of attempting to use too-low or + * too-high values) */ -typedef struct LDKConfirm { +typedef enum LDKAPIError_Tag { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * 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. */ - void *this_arg; + LDKAPIError_APIMisuseError, /** - * Processes transactions confirmed in a block with a given header and height. - * - * Should be called for any transactions registered by [`Filter::register_tx`] or any - * transactions spending an output registered by [`Filter::register_output`]. Such transactions - * appearing in the same block do not need to be included in the same call; instead, multiple - * calls with additional transactions may be made so long as they are made in [chain order]. - * - * May be called before or after [`best_block_updated`] for the corresponding block. However, - * in the event of a chain reorganization, it must not be called with a `header` that is no - * longer in the chain as of the last call to [`best_block_updated`]. - * - * [chain order]: Self#order - * [`best_block_updated`]: Self::best_block_updated + * 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. */ - void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + LDKAPIError_FeeRateTooHigh, /** - * Processes a transaction that is no longer confirmed as result of a chain reorganization. - * - * Should be called for any transaction returned by [`get_relevant_txids`] if it has been - * reorganized out of the best chain. Once called, the given transaction should not be returned - * by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`]. - * - * [`get_relevant_txids`]: Self::get_relevant_txids - * [`transactions_confirmed`]: Self::transactions_confirmed + * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + * too-many-hops, etc). */ - void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); + LDKAPIError_RouteError, /** - * Processes an update to the best header connected at the given height. - * - * Should be called when a new header is available but may be skipped for intermediary blocks - * if they become available at the same time. + * 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. */ - void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + LDKAPIError_ChannelUnavailable, /** - * Returns transactions that should be monitored for reorganization out of the chain. - * - * Should include any transactions passed to [`transactions_confirmed`] that have insufficient - * confirmations to be safe from a chain reorganization. Should not include any transactions - * passed to [`transaction_unconfirmed`] unless later reconfirmed. - * - * May be called to determine the subset of transactions that must still be monitored for - * reorganization. Will be idempotent between calls but may change as a result of calls to the - * other interface methods. Thus, this is useful to determine which transactions may need to be - * given to [`transaction_unconfirmed`]. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the + * attempted action to fail. */ - struct LDKCVec_TxidZ (*get_relevant_txids)(const void *this_arg); + LDKAPIError_MonitorUpdateFailed, /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Must be last for serialization purposes */ - void (*free)(void *this_arg); -} LDKConfirm; - - + LDKAPIError_Sentinel, +} LDKAPIError_Tag; -/** - * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. - * - * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction - * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via - * the return value of [`Filter::register_output`]. - * - * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and - * may have been spent there. See [`Filter::register_output`] for details. - * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected - */ -typedef struct MUST_USE_STRUCT LDKWatchedOutput { +typedef struct LDKAPIError_LDKAPIMisuseError_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A human-readable error message */ - LDKnativeWatchedOutput *inner; + struct LDKCVec_u8Z err; +} LDKAPIError_LDKAPIMisuseError_Body; + +typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKWatchedOutput; - -/** - * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to - * channels. - * - * This is useful in order to have a [`Watch`] implementation convey to a chain source which - * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in - * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If - * receiving full blocks from a chain source, any further filtering is unnecessary. - * - * After an output has been registered, subsequent block retrievals from the chain source must not - * exclude any transactions matching the new criteria nor any in-block descendants of such - * transactions. - * - * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` - * should not block on I/O. Implementations should instead queue the newly monitored data to be - * processed later. Then, in order to block until the data has been processed, any [`Watch`] - * invocation that has called the `Filter` must return [`TemporaryFailure`]. - * - * [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure - * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki - * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki - */ -typedef struct LDKFilter { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - * a spending condition. - */ - void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); - /** - * Registers interest in spends of a transaction output. - * - * Optionally, when `output.block_hash` is set, should return any transaction spending the - * output that is found in the corresponding block along with its index. - * - * This return value is useful for Electrum clients in order to supply in-block descendant - * transactions which otherwise were not included. This is not necessary for other clients if - * such descendant transactions were already included (e.g., when a BIP 157 client provides the - * full block). + * A human-readable error message */ - struct LDKCOption_C2Tuple_usizeTransactionZZ (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + struct LDKCVec_u8Z err; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The feerate which was too high. */ - void (*free)(void *this_arg); -} LDKFilter; + uint32_t feerate; +} LDKAPIError_LDKFeeRateTooHigh_Body; -/** - * `Persist` defines behavior for persisting channel monitors: this could mean - * writing once to disk, and/or uploading to one or more backup services. - * - * Note that for every new monitor, you **must** persist the new `ChannelMonitor` - * to disk/backups. And, on every update, you **must** persist either the - * `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk - * of situations such as revoking a transaction, then crashing before this - * revocation can be persisted, then unintentionally broadcasting a revoked - * transaction and losing money. This is a risk because previous channel states - * are toxic, so it's important that whatever channel state is persisted is - * kept up-to-date. - */ -typedef struct LDKPersist { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Persist a new channel's data. The data can be stored any way you want, but - * the identifier provided by Rust-Lightning is the channel's outpoint (and - * it is up to you to maintain a correct mapping between the outpoint and the - * stored channel data). Note that you **must** persist every new monitor to - * disk. See the `Persist` trait documentation for more details. - * - * See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, - * and [`ChannelMonitorUpdateErr`] for requirements when returning errors. - */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data); +typedef struct LDKAPIError_LDKRouteError_Body { /** - * Update one channel's data. The provided `ChannelMonitor` has already - * applied the given update. - * - * Note that on every update, you **must** persist either the - * `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See - * the `Persist` trait documentation for more details. - * - * If an implementer chooses to persist the updates only, they need to make - * sure that all the updates are applied to the `ChannelMonitors` *before* - * the set of channel monitors is given to the `ChannelManager` - * deserialization routine. See [`ChannelMonitor::update_monitor`] for - * applying a monitor update to a monitor. If full `ChannelMonitors` are - * persisted, then there is no need to persist individual updates. - * - * Note that there could be a performance tradeoff between persisting complete - * channel monitors on every update vs. persisting only updates and applying - * them in batches. The size of each monitor grows `O(number of state updates)` - * whereas updates are small and `O(1)`. - * - * See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, - * [`ChannelMonitorUpdate::write`] for writing out an update, and - * [`ChannelMonitorUpdateErr`] for requirements when returning errors. + * A human-readable error message */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data); + struct LDKStr err; +} LDKAPIError_LDKRouteError_Body; + +typedef struct LDKAPIError_LDKChannelUnavailable_Body { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A human-readable error message */ - void (*free)(void *this_arg); -} LDKPersist; - + struct LDKCVec_u8Z err; +} LDKAPIError_LDKChannelUnavailable_Body; +typedef struct MUST_USE_STRUCT LDKAPIError { + LDKAPIError_Tag tag; + union { + LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; + LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high; + LDKAPIError_LDKRouteError_Body route_error; + LDKAPIError_LDKChannelUnavailable_Body channel_unavailable; + }; +} LDKAPIError; /** - * An implementation of [`chain::Watch`] for monitoring channels. - * - * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by - * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally - * or used independently to monitor channels remotely. See the [module-level documentation] for - * details. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [module-level documentation]: crate::chain::chainmonitor + * The contents of CResult_NoneAPIErrorZ */ -typedef struct MUST_USE_STRUCT LDKChainMonitor { +typedef union LDKCResult_NoneAPIErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKnativeChainMonitor *inner; + void *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChainMonitor; - - + struct LDKAPIError *err; +} LDKCResult_NoneAPIErrorZPtr; /** - * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key - * and derives keys from that. - * - * Your node_id is seed/0' - * ChannelMonitor closes may use seed/1' - * Cooperative closes may use seed/2' - * The two close keys may be needed to claim on-chain funds! + * A CResult_NoneAPIErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKKeysManager { +typedef struct LDKCResult_NoneAPIErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_NoneAPIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeKeysManager *inner; + union LDKCResult_NoneAPIErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_NoneAPIErrorZ represents a success state. */ - bool is_owned; -} LDKKeysManager; - - + bool result_ok; +} LDKCResult_NoneAPIErrorZ; /** - * Chain-related parameters used to construct a new `ChannelManager`. - * - * Typically, the block-specific parameters are derived from the best block hash for the network, - * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters - * are not needed when deserializing a previously constructed `ChannelManager`. + * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChainParameters { +typedef struct LDKCVec_CResult_NoneAPIErrorZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeChainParameters *inner; + struct LDKCResult_NoneAPIErrorZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKChainParameters; - - + uintptr_t datalen; +} LDKCVec_CResult_NoneAPIErrorZZ; /** - * The best known block as identified by its hash and height. + * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKBestBlock { +typedef struct LDKCVec_APIErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeBestBlock *inner; + struct LDKAPIError *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKBestBlock; + uintptr_t datalen; +} LDKCVec_APIErrorZ; /** - * A 3-byte byte array. + * 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 LDKThreeBytes { +typedef enum LDKPaymentSendFailure_Tag { /** - * The three bytes + * A parameter which was passed to send_payment was invalid, preventing us from attempting to + * send the payment at all. No channel state has been changed or messages sent to peers, and + * once you've changed the parameter at error, you can freely retry the payment in full. */ - uint8_t data[3]; -} LDKThreeBytes; - -/** - * A trait to describe an object which can receive channel messages. - * - * Messages MAY be called in parallel when they originate from different their_node_ids, however - * they MUST NOT be called in parallel when the two calls have the same their_node_id. - */ -typedef struct LDKChannelMessageHandler { + LDKPaymentSendFailure_ParameterError, /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A parameter in a single path which was passed to send_payment was invalid, preventing us + * from attempting to send the payment at all. No channel state has been changed or messages + * sent to peers, and once you've changed the parameter at error, you can freely retry the + * payment in full. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment. */ - void *this_arg; + LDKPaymentSendFailure_PathParameterError, /** - * Handle an incoming open_channel message from the given peer. + * All paths which were attempted failed to send, with no channel state change taking place. + * You can freely retry the payment in full (though you probably want to do so over different + * paths than the ones selected). */ - void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKOpenChannel *NONNULL_PTR msg); + LDKPaymentSendFailure_AllFailedRetrySafe, /** - * Handle an incoming accept_channel message from the given peer. + * Some paths which were attempted failed to send, though possibly not all. At least some + * paths have irrevocably committed to the HTLC and retrying the payment in full would result + * in over-/re-payment. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely + * retried (though there is currently no API with which to do so). + * + * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried + * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the + * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel + * with the latest update_id. */ - void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKAcceptChannel *NONNULL_PTR msg); + LDKPaymentSendFailure_PartialFailure, /** - * Handle an incoming funding_created message from the given peer. + * Must be last for serialization purposes */ - void (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); + LDKPaymentSendFailure_Sentinel, +} LDKPaymentSendFailure_Tag; + +typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { + LDKPaymentSendFailure_Tag tag; + union { + struct { + struct LDKAPIError parameter_error; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; + }; + struct { + struct LDKCVec_APIErrorZ all_failed_retry_safe; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ partial_failure; + }; + }; +} LDKPaymentSendFailure; + +/** + * The contents of CResult_NonePaymentSendFailureZ + */ +typedef union LDKCResult_NonePaymentSendFailureZPtr { /** - * Handle an incoming funding_signed message from the given peer. + * Note that this value is always NULL, as there are no contents in the OK variant */ - void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + void *result; /** - * Handle an incoming funding_locked message from the given peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*handle_funding_locked)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingLocked *NONNULL_PTR msg); + struct LDKPaymentSendFailure *err; +} LDKCResult_NonePaymentSendFailureZPtr; + +/** + * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NonePaymentSendFailureZ { /** - * Handle an incoming shutdown message from the given peer. + * The contents of this CResult_NonePaymentSendFailureZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInitFeatures *NONNULL_PTR their_features, const struct LDKShutdown *NONNULL_PTR msg); + union LDKCResult_NonePaymentSendFailureZPtr contents; /** - * Handle an incoming closing_signed message from the given peer. + * Whether this CResult_NonePaymentSendFailureZ represents a success state. */ - void (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_NonePaymentSendFailureZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { /** - * Handle an incoming update_add_htlc message from the given peer. + * The element at position 0 */ - void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + struct LDKThirtyTwoBytes a; /** - * Handle an incoming update_fulfill_htlc message from the given peer. + * The element at position 1 */ - void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentSecretZ; + +/** + * The contents of CResult_PaymentSecretAPIErrorZ + */ +typedef union LDKCResult_PaymentSecretAPIErrorZPtr { /** - * Handle an incoming update_fail_htlc message from the given peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + struct LDKThirtyTwoBytes *result; /** - * Handle an incoming update_fail_malformed_htlc message from the given peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + struct LDKAPIError *err; +} LDKCResult_PaymentSecretAPIErrorZPtr; + +/** + * A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PaymentSecretAPIErrorZ { /** - * Handle an incoming commitment_signed message from the given peer. + * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + union LDKCResult_PaymentSecretAPIErrorZPtr contents; /** - * Handle an incoming revoke_and_ack message from the given peer. + * Whether this CResult_PaymentSecretAPIErrorZ represents a success state. */ - void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_PaymentSecretAPIErrorZ; + +/** + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_ChannelMonitorZ { /** - * Handle an incoming update_fee message from the given peer. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + struct LDKChannelMonitor *data; /** - * Handle an incoming announcement_signatures message from the given peer. + * The number of elements pointed to by `data`. */ - void (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + uintptr_t datalen; +} LDKCVec_ChannelMonitorZ; + +/** + * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as + * blocks are connected and disconnected. + * + * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are + * responsible for maintaining a set of monitors such that they can be updated accordingly as + * channel state changes and HTLCs are resolved. See method documentation for specific + * requirements. + * + * Implementations **must** ensure that updates are successfully applied and persisted upon method + * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down + * without taking any further action such as persisting the current state. + * + * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing + * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it + * could result in a revoked transaction being broadcast, allowing the counterparty to claim all + * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle + * multiple instances. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr + * [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure + */ +typedef struct LDKWatch { /** - * Indicates a connection to the peer failed/an existing connection was lost. If no connection - * is believed to be possible in the future (eg they're sending us messages we don't - * understand or indicate they require unknown feature bits), no_connection_possible is set - * and any outstanding channels should be failed. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible); + void *this_arg; /** - * Handle a peer reconnecting, possibly generating channel_reestablish message(s). + * Watches a channel identified by `funding_txo` using `monitor`. + * + * Implementations are responsible for watching the chain for the funding transaction along + * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + * calling [`block_connected`] and [`block_disconnected`] on the monitor. + * + * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected */ - void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg); + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** - * Handle an incoming channel_reestablish message from the given peer. + * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * + * Implementations must call [`update_monitor`] with the given update. See + * [`ChannelMonitorUpdateErr`] for invariants around returning an error. + * + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr */ - void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); /** - * Handle an incoming channel update from the given peer. + * Returns any monitor events since the last call. Subsequent calls must only return new + * events. */ - void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); /** - * Handle an incoming error message from the given peer. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + void (*free)(void *this_arg); +} LDKWatch; + +/** + * An interface to send a transaction to the Bitcoin network. + */ +typedef struct LDKBroadcasterInterface { /** - * Implementation of MessageSendEventsProvider for this object. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKMessageSendEventsProvider MessageSendEventsProvider; + void *this_arg; + /** + * Sends a transaction out to (hopefully) be mined. + */ + void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKChannelMessageHandler; - - +} LDKBroadcasterInterface; /** - * Arguments for the creation of a ChannelManager that are not deserialized. - * - * At a high-level, the process for deserializing a ChannelManager and resuming normal operation - * is: - * 1) Deserialize all stored ChannelMonitors. - * 2) Deserialize the ChannelManager by filling in this struct and calling: - * <(BlockHash, ChannelManager)>::read(reader, args) - * This may result in closing some Channels if the ChannelMonitor is newer than the stored - * ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted. - * 3) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same - * way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and - * ChannelMonitor::get_funding_txo(). - * 4) Reconnect blocks on your ChannelMonitors. - * 5) Disconnect/connect blocks on the ChannelManager. - * 6) Move the ChannelMonitors into your local chain::Watch. - * - * Note that the ordering of #4-6 is not of importance, however all three must occur before you - * call any other methods on the newly-deserialized ChannelManager. - * - * Note that because some channels may be closed during deserialization, it is critical that you - * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to - * you. If you deserialize an old ChannelManager (during which force-closure transactions may be - * broadcast), and then later deserialize a newer version of the same ChannelManager (which will - * not force-close the same channels but consider them live), you may end up revoking a state for - * which you've already broadcasted the transaction. + * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not + * own the memory pointed to by data. */ -typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { +typedef struct LDKu8slice { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelManagerReadArgs *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChannelManagerReadArgs; - - - -/** - * Proof that the sender knows the per-commitment secret of the previous commitment transaction. - * This is used to convince the recipient that the channel is at a certain commitment - * number even if they lost that data due to a local failure. Of course, the peer may lie - * and even later commitments may have been revoked. - */ -typedef struct MUST_USE_STRUCT LDKDataLossProtect { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the byte buffer */ - LDKnativeDataLossProtect *inner; + const uint8_t *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of bytes pointed to by `data`. */ - bool is_owned; -} LDKDataLossProtect; + uintptr_t datalen; +} LDKu8slice; /** - * A trait to describe an object which can receive routing messages. - * - * # Implementor DoS Warnings - * - * For `gossip_queries` messages there are potential DoS vectors when handling - * inbound queries. Implementors using an on-disk network graph should be aware of - * repeated disk I/O for queries accessing different parts of the network graph. + * A trait to describe an object which can get user secrets and key material. */ -typedef struct LDKRoutingMessageHandler { +typedef struct LDKKeysInterface { /** * An opaque pointer which is passed to your function implementations as an argument. * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; /** - * Handle an incoming node_announcement message, returning true if it should be forwarded on, - * false or returning an Err otherwise. + * Get node secret key (aka node_id or network_key). + * + * This method must return the same value each time it is called. */ - struct LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); + struct LDKSecretKey (*get_node_secret)(const void *this_arg); /** - * Handle a channel_announcement message, returning true if it should be forwarded on, false - * or returning an Err otherwise. + * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - struct LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); + struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); /** - * Handle an incoming channel_update message, returning true if it should be forwarded on, - * false or returning an Err otherwise. + * Get a public key which we will send funds to (in the form of a P2WPKH output) when closing + * a channel. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); + struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); /** - * Handle some updates to the route graph that we learned due to an outbound failed payment. + * Get a new set of Sign for per-channel secrets. These MUST be unique even if you + * restarted with some stale data! + * + * This method must return a different value each time it is called. */ - void (*handle_htlc_fail_channel_update)(const void *this_arg, const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update); + struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); /** - * Gets a subset of the channel announcements and updates required to dump our routing table - * to a remote node, starting at the short_channel_id indicated by starting_point and - * including the batch_amount entries immediately higher in numerical value than starting_point. + * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting + * onion packets and for temporary channel IDs. There is no requirement that these be + * persisted anywhere, though they must be unique across restarts. + * + * This method must return a different value each time it is called. */ - struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount); + struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); /** - * Gets a subset of the node announcements required to dump our routing table to a remote node, - * starting at the node *after* the provided publickey and including batch_amount entries - * immediately higher (as defined by ::cmp) than starting_point. - * If None is provided for starting_point, we start at the first node. + * Reads a `Signer` for this `KeysInterface` from the given input stream. + * This is only called during deserialization of other objects which contain + * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). + * The bytes are exactly those which `::write()` writes, and + * contain no versioning scheme. You may wish to include your own version prefix and ensure + * you've read all of the provided bytes to ensure no corruption occurred. */ - struct LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount); + struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** - * Called when a connection is established with a peer. This can be used to - * perform routing table synchronization using a strategy defined by the - * implementor. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - void (*sync_routing_table)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); + 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 { /** - * Handles the reply of a query we initiated to learn about channels - * for a given range of blocks. We can expect to receive one or more - * replies to a single query. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); + void *this_arg; /** - * Handles the reply of a query we initiated asking for routing gossip - * messages for a list of channels. We should receive this message when - * a node has completed its best effort to send us the pertaining routing - * gossip messages. + * 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) */ - struct LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); + uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); /** - * Handles when a peer asks us to send a list of short_channel_ids - * for the requested range of blocks. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - struct LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + void (*free)(void *this_arg); +} LDKFeeEstimator; + +/** + * A trait encapsulating the operations required of a logger + */ +typedef struct LDKLogger { /** - * Handles when a peer asks us to send routing gossip messages for a - * list of short_channel_ids. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + void *this_arg; /** - * Implementation of MessageSendEventsProvider for this object. + * Logs the `Record` */ - struct LDKMessageSendEventsProvider MessageSendEventsProvider; + void (*log)(const void *this_arg, const char *record); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKRoutingMessageHandler; +} LDKLogger; /** - * A dummy struct which implements `RoutingMessageHandler` without storing any routing information - * or doing any processing. You can provide one of these as the route_handler in a MessageHandler. + * Manager which keeps track of a number of channels and sends messages to the appropriate + * channel, also tracking HTLC preimages and forwarding onion packets appropriately. + * + * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through + * to individual Channels. + * + * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for + * all peers during write/read (though does not modify this instance, only the instance being + * serialized). This will result in any channels which have not yet exchanged funding_created (ie + * called funding_transaction_generated for outbound channels). + * + * Note that you can be a bit lazier about writing out ChannelManager than you can be with + * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before + * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates + * happens out-of-band (and will prevent any other ChannelManager operations from occurring during + * the serialization process). If the deserialized version is out-of-date compared to the + * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the + * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees). + * + * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call + * block_connected() to step towards your best block) upon deserialization before using the + * object! + * + * Note that ChannelManager is responsible for tracking liveness of its channels and generating + * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid + * spam due to quick disconnection/reconnection, updates are not sent until the channel has been + * offline for a full minute. In order to track this, you must call + * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect. + * + * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager + * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but + * essentially you should default to using a SimpleRefChannelManager, and use a + * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when + * you're using lightning-net-tokio. */ -typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { +typedef struct MUST_USE_STRUCT LDKChannelManager { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeIgnoringMessageHandler *inner; + LDKnativeChannelManager *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKIgnoringMessageHandler; - - +} LDKChannelManager; /** - * A dummy struct which implements `ChannelMessageHandler` without having any channels. - * You can provide one of these as the route_handler in a MessageHandler. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { +typedef struct LDKC2Tuple_BlockHashChannelManagerZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeErroringMessageHandler *inner; + struct LDKThirtyTwoBytes a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKErroringMessageHandler; - - + struct LDKChannelManager b; +} LDKC2Tuple_BlockHashChannelManagerZ; /** - * Provides references to trait impls which handle different types of messages. + * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKMessageHandler { +typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeMessageHandler *inner; + struct LDKC2Tuple_BlockHashChannelManagerZ *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKMessageHandler; + struct LDKDecodeError *err; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; /** - * Provides an object which can be used to send data to and which uniquely identifies a connection - * to a remote host. You will need to be able to generate multiple of these which meet Eq and - * implement Hash to meet the PeerManager API. - * - * For efficiency, Clone should be relatively cheap for this type. - * - * You probably want to just extend an int and put a file descriptor in a struct and implement - * send_data. Note that if you are using a higher-level net library that may call close() itself, - * be careful to ensure you don't have races whereby you might register a new connection with an - * fd which is the same as a previous one which has yet to be removed via - * PeerManager::socket_disconnected(). + * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKSocketDescriptor { +typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + /** + * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; + /** + * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; + +/** + * A trait indicating an object may generate message send events + */ +typedef struct LDKMessageSendEventsProvider { /** * An opaque pointer which is passed to your function implementations as an argument. * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; /** - * Attempts to send some data from the given slice to the peer. - * - * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. - * Note that in the disconnected case, socket_disconnected must still fire and further write - * attempts may occur until that time. - * - * If the returned size is smaller than data.len(), a write_available event must - * trigger the next time more data can be written. Additionally, until the a send_data event - * completes fully, no further read_events should trigger on the same peer! - * - * If a read_event on this descriptor had previously returned true (indicating that read - * events should be paused to prevent DoS in the send buffer), resume_read may be set - * indicating that read events on this descriptor should resume. A resume_read of false does - * *not* imply that further read events should be paused. - */ - uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); - /** - * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no - * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with - * this descriptor. No socket_disconnected call should be generated as a result of this call, - * though races may occur whereby disconnect_socket is called after a call to - * socket_disconnected but prior to socket_disconnected returning. + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. */ - void (*disconnect_socket)(void *this_arg); + struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); /** - * Checks if two objects are equal given this object's this_arg pointer and another object. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + void (*free)(void *this_arg); +} LDKMessageSendEventsProvider; + +/** + * A trait indicating an object may generate events + */ +typedef struct LDKEventsProvider { /** - * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. - * This is used, for example, for inclusion of this object in a hash map. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - uint64_t (*hash)(const void *this_arg); + void *this_arg; /** - * Creates a copy of the object pointed to by this_arg, for a copy of this SocketDescriptor. - * Note that the ultimate copy of the SocketDescriptor will have all function pointers the same as the original. - * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new SocketDescriptor. + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. */ - void *(*clone)(const void *this_arg); + struct LDKCVec_EventZ (*get_and_clear_pending_events)(const void *this_arg); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKSocketDescriptor; +} LDKEventsProvider; /** - * A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket - * events into messages which it passes on to its MessageHandlers. + * Configuration we set when applicable. * - * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager - * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but - * essentially you should default to using a SimpleRefPeerManager, and use a - * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when - * you're using lightning-net-tokio. + * Default::default() provides sane defaults. */ -typedef struct MUST_USE_STRUCT LDKPeerManager { +typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePeerManager *inner; + LDKnativeChannelHandshakeConfig *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPeerManager; +} LDKChannelHandshakeConfig; /** - * Static channel fields used to build transactions given per-commitment fields, organized by - * broadcaster/countersignatory. + * Optional channel limits which are applied during channel creation. * - * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the - * as_holder_broadcastable and as_counterparty_broadcastable functions. + * These limits are only applied to our counterparty's limits, not our own. + * + * Use 0/::max_value() as appropriate to skip checking. + * + * Provides sane defaults for most configurations. + * + * Most additional limits are disabled except those with which specify a default in individual + * field documentation. Note that this may result in barely-usable channels, but since they + * are applied mostly only to incoming channels that's not much of a problem. */ -typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { +typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDirectedChannelTransactionParameters *inner; + LDKnativeChannelHandshakeLimits *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDirectedChannelTransactionParameters; +} LDKChannelHandshakeLimits; /** - * A simple newtype for RwLockReadGuard<'a, NetworkGraph>. - * This exists only to make accessing a RwLock possible from - * the C bindings, as it can be done directly in Rust code. + * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. + * + * Default::default() provides sane defaults for most configurations + * (but currently with 0 relay fees!) */ -typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph { +typedef struct MUST_USE_STRUCT LDKUserConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeLockedNetworkGraph *inner; + LDKnativeUserConfig *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKLockedNetworkGraph; +} LDKUserConfig; +/** + * The `Access` trait defines behavior for accessing chain data and state, such as blocks and + * UTXOs. + */ +typedef struct LDKAccess { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. + * 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 + */ + struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKAccess; +/** + * The `Listen` trait is used to notify when blocks have been connected or disconnected from the + * chain. + * + * Useful when needing to replay chain data upon startup or as new chain events occur. Clients + * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. + * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers + * when needed. + */ +typedef struct LDKListen { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Notifies the listener that a block was added at the given height. + */ + void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); + /** + * Notifies the listener that a block was removed at the given height. + */ + void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKListen; /** - * Receives and validates network updates from peers, - * stores authentic and relevant data as a network graph. - * This network graph is then used for routing payments. - * Provides interface to help with initial routing sync by - * serving historical announcements. + * The `Confirm` trait is used to notify when transactions have been confirmed on chain or + * unconfirmed during a chain reorganization. + * + * Clients sourcing chain data using a transaction-oriented API should prefer this interface over + * [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity + * related to registered transactions and outputs. Upon notification, it would pass along the + * matching transactions using this interface. + * + * # Use + * + * The intended use is as follows: + * - Call [`transactions_confirmed`] to process any on-chain activity of interest. + * - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`] + * that has been reorganized out of the chain. + * - Call [`best_block_updated`] whenever a new chain tip becomes available. + * + * # Order + * + * Clients must call these methods in chain order. Specifically: + * - Transactions confirmed in a block must be given before transactions confirmed in a later + * block. + * - Dependent transactions within the same block must be given in topological order, possibly in + * separate calls. + * - Unconfirmed transactions must be given after the original confirmations and before any + * reconfirmation. + * + * See individual method documentation for further details. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * [`best_block_updated`]: Self::best_block_updated + * [`get_relevant_txids`]: Self::get_relevant_txids */ -typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler { +typedef struct LDKConfirm { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKnativeNetGraphMsgHandler *inner; + void *this_arg; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Processes transactions confirmed in a block with a given header and height. + * + * Should be called for any transactions registered by [`Filter::register_tx`] or any + * transactions spending an output registered by [`Filter::register_output`]. Such transactions + * appearing in the same block do not need to be included in the same call; instead, multiple + * calls with additional transactions may be made so long as they are made in [chain order]. + * + * May be called before or after [`best_block_updated`] for the corresponding block. However, + * in the event of a chain reorganization, it must not be called with a `header` that is no + * longer in the chain as of the last call to [`best_block_updated`]. + * + * [chain order]: Confirm#Order + * [`best_block_updated`]: Self::best_block_updated */ - bool is_owned; -} LDKNetGraphMsgHandler; + void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + /** + * Processes a transaction that is no longer confirmed as result of a chain reorganization. + * + * Should be called for any transaction returned by [`get_relevant_txids`] if it has been + * reorganized out of the best chain. Once called, the given transaction should not be returned + * by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`]. + * + * [`get_relevant_txids`]: Self::get_relevant_txids + * [`transactions_confirmed`]: Self::transactions_confirmed + */ + void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); + /** + * Processes an update to the best header connected at the given height. + * + * Should be called when a new header is available but may be skipped for intermediary blocks + * if they become available at the same time. + */ + void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + /** + * Returns transactions that should be monitored for reorganization out of the chain. + * + * Should include any transactions passed to [`transactions_confirmed`] that have insufficient + * confirmations to be safe from a chain reorganization. Should not include any transactions + * passed to [`transaction_unconfirmed`] unless later reconfirmed. + * + * May be called to determine the subset of transactions that must still be monitored for + * reorganization. Will be idempotent between calls but may change as a result of calls to the + * other interface methods. Thus, this is useful to determine which transactions may need to be + * given to [`transaction_unconfirmed`]. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + */ + struct LDKCVec_TxidZ (*get_relevant_txids)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKConfirm; + + + +/** + * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. + * + * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction + * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via + * the return value of [`Filter::register_output`]. + * + * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and + * may have been spent there. See [`Filter::register_output`] for details. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected + */ +typedef struct MUST_USE_STRUCT LDKWatchedOutput { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeWatchedOutput *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKWatchedOutput; + +/** + * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to + * channels. + * + * This is useful in order to have a [`Watch`] implementation convey to a chain source which + * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in + * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If + * receiving full blocks from a chain source, any further filtering is unnecessary. + * + * After an output has been registered, subsequent block retrievals from the chain source must not + * exclude any transactions matching the new criteria nor any in-block descendants of such + * transactions. + * + * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` + * should not block on I/O. Implementations should instead queue the newly monitored data to be + * processed later. Then, in order to block until the data has been processed, any [`Watch`] + * invocation that has called the `Filter` must return [`TemporaryFailure`]. + * + * [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure + * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki + * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki + */ +typedef struct LDKFilter { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + * a spending condition. + */ + void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + /** + * Registers interest in spends of a transaction output. + * + * Optionally, when `output.block_hash` is set, should return any transaction spending the + * output that is found in the corresponding block along with its index. + * + * This return value is useful for Electrum clients in order to supply in-block descendant + * transactions which otherwise were not included. This is not necessary for other clients if + * such descendant transactions were already included (e.g., when a BIP 157 client provides the + * full block). + */ + struct LDKCOption_C2Tuple_usizeTransactionZZ (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFilter; + +/** + * `Persist` defines behavior for persisting channel monitors: this could mean + * writing once to disk, and/or uploading to one or more backup services. + * + * Note that for every new monitor, you **must** persist the new `ChannelMonitor` + * to disk/backups. And, on every update, you **must** persist either the + * `ChannelMonitorUpdate` or the updated monitor itself. Otherwise, there is risk + * of situations such as revoking a transaction, then crashing before this + * revocation can be persisted, then unintentionally broadcasting a revoked + * transaction and losing money. This is a risk because previous channel states + * are toxic, so it's important that whatever channel state is persisted is + * kept up-to-date. + */ +typedef struct LDKPersist { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Persist a new channel's data. The data can be stored any way you want, but + * the identifier provided by Rust-Lightning is the channel's outpoint (and + * it is up to you to maintain a correct mapping between the outpoint and the + * stored channel data). Note that you **must** persist every new monitor to + * disk. See the `Persist` trait documentation for more details. + * + * See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, + * and [`ChannelMonitorUpdateErr`] for requirements when returning errors. + */ + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data); + /** + * Update one channel's data. The provided `ChannelMonitor` has already + * applied the given update. + * + * Note that on every update, you **must** persist either the + * `ChannelMonitorUpdate` or the updated monitor itself to disk/backups. See + * the `Persist` trait documentation for more details. + * + * If an implementer chooses to persist the updates only, they need to make + * sure that all the updates are applied to the `ChannelMonitors` *before* + * the set of channel monitors is given to the `ChannelManager` + * deserialization routine. See [`ChannelMonitor::update_monitor`] for + * applying a monitor update to a monitor. If full `ChannelMonitors` are + * persisted, then there is no need to persist individual updates. + * + * Note that there could be a performance tradeoff between persisting complete + * channel monitors on every update vs. persisting only updates and applying + * them in batches. The size of each monitor grows `O(number of state updates)` + * whereas updates are small and `O(1)`. + * + * See [`ChannelMonitor::write`] for writing out a `ChannelMonitor`, + * [`ChannelMonitorUpdate::write`] for writing out an update, and + * [`ChannelMonitorUpdateErr`] for requirements when returning errors. + */ + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKPersist; + + + +/** + * An implementation of [`chain::Watch`] for monitoring channels. + * + * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by + * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally + * or used independently to monitor channels remotely. See the [module-level documentation] for + * details. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [module-level documentation]: crate::chain::chainmonitor + */ +typedef struct MUST_USE_STRUCT LDKChainMonitor { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChainMonitor *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChainMonitor; + + + +/** + * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key + * and derives keys from that. + * + * Your node_id is seed/0' + * ChannelMonitor closes may use seed/1' + * Cooperative closes may use seed/2' + * The two close keys may be needed to claim on-chain funds! + */ +typedef struct MUST_USE_STRUCT LDKKeysManager { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeKeysManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKKeysManager; + + + +/** + * Chain-related parameters used to construct a new `ChannelManager`. + * + * Typically, the block-specific parameters are derived from the best block hash for the network, + * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters + * are not needed when deserializing a previously constructed `ChannelManager`. + */ +typedef struct MUST_USE_STRUCT LDKChainParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChainParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChainParameters; + + + +/** + * The best known block as identified by its hash and height. + */ +typedef struct MUST_USE_STRUCT LDKBestBlock { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBestBlock *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBestBlock; + +/** + * A 3-byte byte array. + */ +typedef struct LDKThreeBytes { + /** + * The three bytes + */ + uint8_t data[3]; +} LDKThreeBytes; + +/** + * A trait to describe an object which can receive channel messages. + * + * Messages MAY be called in parallel when they originate from different their_node_ids, however + * they MUST NOT be called in parallel when the two calls have the same their_node_id. + */ +typedef struct LDKChannelMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handle an incoming open_channel message from the given peer. + */ + void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKOpenChannel *NONNULL_PTR msg); + /** + * Handle an incoming accept_channel message from the given peer. + */ + void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKAcceptChannel *NONNULL_PTR msg); + /** + * Handle an incoming funding_created message from the given peer. + */ + void (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); + /** + * Handle an incoming funding_signed message from the given peer. + */ + void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + /** + * Handle an incoming funding_locked message from the given peer. + */ + void (*handle_funding_locked)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingLocked *NONNULL_PTR msg); + /** + * Handle an incoming shutdown message from the given peer. + */ + void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInitFeatures *NONNULL_PTR their_features, const struct LDKShutdown *NONNULL_PTR msg); + /** + * Handle an incoming closing_signed message from the given peer. + */ + void (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + /** + * Handle an incoming update_add_htlc message from the given peer. + */ + void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + /** + * Handle an incoming update_fulfill_htlc message from the given peer. + */ + void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + /** + * Handle an incoming update_fail_htlc message from the given peer. + */ + void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + /** + * Handle an incoming update_fail_malformed_htlc message from the given peer. + */ + void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + /** + * Handle an incoming commitment_signed message from the given peer. + */ + void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + /** + * Handle an incoming revoke_and_ack message from the given peer. + */ + void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + /** + * Handle an incoming update_fee message from the given peer. + */ + void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + /** + * Handle an incoming announcement_signatures message from the given peer. + */ + void (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + /** + * Indicates a connection to the peer failed/an existing connection was lost. If no connection + * is believed to be possible in the future (eg they're sending us messages we don't + * understand or indicate they require unknown feature bits), no_connection_possible is set + * and any outstanding channels should be failed. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible); + /** + * Handle a peer reconnecting, possibly generating channel_reestablish message(s). + */ + void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg); + /** + * Handle an incoming channel_reestablish message from the given peer. + */ + void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + /** + * Handle an incoming channel update from the given peer. + */ + void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Handle an incoming error message from the given peer. + */ + void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + /** + * Implementation of MessageSendEventsProvider for this object. + */ + struct LDKMessageSendEventsProvider MessageSendEventsProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKChannelMessageHandler; + + + +/** + * Arguments for the creation of a ChannelManager that are not deserialized. + * + * At a high-level, the process for deserializing a ChannelManager and resuming normal operation + * is: + * 1) Deserialize all stored ChannelMonitors. + * 2) Deserialize the ChannelManager by filling in this struct and calling: + * <(BlockHash, ChannelManager)>::read(reader, args) + * This may result in closing some Channels if the ChannelMonitor is newer than the stored + * ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted. + * 3) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same + * way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and + * ChannelMonitor::get_funding_txo(). + * 4) Reconnect blocks on your ChannelMonitors. + * 5) Disconnect/connect blocks on the ChannelManager. + * 6) Move the ChannelMonitors into your local chain::Watch. + * + * Note that the ordering of #4-6 is not of importance, however all three must occur before you + * call any other methods on the newly-deserialized ChannelManager. + * + * Note that because some channels may be closed during deserialization, it is critical that you + * always deserialize only the latest version of a ChannelManager and ChannelMonitors available to + * you. If you deserialize an old ChannelManager (during which force-closure transactions may be + * broadcast), and then later deserialize a newer version of the same ChannelManager (which will + * not force-close the same channels but consider them live), you may end up revoking a state for + * which you've already broadcasted the transaction. + */ +typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelManagerReadArgs *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelManagerReadArgs; + + + +/** + * Proof that the sender knows the per-commitment secret of the previous commitment transaction. + * This is used to convince the recipient that the channel is at a certain commitment + * number even if they lost that data due to a local failure. Of course, the peer may lie + * and even later commitments may have been revoked. + */ +typedef struct MUST_USE_STRUCT LDKDataLossProtect { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDataLossProtect *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDataLossProtect; + +/** + * A trait to describe an object which can receive routing messages. + * + * # Implementor DoS Warnings + * + * For `gossip_queries` messages there are potential DoS vectors when handling + * inbound queries. Implementors using an on-disk network graph should be aware of + * repeated disk I/O for queries accessing different parts of the network graph. + */ +typedef struct LDKRoutingMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handle an incoming node_announcement message, returning true if it should be forwarded on, + * false or returning an Err otherwise. + */ + struct LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); + /** + * Handle a channel_announcement message, returning true if it should be forwarded on, false + * or returning an Err otherwise. + */ + struct LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); + /** + * Handle an incoming channel_update message, returning true if it should be forwarded on, + * false or returning an Err otherwise. + */ + struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Handle some updates to the route graph that we learned due to an outbound failed payment. + */ + void (*handle_htlc_fail_channel_update)(const void *this_arg, const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update); + /** + * Gets a subset of the channel announcements and updates required to dump our routing table + * to a remote node, starting at the short_channel_id indicated by starting_point and + * including the batch_amount entries immediately higher in numerical value than starting_point. + */ + struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcements)(const void *this_arg, uint64_t starting_point, uint8_t batch_amount); + /** + * Gets a subset of the node announcements required to dump our routing table to a remote node, + * starting at the node *after* the provided publickey and including batch_amount entries + * immediately higher (as defined by ::cmp) than starting_point. + * If None is provided for starting_point, we start at the first node. + */ + struct LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount); + /** + * Called when a connection is established with a peer. This can be used to + * perform routing table synchronization using a strategy defined by the + * implementor. + */ + void (*sync_routing_table)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); + /** + * Handles the reply of a query we initiated to learn about channels + * for a given range of blocks. We can expect to receive one or more + * replies to a single query. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); + /** + * Handles the reply of a query we initiated asking for routing gossip + * messages for a list of channels. We should receive this message when + * a node has completed its best effort to send us the pertaining routing + * gossip messages. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); + /** + * Handles when a peer asks us to send a list of short_channel_ids + * for the requested range of blocks. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + /** + * Handles when a peer asks us to send routing gossip messages for a + * list of short_channel_ids. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + /** + * Implementation of MessageSendEventsProvider for this object. + */ + struct LDKMessageSendEventsProvider MessageSendEventsProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKRoutingMessageHandler; + + + +/** + * A dummy struct which implements `RoutingMessageHandler` without storing any routing information + * or doing any processing. You can provide one of these as the route_handler in a MessageHandler. + */ +typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeIgnoringMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKIgnoringMessageHandler; + + + +/** + * A dummy struct which implements `ChannelMessageHandler` without having any channels. + * You can provide one of these as the route_handler in a MessageHandler. + */ +typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeErroringMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKErroringMessageHandler; + + + +/** + * Provides references to trait impls which handle different types of messages. + */ +typedef struct MUST_USE_STRUCT LDKMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMessageHandler; + +/** + * Provides an object which can be used to send data to and which uniquely identifies a connection + * to a remote host. You will need to be able to generate multiple of these which meet Eq and + * implement Hash to meet the PeerManager API. + * + * For efficiency, Clone should be relatively cheap for this type. + * + * You probably want to just extend an int and put a file descriptor in a struct and implement + * send_data. Note that if you are using a higher-level net library that may call close() itself, + * be careful to ensure you don't have races whereby you might register a new connection with an + * fd which is the same as a previous one which has yet to be removed via + * PeerManager::socket_disconnected(). + */ +typedef struct LDKSocketDescriptor { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Attempts to send some data from the given slice to the peer. + * + * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. + * Note that in the disconnected case, socket_disconnected must still fire and further write + * attempts may occur until that time. + * + * If the returned size is smaller than data.len(), a write_available event must + * trigger the next time more data can be written. Additionally, until the a send_data event + * completes fully, no further read_events should trigger on the same peer! + * + * If a read_event on this descriptor had previously returned true (indicating that read + * events should be paused to prevent DoS in the send buffer), resume_read may be set + * indicating that read events on this descriptor should resume. A resume_read of false does + * *not* imply that further read events should be paused. + */ + uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); + /** + * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no + * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with + * this descriptor. No socket_disconnected call should be generated as a result of this call, + * though races may occur whereby disconnect_socket is called after a call to + * socket_disconnected but prior to socket_disconnected returning. + */ + void (*disconnect_socket)(void *this_arg); + /** + * Checks if two objects are equal given this object's this_arg pointer and another object. + */ + bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + /** + * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. + * This is used, for example, for inclusion of this object in a hash map. + */ + uint64_t (*hash)(const void *this_arg); + /** + * Creates a copy of the object pointed to by this_arg, for a copy of this SocketDescriptor. + * Note that the ultimate copy of the SocketDescriptor will have all function pointers the same as the original. + * May be NULL if no action needs to be taken, the this_arg pointer will be copied into the new SocketDescriptor. + */ + void *(*clone)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSocketDescriptor; + + + +/** + * A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket + * events into messages which it passes on to its MessageHandlers. + * + * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager + * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but + * essentially you should default to using a SimpleRefPeerManager, and use a + * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when + * you're using lightning-net-tokio. + */ +typedef struct MUST_USE_STRUCT LDKPeerManager { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePeerManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPeerManager; + + + +/** + * Static channel fields used to build transactions given per-commitment fields, organized by + * broadcaster/countersignatory. + * + * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the + * as_holder_broadcastable and as_counterparty_broadcastable functions. + */ +typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDirectedChannelTransactionParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDirectedChannelTransactionParameters; + + + +/** + * A simple newtype for RwLockReadGuard<'a, NetworkGraph>. + * This exists only to make accessing a RwLock possible from + * the C bindings, as it can be done directly in Rust code. + */ +typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLockedNetworkGraph *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLockedNetworkGraph; + + + +/** + * Receives and validates network updates from peers, + * stores authentic and relevant data as a network graph. + * This network graph is then used for routing payments. + * Provides interface to help with initial routing sync by + * serving historical announcements. + */ +typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeNetGraphMsgHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKNetGraphMsgHandler; + + + +/** + * FilesystemPersister persists channel data on disk, where each channel's + * data is stored in a file named after its funding outpoint. + * + * Warning: this module does the best it can with calls to persist data, but it + * can only guarantee that the data is passed to the drive. It is up to the + * drive manufacturers to do the actual persistence properly, which they often + * don't (especially on consumer-grade hardware). Therefore, it is up to the + * user to validate their entire storage stack, to ensure the writes are + * persistent. + * Corollary: especially when dealing with larger amounts of money, it is best + * practice to have multiple channel data backups and not rely only on one + * FilesystemPersister. + */ +typedef struct MUST_USE_STRUCT LDKFilesystemPersister { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFilesystemPersister *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKFilesystemPersister; + + + +/** + * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be + * invalid. + * + * # Invariants + * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`. + */ +typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeSignedRawInvoice *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKSignedRawInvoice; + + + +/** + * Data of the `RawInvoice` that is encoded in the data part + */ +typedef struct MUST_USE_STRUCT LDKRawDataPart { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRawDataPart *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRawDataPart; + +extern const uintptr_t MAX_BUF_SIZE; + +extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; + +extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; + +extern const uint16_t BREAKDOWN_TIMEOUT; + +extern const uint16_t MIN_CLTV_EXPIRY_DELTA; + +extern const uint32_t MIN_FINAL_CLTV_EXPIRY; + +extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; + +extern const uint8_t TAG_PAYMENT_HASH; + +extern const uint8_t TAG_DESCRIPTION; + +extern const uint8_t TAG_PAYEE_PUB_KEY; + +extern const uint8_t TAG_DESCRIPTION_HASH; + +extern const uint8_t TAG_EXPIRY_TIME; + +extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY; + +extern const uint8_t TAG_FALLBACK; + +extern const uint8_t TAG_ROUTE; + +extern const uint8_t TAG_PAYMENT_SECRET; + +extern const uint8_t TAG_FEATURES; + +/** + * Frees the data buffer, if data_is_owned is set and datalen > 0. + */ +void Transaction_free(struct LDKTransaction _res); + +/** + * Frees the data pointed to by script_pubkey. + */ +void TxOut_free(struct LDKTxOut _res); + +/** + * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + */ +struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); + +/** + * Frees the data buffer, if chars_is_owned is set and len > 0. + */ +void Str_free(struct LDKStr _res); + +/** + * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); + +/** + * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. + */ +void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OutPointDecodeErrorZ in the success state. + */ +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); + +/** + * Creates a new CResult_OutPointDecodeErrorZ in the error state. + */ +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_OutPointDecodeErrorZ. + */ +void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); + +/** + * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SecretKeyErrorZ in the success state. + */ +struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey o); + +/** + * Creates a new CResult_SecretKeyErrorZ in the error state. + */ +struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Frees any resources used by the CResult_SecretKeyErrorZ. + */ +void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res); + +/** + * Creates a new CResult_PublicKeyErrorZ in the success state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeyErrorZ in the error state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Frees any resources used by the CResult_PublicKeyErrorZ. + */ +void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); + +/** + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. + */ +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); + +/** + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. + */ +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. + */ +void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); + +/** + * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. + */ +void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TxCreationKeysErrorZ in the success state. + */ +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LDKTxCreationKeys o); + +/** + * Creates a new CResult_TxCreationKeysErrorZ in the error state. + */ +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Frees any resources used by the CResult_TxCreationKeysErrorZ. + */ +void CResult_TxCreationKeysErrorZ_free(struct LDKCResult_TxCreationKeysErrorZ _res); + +/** + * Constructs a new COption_u32Z containing a u32 + */ +struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); + +/** + * Constructs a new COption_u32Z containing nothing + */ +struct LDKCOption_u32Z COption_u32Z_none(void); + +/** + * Frees any resources associated with the u32, if we are in the Some state + */ +void COption_u32Z_free(struct LDKCOption_u32Z _res); + +/** + * Creates a new COption_u32Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. + */ +void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. + */ +void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. + */ +void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. + */ +void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. + */ +void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. + */ +void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + */ +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); + +/** + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + */ +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); + +/** + * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. + */ +void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ in the success state. + */ +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ in the error state. + */ +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); + +/** + * Frees any resources used by the CResult_CVec_SignatureZNoneZ. + */ +void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); + +/** + * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RawTaggedFieldZ_free(struct LDKCVec_RawTaggedFieldZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u5Z_free(struct LDKCVec_u5Z _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u8Z_free(struct LDKCVec_u8Z _res); + +/** + * Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. + */ +struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(struct LDKRawInvoice a, struct LDKThirtyTwoBytes b, struct LDKInvoiceSignature c); + +/** + * Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. + */ +void C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res); + +/** + * Creates a new CResult_PayeePubKeyErrorZ in the success state. + */ +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); + +/** + * Creates a new CResult_PayeePubKeyErrorZ in the error state. + */ +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Frees any resources used by the CResult_PayeePubKeyErrorZ. + */ +void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); + +/** + * Constructs a new COption_u64Z containing a u64 + */ +struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); + +/** + * Constructs a new COption_u64Z containing nothing + */ +struct LDKCOption_u64Z COption_u64Z_none(void); + +/** + * Frees any resources associated with the u64, if we are in the Some state + */ +void COption_u64Z_free(struct LDKCOption_u64Z _res); + +/** + * Creates a new COption_u64Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); + +/** + * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. + */ +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); + +/** + * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. + */ +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); + +/** + * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. + */ +void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); + +/** + * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneSemanticErrorZ in the success state. + */ +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); + +/** + * Creates a new CResult_NoneSemanticErrorZ in the error state. + */ +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); + +/** + * Frees any resources used by the CResult_NoneSemanticErrorZ. + */ +void CResult_NoneSemanticErrorZ_free(struct LDKCResult_NoneSemanticErrorZ _res); + +/** + * Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_clone(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InvoiceSemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct LDKInvoice o); + +/** + * Creates a new CResult_InvoiceSemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); + +/** + * Frees any resources used by the CResult_InvoiceSemanticErrorZ. + */ +void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ _res); + +/** + * Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_clone(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_DescriptionCreationErrorZ in the success state. + */ +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); + +/** + * Creates a new CResult_DescriptionCreationErrorZ in the error state. + */ +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); + +/** + * Frees any resources used by the CResult_DescriptionCreationErrorZ. + */ +void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); + +/** + * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ExpiryTimeCreationErrorZ in the success state. + */ +struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_ok(struct LDKExpiryTime o); + +/** + * Creates a new CResult_ExpiryTimeCreationErrorZ in the error state. + */ +struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_err(enum LDKCreationError e); + +/** + * Frees any resources used by the CResult_ExpiryTimeCreationErrorZ. + */ +void CResult_ExpiryTimeCreationErrorZ_free(struct LDKCResult_ExpiryTimeCreationErrorZ _res); + +/** + * Creates a new CResult_ExpiryTimeCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_clone(const struct LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); + +/** + * Creates a new CResult_RouteHintCreationErrorZ in the success state. + */ +struct LDKCResult_RouteHintCreationErrorZ CResult_RouteHintCreationErrorZ_ok(struct LDKRouteHint o); + +/** + * Creates a new CResult_RouteHintCreationErrorZ in the error state. + */ +struct LDKCResult_RouteHintCreationErrorZ CResult_RouteHintCreationErrorZ_err(enum LDKCreationError e); + +/** + * Frees any resources used by the CResult_RouteHintCreationErrorZ. + */ +void CResult_RouteHintCreationErrorZ_free(struct LDKCResult_RouteHintCreationErrorZ _res); + +/** + * Creates a new CResult_RouteHintCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHintCreationErrorZ CResult_RouteHintCreationErrorZ_clone(const struct LDKCResult_RouteHintCreationErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_StringErrorZ in the success state. + */ +struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKCVec_u8Z o); + +/** + * Creates a new CResult_StringErrorZ in the error state. + */ +struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Frees any resources used by the CResult_StringErrorZ. + */ +void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); + +/** + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_ok(struct LDKChannelMonitorUpdate o); + +/** + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. + */ +void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); + +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. + */ +void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * FilesystemPersister persists channel data on disk, where each channel's - * data is stored in a file named after its funding outpoint. - * - * Warning: this module does the best it can with calls to persist data, but it - * can only guarantee that the data is passed to the drive. It is up to the - * drive manufacturers to do the actual persistence properly, which they often - * don't (especially on consumer-grade hardware). Therefore, it is up to the - * user to validate their entire storage stack, to ensure the writes are - * persistent. - * Corollary: especially when dealing with larger amounts of money, it is best - * practice to have multiple channel data backups and not rely only on one - * FilesystemPersister. + * Creates a new CResult_NoneMonitorUpdateErrorZ in the success state. */ -typedef struct MUST_USE_STRUCT LDKFilesystemPersister { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeFilesystemPersister *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKFilesystemPersister; +struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void); -extern const uintptr_t MAX_BUF_SIZE; +/** + * Creates a new CResult_NoneMonitorUpdateErrorZ in the error state. + */ +struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_err(struct LDKMonitorUpdateError e); -extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; +/** + * Frees any resources used by the CResult_NoneMonitorUpdateErrorZ. + */ +void CResult_NoneMonitorUpdateErrorZ_free(struct LDKCResult_NoneMonitorUpdateErrorZ _res); -extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; +/** + * Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_clone(const struct LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR orig); -extern const uint16_t BREAKDOWN_TIMEOUT; +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const struct LDKC2Tuple_OutPointScriptZ *NONNULL_PTR orig); -extern const uint16_t MIN_CLTV_EXPIRY_DELTA; +/** + * Creates a new C2Tuple_OutPointScriptZ from the contained elements. + */ +struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, struct LDKCVec_u8Z b); -extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; +/** + * Frees any resources used by the C2Tuple_OutPointScriptZ. + */ +void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); /** - * Frees the data buffer, if data_is_owned is set and datalen > 0. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void Transaction_free(struct LDKTransaction _res); +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); /** - * Frees the data pointed to by script_pubkey. + * Creates a new C2Tuple_u32ScriptZ from the contained elements. */ -void TxOut_free(struct LDKTxOut _res); +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); /** - * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + * Frees any resources used by the C2Tuple_u32ScriptZ. */ -struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); +void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); +void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. + * Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); /** - * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. + * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. */ -void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); +void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); +void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); /** - * Creates a new CResult_OutPointDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); +void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); /** - * Creates a new CResult_OutPointDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_EventZ_free(struct LDKCVec_EventZ _res); /** - * Frees any resources used by the CResult_OutPointDecodeErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); +void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); /** - * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new C2Tuple_usizeTransactionZ from the contained elements. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); +struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); /** - * Creates a new CResult_SecretKeyErrorZ in the success state. + * Frees any resources used by the C2Tuple_usizeTransactionZ. */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey o); +void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); /** - * Creates a new CResult_SecretKeyErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e); +void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); /** - * Frees any resources used by the CResult_SecretKeyErrorZ. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res); +struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); /** - * Creates a new CResult_PublicKeyErrorZ in the success state. + * Creates a new C2Tuple_u32TxOutZ from the contained elements. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); +struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); /** - * Creates a new CResult_PublicKeyErrorZ in the error state. + * Frees any resources used by the C2Tuple_u32TxOutZ. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); +void C2Tuple_u32TxOutZ_free(struct LDKC2Tuple_u32TxOutZ _res); /** - * Frees any resources used by the CResult_PublicKeyErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); +void CVec_C2Tuple_u32TxOutZZ_free(struct LDKCVec_C2Tuple_u32TxOutZZ _res); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. + * Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32TxOutZZ b); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. + * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); +void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res); /** - * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); +void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); +void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); /** - * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. + * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. */ -void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); +void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxCreationKeysErrorZ in the success state. + * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LDKTxCreationKeys o); +struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); /** - * Creates a new CResult_TxCreationKeysErrorZ in the error state. + * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); +void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); /** - * Frees any resources used by the CResult_TxCreationKeysErrorZ. + * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. */ -void CResult_TxCreationKeysErrorZ_free(struct LDKCResult_TxCreationKeysErrorZ _res); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); /** - * Constructs a new COption_u32Z containing a u32 + * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. */ -struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_u32Z containing nothing + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. */ -struct LDKCOption_u32Z COption_u32Z_none(void); +void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); /** - * Frees any resources associated with the u32, if we are in the Some state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void COption_u32Z_free(struct LDKCOption_u32Z _res); +void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); /** - * Creates a new COption_u32Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); +void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + * Creates a new CResult_RouteDecodeErrorZ in the success state. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + * Creates a new CResult_RouteDecodeErrorZ in the error state. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. + * Frees any resources used by the CResult_RouteDecodeErrorZ. */ -void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); +void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); +void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + * Creates a new CResult_RouteLightningErrorZ in the success state. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); /** - * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. + * Creates a new CResult_RouteLightningErrorZ in the error state. */ -void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * Frees any resources used by the CResult_RouteLightningErrorZ. + */ +void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); +void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + * Creates a new CResult_boolLightningErrorZ in the success state. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); /** - * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. + * Creates a new CResult_boolLightningErrorZ in the error state. */ -void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_boolLightningErrorZ. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); /** - * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. + * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. */ -void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); +void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); +void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult_NoneLightningErrorZ in the success state. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); /** - * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. + * Creates a new CResult_NoneLightningErrorZ in the error state. */ -void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_NoneLightningErrorZ. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); /** - * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. */ -void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); +void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. + * Creates a new CResult_NonePeerHandleErrorZ in the success state. */ -void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); /** - * Creates a new CResult_CVec_SignatureZNoneZ in the success state. + * Creates a new CResult_NonePeerHandleErrorZ in the error state. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); /** - * Creates a new CResult_CVec_SignatureZNoneZ in the error state. + * Frees any resources used by the CResult_NonePeerHandleErrorZ. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); +void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); /** - * Frees any resources used by the CResult_CVec_SignatureZNoneZ. + * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_boolPeerHandleErrorZ in the success state. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); /** - * Creates a new CResult_StringErrorZ in the success state. + * Creates a new CResult_boolPeerHandleErrorZ in the error state. */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKCVec_u8Z o); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** - * Creates a new CResult_StringErrorZ in the error state. + * Frees any resources used by the CResult_boolPeerHandleErrorZ. */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); +void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); /** - * Frees any resources used by the CResult_StringErrorZ. + * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. + * Creates a new CResult_TxOutAccessErrorZ in the success state. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_ok(struct LDKChannelMonitorUpdate o); +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. + * Creates a new CResult_TxOutAccessErrorZ in the error state. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); /** - * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. + * Frees any resources used by the CResult_TxOutAccessErrorZ. */ -void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res); +void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. + * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); /** - * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. + * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state */ -void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); +void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); +void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); /** - * Creates a new CResult_NoneMonitorUpdateErrorZ in the success state. + * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. */ -struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void); +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); /** - * Creates a new CResult_NoneMonitorUpdateErrorZ in the error state. + * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. */ -struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_err(struct LDKMonitorUpdateError e); +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NoneMonitorUpdateErrorZ. + * Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. */ -void CResult_NoneMonitorUpdateErrorZ_free(struct LDKCResult_NoneMonitorUpdateErrorZ _res); +void CResult_DirectionalChannelInfoDecodeErrorZ_free(struct LDKCResult_DirectionalChannelInfoDecodeErrorZ _res); /** - * Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig` + * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_clone(const struct LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR orig); +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_clone(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_OutPointScriptZ from the contained elements. + * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. */ -struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, struct LDKCVec_u8Z b); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); /** - * Frees any resources used by the C2Tuple_OutPointScriptZ. + * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. */ -void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new C2Tuple_u32ScriptZ from the contained elements. + * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. */ -struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); +void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); /** - * Frees any resources used by the C2Tuple_u32ScriptZ. + * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. */ -void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); /** - * Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. + * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. + * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. */ -void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); +void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); +void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. */ -void CVec_EventZ_free(struct LDKCVec_EventZ _res); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. */ -void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); +void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); /** - * Frees any resources used by the C2Tuple_usizeTransactionZ. + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); +void CVec_u64Z_free(struct LDKCVec_u64Z _res); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. */ -struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); /** - * Creates a new C2Tuple_u32TxOutZ from the contained elements. + * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. */ -struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the C2Tuple_u32TxOutZ. + * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. */ -void C2Tuple_u32TxOutZ_free(struct LDKC2Tuple_u32TxOutZ _res); +void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_C2Tuple_u32TxOutZZ_free(struct LDKCVec_C2Tuple_u32TxOutZZ _res); +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. + * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32TxOutZZ b); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); /** - * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. + * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. */ -void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. */ -void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); +void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. + * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. + * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. + * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. + */ +void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. */ -void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. + * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. */ -struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); +void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); /** - * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. */ -void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); /** - * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. + * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. */ -void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. */ -void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); +struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. */ -void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); +void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); /** - * Creates a new CResult_RouteDecodeErrorZ in the success state. + * Creates a new CResult_NetAddressu8Z in the success state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); +struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_ok(struct LDKNetAddress o); /** - * Creates a new CResult_RouteDecodeErrorZ in the error state. + * Creates a new CResult_NetAddressu8Z in the error state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_err(uint8_t e); /** - * Frees any resources used by the CResult_RouteDecodeErrorZ. + * Frees any resources used by the CResult_NetAddressu8Z. */ -void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); +void CResult_NetAddressu8Z_free(struct LDKCResult_NetAddressu8Z _res); /** - * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NetAddressu8Z which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const struct LDKCResult_NetAddressu8Z *NONNULL_PTR orig); /** - * Constructs a new COption_u64Z containing a u64 + * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the success state. */ -struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); +struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(struct LDKCResult_NetAddressu8Z o); /** - * Constructs a new COption_u64Z containing nothing + * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the error state. */ -struct LDKCOption_u64Z COption_u64Z_none(void); +struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the u64, if we are in the Some state + * Frees any resources used by the CResult_CResult_NetAddressu8ZDecodeErrorZ. */ -void COption_u64Z_free(struct LDKCOption_u64Z _res); +void CResult_CResult_NetAddressu8ZDecodeErrorZ_free(struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res); /** - * Creates a new COption_u64Z which has the same data as `orig` + * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); +struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(const struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); +void CVec_UpdateAddHTLCZ_free(struct LDKCVec_UpdateAddHTLCZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); +void CVec_UpdateFulfillHTLCZ_free(struct LDKCVec_UpdateFulfillHTLCZ _res); /** - * Creates a new CResult_RouteLightningErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); +void CVec_UpdateFailHTLCZ_free(struct LDKCVec_UpdateFailHTLCZ _res); /** - * Creates a new CResult_RouteLightningErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); +void CVec_UpdateFailMalformedHTLCZ_free(struct LDKCVec_UpdateFailMalformedHTLCZ _res); /** - * Frees any resources used by the CResult_RouteLightningErrorZ. + * Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. */ -void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok(struct LDKAcceptChannel o); /** - * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. */ -void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); +void CResult_AcceptChannelDecodeErrorZ_free(struct LDKCResult_AcceptChannelDecodeErrorZ _res); /** - * Creates a new CResult_boolLightningErrorZ in the success state. + * Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_clone(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_boolLightningErrorZ in the error state. + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_ok(struct LDKAnnouncementSignatures o); /** - * Frees any resources used by the CResult_boolLightningErrorZ. + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. */ -void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); +void CResult_AnnouncementSignaturesDecodeErrorZ_free(struct LDKCResult_AnnouncementSignaturesDecodeErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_clone(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. + * Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_ok(struct LDKChannelReestablish o); /** - * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. + * Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. */ -void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. */ -void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); +void CResult_ChannelReestablishDecodeErrorZ_free(struct LDKCResult_ChannelReestablishDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_clone(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneLightningErrorZ in the success state. + * Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok(struct LDKClosingSigned o); /** - * Creates a new CResult_NoneLightningErrorZ in the error state. + * Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NoneLightningErrorZ. + * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. */ -void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); +void CResult_ClosingSignedDecodeErrorZ_free(struct LDKCResult_ClosingSignedDecodeErrorZ _res); /** - * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` + * Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. */ -void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_ok(struct LDKCommitmentSigned o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. + * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); +void CResult_CommitmentSignedDecodeErrorZ_free(struct LDKCResult_CommitmentSignedDecodeErrorZ _res); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. + * Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. + * Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. */ -void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ok(struct LDKFundingCreated o); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` + * Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. + */ +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. + */ +void CResult_FundingCreatedDecodeErrorZ_free(struct LDKCResult_FundingCreatedDecodeErrorZ _res); + +/** + * Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_clone(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NonePeerHandleErrorZ in the success state. + * Creates a new CResult_FundingSignedDecodeErrorZ in the success state. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok(struct LDKFundingSigned o); /** - * Creates a new CResult_NonePeerHandleErrorZ in the error state. + * Creates a new CResult_FundingSignedDecodeErrorZ in the error state. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NonePeerHandleErrorZ. + * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. */ -void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); +void CResult_FundingSignedDecodeErrorZ_free(struct LDKCResult_FundingSignedDecodeErrorZ _res); /** - * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` + * Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_clone(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_boolPeerHandleErrorZ in the success state. + * Creates a new CResult_FundingLockedDecodeErrorZ in the success state. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); +struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_ok(struct LDKFundingLocked o); /** - * Creates a new CResult_boolPeerHandleErrorZ in the error state. + * Creates a new CResult_FundingLockedDecodeErrorZ in the error state. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_boolPeerHandleErrorZ. + * Frees any resources used by the CResult_FundingLockedDecodeErrorZ. */ -void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); +void CResult_FundingLockedDecodeErrorZ_free(struct LDKCResult_FundingLockedDecodeErrorZ _res); /** - * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` + * Creates a new CResult_FundingLockedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); +struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_clone(const struct LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxOutAccessErrorZ in the success state. + * Creates a new CResult_InitDecodeErrorZ in the success state. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o); /** - * Creates a new CResult_TxOutAccessErrorZ in the error state. + * Creates a new CResult_InitDecodeErrorZ in the error state. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_TxOutAccessErrorZ. + * Frees any resources used by the CResult_InitDecodeErrorZ. */ -void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); +void CResult_InitDecodeErrorZ_free(struct LDKCResult_InitDecodeErrorZ _res); /** - * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` + * Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_clone(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ + * Creates a new CResult_OpenChannelDecodeErrorZ in the success state. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(struct LDKOpenChannel o); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing + * Creates a new CResult_OpenChannelDecodeErrorZ in the error state. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state + * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. */ -void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); +void CResult_OpenChannelDecodeErrorZ_free(struct LDKCResult_OpenChannelDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_clone(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. + * Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(struct LDKRevokeAndACK o); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. + * Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. + * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. */ -void CResult_DirectionalChannelInfoDecodeErrorZ_free(struct LDKCResult_DirectionalChannelInfoDecodeErrorZ _res); +void CResult_RevokeAndACKDecodeErrorZ_free(struct LDKCResult_RevokeAndACKDecodeErrorZ _res); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_clone(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_clone(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. + * Creates a new CResult_ShutdownDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LDKShutdown o); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. + * Creates a new CResult_ShutdownDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. + * Frees any resources used by the CResult_ShutdownDecodeErrorZ. */ -void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); +void CResult_ShutdownDecodeErrorZ_free(struct LDKCResult_ShutdownDecodeErrorZ _res); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_clone(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ok(struct LDKUpdateFailHTLC o); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. + * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. */ -void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); +void CResult_UpdateFailHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailHTLCDecodeErrorZ _res); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(struct LDKUpdateFailMalformedHTLC o); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. + * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. */ -void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); +void CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_u64Z_free(struct LDKCVec_u64Z _res); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct LDKUpdateFee o); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. + * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. */ -void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); +void CResult_UpdateFeeDecodeErrorZ_free(struct LDKCResult_UpdateFeeDecodeErrorZ _res); /** - * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_clone(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_ok(struct LDKUpdateFulfillHTLC o); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. + * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. */ -void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); +void CResult_UpdateFulfillHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok(struct LDKUpdateAddHTLC o); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. */ -void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); +void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecodeErrorZ _res); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_PingDecodeErrorZ in the success state. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o); /** - * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + * Creates a new CResult_PingDecodeErrorZ in the error state. */ -void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + * Frees any resources used by the CResult_PingDecodeErrorZ. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); +void CResult_PingDecodeErrorZ_free(struct LDKCResult_PingDecodeErrorZ _res); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_clone(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + * Creates a new CResult_PongDecodeErrorZ in the success state. */ -void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_PongDecodeErrorZ in the error state. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. + * Frees any resources used by the CResult_PongDecodeErrorZ. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_PongDecodeErrorZ_free(struct LDKCResult_PongDecodeErrorZ _res); /** - * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. + * Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_clone(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NetAddressu8Z in the success state. + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_ok(struct LDKNetAddress o); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(struct LDKUnsignedChannelAnnouncement o); /** - * Creates a new CResult_NetAddressu8Z in the error state. + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_err(uint8_t e); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NetAddressu8Z. + * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. */ -void CResult_NetAddressu8Z_free(struct LDKCResult_NetAddressu8Z _res); +void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_NetAddressu8Z which has the same data as `orig` + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const struct LDKCResult_NetAddressu8Z *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the success state. + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(struct LDKCResult_NetAddressu8Z o); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); /** - * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ in the error state. + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_CResult_NetAddressu8ZDecodeErrorZ. + * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. */ -void CResult_CResult_NetAddressu8ZDecodeErrorZ_free(struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res); +void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(const struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. */ -void CVec_UpdateAddHTLCZ_free(struct LDKCVec_UpdateAddHTLCZ _res); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. */ -void CVec_UpdateFulfillHTLCZ_free(struct LDKCVec_UpdateFulfillHTLCZ _res); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. */ -void CVec_UpdateFailHTLCZ_free(struct LDKCVec_UpdateFailHTLCZ _res); +void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_UpdateFailMalformedHTLCZ_free(struct LDKCVec_UpdateFailMalformedHTLCZ _res); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok(struct LDKAcceptChannel o); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. + * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. */ -void CResult_AcceptChannelDecodeErrorZ_free(struct LDKCResult_AcceptChannelDecodeErrorZ _res); +void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_clone(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. + * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_ok(struct LDKAnnouncementSignatures o); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. + * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. + * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. */ -void CResult_AnnouncementSignaturesDecodeErrorZ_free(struct LDKCResult_AnnouncementSignaturesDecodeErrorZ _res); +void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_clone(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_ok(struct LDKChannelReestablish o); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. + * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. */ -void CResult_ChannelReestablishDecodeErrorZ_free(struct LDKCResult_ChannelReestablishDecodeErrorZ _res); +void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_clone(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok(struct LDKClosingSigned o); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. + * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. */ -void CResult_ClosingSignedDecodeErrorZ_free(struct LDKCResult_ClosingSignedDecodeErrorZ _res); +void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_ok(struct LDKCommitmentSigned o); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. + * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. */ -void CResult_CommitmentSignedDecodeErrorZ_free(struct LDKCResult_CommitmentSignedDecodeErrorZ _res); +void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ok(struct LDKFundingCreated o); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. + * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. */ -void CResult_FundingCreatedDecodeErrorZ_free(struct LDKCResult_FundingCreatedDecodeErrorZ _res); +void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_clone(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_FundingSignedDecodeErrorZ in the success state. + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok(struct LDKFundingSigned o); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); /** - * Creates a new CResult_FundingSignedDecodeErrorZ in the error state. + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. + * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. */ -void CResult_FundingSignedDecodeErrorZ_free(struct LDKCResult_FundingSignedDecodeErrorZ _res); +void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); /** - * Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_clone(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_FundingLockedDecodeErrorZ in the success state. + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. */ -struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_ok(struct LDKFundingLocked o); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); /** - * Creates a new CResult_FundingLockedDecodeErrorZ in the error state. + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. */ -struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_FundingLockedDecodeErrorZ. + * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. */ -void CResult_FundingLockedDecodeErrorZ_free(struct LDKCResult_FundingLockedDecodeErrorZ _res); +void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); /** - * Creates a new CResult_FundingLockedDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_clone(const struct LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InitDecodeErrorZ in the success state. + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); /** - * Creates a new CResult_InitDecodeErrorZ in the error state. + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_InitDecodeErrorZ. + * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. */ -void CResult_InitDecodeErrorZ_free(struct LDKCResult_InitDecodeErrorZ _res); +void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); /** - * Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_clone(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_OpenChannelDecodeErrorZ in the success state. + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(struct LDKOpenChannel o); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); /** - * Creates a new CResult_OpenChannelDecodeErrorZ in the error state. + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. + * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. */ -void CResult_OpenChannelDecodeErrorZ_free(struct LDKCResult_OpenChannelDecodeErrorZ _res); +void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); /** - * Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_clone(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. - */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(struct LDKRevokeAndACK o); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. + * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. */ -void CResult_RevokeAndACKDecodeErrorZ_free(struct LDKCResult_RevokeAndACKDecodeErrorZ _res); +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_clone(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR orig); +void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); /** - * Creates a new CResult_ShutdownDecodeErrorZ in the success state. + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LDKShutdown o); +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); /** - * Creates a new CResult_ShutdownDecodeErrorZ in the error state. + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); /** - * Frees any resources used by the CResult_ShutdownDecodeErrorZ. + * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. */ -void CResult_ShutdownDecodeErrorZ_free(struct LDKCResult_ShutdownDecodeErrorZ _res); +void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); /** - * Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_clone(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. + * Creates a new CResult_SignatureNoneZ in the success state. */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ok(struct LDKUpdateFailHTLC o); +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. + * Creates a new CResult_SignatureNoneZ in the error state. */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); /** - * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. + * Frees any resources used by the CResult_SignatureNoneZ. */ -void CResult_UpdateFailHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailHTLCDecodeErrorZ _res); +void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_SignatureNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. + * Creates a new CResult_SignDecodeErrorZ in the success state. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(struct LDKUpdateFailMalformedHTLC o); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. + * Creates a new CResult_SignDecodeErrorZ in the error state. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. + * Frees any resources used by the CResult_SignDecodeErrorZ. */ -void CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res); +void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct LDKUpdateFee o); +void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); /** - * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. */ -void CResult_UpdateFeeDecodeErrorZ_free(struct LDKCResult_UpdateFeeDecodeErrorZ _res); +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_clone(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR orig); +void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. + * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_ok(struct LDKUpdateFulfillHTLC o); +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. + * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); /** - * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. + * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. */ -void CResult_UpdateFulfillHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR orig); +void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. + * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok(struct LDKUpdateAddHTLC o); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); /** - * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. + * Creates a new CResult_TransactionNoneZ in the success state. */ -void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecodeErrorZ _res); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_TransactionNoneZ in the error state. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); /** - * Creates a new CResult_PingDecodeErrorZ in the success state. + * Frees any resources used by the CResult_TransactionNoneZ. */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o); +void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); /** - * Creates a new CResult_PingDecodeErrorZ in the error state. + * Creates a new CResult_NoneErrorZ in the success state. */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); /** - * Frees any resources used by the CResult_PingDecodeErrorZ. + * Creates a new CResult_NoneErrorZ in the error state. */ -void CResult_PingDecodeErrorZ_free(struct LDKCResult_PingDecodeErrorZ _res); +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); /** - * Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_NoneErrorZ. */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_clone(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR orig); +void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); /** - * Creates a new CResult_PongDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o); +void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); /** - * Creates a new CResult_PongDecodeErrorZ in the error state. + * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); /** - * Frees any resources used by the CResult_PongDecodeErrorZ. + * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. */ -void CResult_PongDecodeErrorZ_free(struct LDKCResult_PongDecodeErrorZ _res); +struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); /** - * Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_clone(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR orig); +void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. + * Creates a new CResult_NoneAPIErrorZ in the success state. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(struct LDKUnsignedChannelAnnouncement o); +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. + * Creates a new CResult_NoneAPIErrorZ in the error state. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); /** - * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. + * Frees any resources used by the CResult_NoneAPIErrorZ. */ -void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); +void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); +void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); /** - * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. + * Creates a new CResult_NonePaymentSendFailureZ in the success state. */ -void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NonePaymentSendFailureZ in the error state. */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. + * Frees any resources used by the CResult_NonePaymentSendFailureZ. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); +void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. + * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. + * Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. */ -void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); +struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); +void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. + * Creates a new CResult_PaymentSecretAPIErrorZ in the success state. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); +struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. + * Creates a new CResult_PaymentSecretAPIErrorZ in the error state. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_err(struct LDKAPIError e); /** - * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. + * Frees any resources used by the CResult_PaymentSecretAPIErrorZ. */ -void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); +void CResult_PaymentSecretAPIErrorZ_free(struct LDKCResult_PaymentSecretAPIErrorZ _res); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); +void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. + * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); +struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. + * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); +void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); /** - * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. */ -void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); +void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. + * Frees any resources used by the Event */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +void Event_free(struct LDKEvent this_ptr); /** - * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. + * Creates a copy of the Event */ -void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); +struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Serialize the Event object into a byte array which can be read by Event_read */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); +struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. + * Frees any resources used by the MessageSendEvent */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. + * Creates a copy of the MessageSendEvent */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. + * Calls the free function if one is set */ -void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); +void EventsProvider_free(struct LDKEventsProvider this_ptr); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. + * Frees any resources used by the APIError */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); +void APIError_free(struct LDKAPIError this_ptr); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. + * Creates a copy of the APIError */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. + * Creates a digital signature of a message given a SecretKey, like the node's secret. + * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. + * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. */ -void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); +struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, struct LDKSecretKey sk); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Recovers the PublicKey of the signer of the message given the message and the signature. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. + * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, + * and the PublicKey. */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); +bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. + * Creates a copy of the Level */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. + * Returns the most verbose logging level. */ -void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); +MUST_USE_RES enum LDKLevel Level_max(void); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); +void Logger_free(struct LDKLogger this_ptr); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. + * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); +void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * Default value: 6. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * Default value: 6. */ -void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); +void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); +uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); +void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. */ -void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); +void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new ChannelHandshakeConfig given each field */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. + * Creates a copy of the ChannelHandshakeConfig */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); +struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. + * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); /** - * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. + * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. */ -void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); +void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 0. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); +uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 0. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); +void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows + * you to limit the maximum minimum-size they can require. + * + * Default value: u64::max_value. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows + * you to limit the maximum minimum-size they can require. + * + * Default value: u64::max_value. */ -void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); +void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The remote node sets a limit on the maximum value of pending HTLCs to them at any given + * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); +uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The remote node sets a limit on the maximum value of pending HTLCs to them at any given + * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + * The remote node will require we keep a certain amount in direct payment to ourselves at all + * time, ensuring that we are able to be punished if we broadcast an old state. This allows to + * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). + * + * Default value: u64::max_value. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); +uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + * The remote node will require we keep a certain amount in direct payment to ourselves at all + * time, ensuring that we are able to be punished if we broadcast an old state. This allows to + * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). + * + * Default value: u64::max_value. */ -void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); +void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + * The remote node sets a limit on the maximum number of pending HTLCs to them at any given + * time. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); +uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + * The remote node sets a limit on the maximum number of pending HTLCs to them at any given + * time. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); +void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + * Outputs below a certain value will not be added to on-chain transactions. The dust value is + * required to always be higher than this value so this only applies to HTLC outputs (and + * potentially to-self outputs before any payments have been made). + * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. + * This setting allows you to set a minimum dust limit for their commitment transactions, + * reflecting the reality that tiny outputs are not considered standard transactions and will + * not propagate through the Bitcoin network. + * + * Default value: 546, the current dust limit on the Bitcoin network. */ -void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); +uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Outputs below a certain value will not be added to on-chain transactions. The dust value is + * required to always be higher than this value so this only applies to HTLC outputs (and + * potentially to-self outputs before any payments have been made). + * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. + * This setting allows you to set a minimum dust limit for their commitment transactions, + * reflecting the reality that tiny outputs are not considered standard transactions and will + * not propagate through the Bitcoin network. + * + * Default value: 546, the current dust limit on the Bitcoin network. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_min_dust_limit_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_SignatureNoneZ in the success state. + * Maximum allowed threshold above which outputs will not be generated in their commitment + * transactions. + * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. + * + * Default value: u64::max_value. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); +uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SignatureNoneZ in the error state. + * Maximum allowed threshold above which outputs will not be generated in their commitment + * transactions. + * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. + * + * Default value: u64::max_value. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); +void ChannelHandshakeLimits_set_max_dust_limit_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the CResult_SignatureNoneZ. + * Before a channel is usable the funding transaction will need to be confirmed by at least a + * certain number of blocks, specified by the node which is not the funder (as the funder can + * assume they aren't going to double-spend themselves). + * This config allows you to set a limit on the maximum amount of time to wait. + * + * Default value: 144, or roughly one day and only applies to outbound channels. */ -void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); +uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SignatureNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Before a channel is usable the funding transaction will need to be confirmed by at least a + * certain number of blocks, specified by the node which is not the funder (as the funder can + * assume they aren't going to double-spend themselves). + * This config allows you to set a limit on the maximum amount of time to wait. + * + * Default value: 144, or roughly one day and only applies to outbound channels. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_SignDecodeErrorZ in the success state. + * Set to force the incoming channel to match our announced channel preference in + * ChannelConfig. + * + * Default value: true, to make the default that no announced channels are possible (which is + * appropriate for any nodes which are not online very reliably). */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); +bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SignDecodeErrorZ in the error state. + * Set to force the incoming channel to match our announced channel preference in + * ChannelConfig. + * + * Default value: true, to make the default that no announced channels are possible (which is + * appropriate for any nodes which are not online very reliably). */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CResult_SignDecodeErrorZ. + * Set to the amount of time we're willing to wait to claim money back to us. + * + * Not checking this value would be a security issue, as our peer would be able to set it to + * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. + * + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ -void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); +uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SignDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to the amount of time we're willing to wait to claim money back to us. + * + * Not checking this value would be a security issue, as our peer would be able to set it to + * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. + * + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ -struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new ChannelHandshakeLimits given each field */ -void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. + * Creates a copy of the ChannelHandshakeLimits */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); +struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. + * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); /** - * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. + * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. */ -void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); +void ChannelConfig_free(struct LDKChannelConfig this_obj); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * Default value: 0. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); +uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. + * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * Default value: 0. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); +void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); +uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ -void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); +void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set. + * + * This cannot be changed after the initial channel handshake. + * + * Default value: false. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); +bool ChannelConfig_get_announced_channel(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set. + * + * This cannot be changed after the initial channel handshake. + * + * Default value: false. */ -void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); +void ChannelConfig_set_announced_channel(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_TransactionNoneZ in the success state. + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * This cannot be changed after a channel has been initialized. + * + * Default value: true. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); +bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_TransactionNoneZ in the error state. + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * This cannot be changed after a channel has been initialized. + * + * Default value: true. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); +void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CResult_TransactionNoneZ. + * Constructs a new ChannelConfig given each field */ -void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); /** - * Creates a new CResult_NoneErrorZ in the success state. + * Creates a copy of the ChannelConfig */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); +struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); /** - * Creates a new CResult_NoneErrorZ in the error state. + * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); /** - * Frees any resources used by the CResult_NoneErrorZ. + * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read */ -void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); +struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Read a ChannelConfig from a byte array, created by ChannelConfig_write */ -void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); +struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); /** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. + * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); +void UserConfig_free(struct LDKUserConfig this_obj); /** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. + * Channel config that we propose to our counterparty. */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); +struct LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. + * Channel config that we propose to our counterparty. */ -void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); +void UserConfig_set_own_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val); /** - * Creates a new CResult_NoneAPIErrorZ in the success state. + * Limits applied to our counterparty's proposed channel config settings. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); +struct LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NoneAPIErrorZ in the error state. + * Limits applied to our counterparty's proposed channel config settings. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); +void UserConfig_set_peer_channel_config_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val); /** - * Frees any resources used by the CResult_NoneAPIErrorZ. + * Channel config which affects behavior during channel lifetime. */ -void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); +struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Channel config which affects behavior during channel lifetime. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); +void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new UserConfig given each field */ -void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); +MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a copy of the UserConfig */ -void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); +struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); /** - * Creates a new CResult_NonePaymentSendFailureZ in the success state. + * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); +MUST_USE_RES struct LDKUserConfig UserConfig_default(void); /** - * Creates a new CResult_NonePaymentSendFailureZ in the error state. + * Creates a copy of the AccessError */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NonePaymentSendFailureZ. + * Calls the free function if one is set */ -void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); +void Access_free(struct LDKAccess this_ptr); /** - * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); +void Listen_free(struct LDKListen this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Calls the free function if one is set */ -void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); +void Confirm_free(struct LDKConfirm this_ptr); /** - * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. + * Calls the free function if one is set */ -struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); +void Watch_free(struct LDKWatch this_ptr); /** - * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. + * Calls the free function if one is set */ -void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); +void Filter_free(struct LDKFilter this_ptr); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. + * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); +void WatchedOutput_free(struct LDKWatchedOutput this_obj); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. + * First block where the transaction output may have been spent. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. + * First block where the transaction output may have been spent. */ -void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); +void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the Event + * Outpoint identifying the transaction output. */ -void Event_free(struct LDKEvent this_ptr); +struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Creates a copy of the Event + * Outpoint identifying the transaction output. */ -struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Serialize the Event object into a byte array which can be read by Event_read + * Spending condition of the transaction output. */ -struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Frees any resources used by the MessageSendEvent + * Spending condition of the transaction output. */ -void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Creates a copy of the MessageSendEvent + * Constructs a new WatchedOutput given each field */ -struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); +MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); /** * Calls the free function if one is set */ -void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); /** - * Calls the free function if one is set + * Creates a copy of the ConfirmationTarget */ -void EventsProvider_free(struct LDKEventsProvider this_ptr); +enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); /** - * Frees any resources used by the APIError + * Calls the free function if one is set */ -void APIError_free(struct LDKAPIError this_ptr); +void FeeEstimator_free(struct LDKFeeEstimator this_ptr); /** - * Creates a copy of the APIError + * Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. */ -struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); +void ChainMonitor_free(struct LDKChainMonitor this_obj); /** - * Creates a digital signature of a message given a SecretKey, like the node's secret. - * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. - * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. + * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. + * + * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor + * will call back to it indicating transactions and outputs of interest. This allows clients to + * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may + * always need to fetch full blocks absent another means for determining which blocks contain + * transactions relevant to the watched channels. */ -struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, struct LDKSecretKey sk); +MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); /** - * Recovers the PublicKey of the signer of the message given the message and the signature. + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is */ -struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); +struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, - * and the PublicKey. + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); +struct LDKConfirm ChainMonitor_as_Confirm(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a copy of the Level + * Constructs a new Watch which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is */ -enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); +struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Returns the most verbose logging level. + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -MUST_USE_RES enum LDKLevel Level_max(void); +struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. */ -void Logger_free(struct LDKLogger this_ptr); +void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); /** - * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. + * The sequence number of this update. Updates *must* be replayed in-order according to this + * sequence number (and updates may panic if they are not). The update_id values are strictly + * increasing and increase by one for each new update, with one exception specified below. + * + * This sequence number is also used to track up to which points updates which returned + * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given + * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * + * The only instance where update_id values are not strictly increasing is the case where we + * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See + * its docs for more details. */ -void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); +uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); /** - * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the - * equivalent limit applied to outbound channels). + * The sequence number of this update. Updates *must* be replayed in-order according to this + * sequence number (and updates may panic if they are not). The update_id values are strictly + * increasing and increase by one for each new update, with one exception specified below. * - * Default value: 6. + * This sequence number is also used to track up to which points updates which returned + * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given + * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * + * The only instance where update_id values are not strictly increasing is the case where we + * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See + * its docs for more details. */ -uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the - * equivalent limit applied to outbound channels). - * - * Default value: 6. + * Creates a copy of the ChannelMonitorUpdate */ -void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); +struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); /** - * Set to the number of blocks we require our counterparty to wait to claim their money (ie - * the number of blocks we have to punish our counterparty if they broadcast a revoked - * transaction). - * - * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST - * be online to check for revoked transactions on-chain at least once every our_to_self_delay - * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, - * possibly with time in between to RBF the spending transaction). - * - * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in - * case of an honest unilateral channel close, which implicitly decrease the economic value of - * our channel. - * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read + */ +struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); + +/** + * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write */ -uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); /** - * Set to the number of blocks we require our counterparty to wait to claim their money (ie - * the number of blocks we have to punish our counterparty if they broadcast a revoked - * transaction). - * - * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST - * be online to check for revoked transactions on-chain at least once every our_to_self_delay - * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, - * possibly with time in between to RBF the spending transaction). - * - * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in - * case of an honest unilateral channel close, which implicitly decrease the economic value of - * our channel. - * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * Creates a copy of the ChannelMonitorUpdateErr */ -void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); +enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig); /** - * Set to the smallest value HTLC we will accept to process. - * - * This value is sent to our counterparty on channel-open and we close the channel any time - * our counterparty misbehaves by sending us an HTLC with a value smaller than this. - * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +void MonitorUpdateError_free(struct LDKMonitorUpdateError this_obj); /** - * Set to the smallest value HTLC we will accept to process. - * - * This value is sent to our counterparty on channel-open and we close the channel any time - * our counterparty misbehaves by sending us an HTLC with a value smaller than this. - * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Creates a copy of the MonitorUpdateError */ -void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); +struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig); /** - * Constructs a new ChannelHandshakeConfig given each field + * Frees any resources used by the MonitorEvent */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg); +void MonitorEvent_free(struct LDKMonitorEvent this_ptr); /** - * Creates a copy of the ChannelHandshakeConfig + * Creates a copy of the MonitorEvent */ -struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); +struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); /** - * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. + * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); +void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); /** - * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. + * Creates a copy of the HTLCUpdate */ -void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); +struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); /** - * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so - * only applies to inbound channels. - * - * Default value: 0. + * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read */ -uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); /** - * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so - * only applies to inbound channels. - * - * Default value: 0. + * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write */ -void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); /** - * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows - * you to limit the maximum minimum-size they can require. - * - * Default value: u64::max_value. + * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +void ChannelMonitor_free(struct LDKChannelMonitor this_obj); /** - * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows - * you to limit the maximum minimum-size they can require. - * - * Default value: u64::max_value. + * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read */ -void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); /** - * The remote node sets a limit on the maximum value of pending HTLCs to them at any given - * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * Updates a ChannelMonitor on the basis of some new information provided by the Channel + * itself. * - * Default value: 0. + * panics if the given update is not the next update by update_id. */ -uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger); /** - * The remote node sets a limit on the maximum value of pending HTLCs to them at any given - * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. - * - * Default value: 0. + * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this + * ChannelMonitor. */ -void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * The remote node will require we keep a certain amount in direct payment to ourselves at all - * time, ensuring that we are able to be punished if we broadcast an old state. This allows to - * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). - * - * Default value: u64::max_value. + * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. */ -uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * The remote node will require we keep a certain amount in direct payment to ourselves at all - * time, ensuring that we are able to be punished if we broadcast an old state. This allows to - * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). - * - * Default value: u64::max_value. + * Gets a list of txids, with their output scripts (in the order they appear in the + * transaction), which we must learn about spends of via block_connected(). */ -void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the maximum number of pending HTLCs to them at any given - * time. This allows you to set a minimum such value. - * - * Default value: 0. + * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly + * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs + * have been registered. */ -uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR filter); /** - * The remote node sets a limit on the maximum number of pending HTLCs to them at any given - * time. This allows you to set a minimum such value. - * - * Default value: 0. + * Get the list of HTLCs who's status has been updated on chain. This should be called by + * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. */ -void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Outputs below a certain value will not be added to on-chain transactions. The dust value is - * required to always be higher than this value so this only applies to HTLC outputs (and - * potentially to-self outputs before any payments have been made). - * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * This setting allows you to set a minimum dust limit for their commitment transactions, - * reflecting the reality that tiny outputs are not considered standard transactions and will - * not propagate through the Bitcoin network. + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. * - * Default value: 546, the current dust limit on the Bitcoin network. + * This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to + * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do + * no internal locking in ChannelMonitors. */ -uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Outputs below a certain value will not be added to on-chain transactions. The dust value is - * required to always be higher than this value so this only applies to HTLC outputs (and - * potentially to-self outputs before any payments have been made). - * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * This setting allows you to set a minimum dust limit for their commitment transactions, - * reflecting the reality that tiny outputs are not considered standard transactions and will - * not propagate through the Bitcoin network. - * - * Default value: 546, the current dust limit on the Bitcoin network. + * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of + * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of + * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows + * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these + * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to + * broadcast them if counterparty don't close channel with his higher commitment transaction after a + * substantial amount of time (a month or even a year) to get back funds. Best may be to contact + * out-of-band the other node operator to coordinate with him if option is available to you. + * In any-case, choice is up to the user. */ -void ChannelHandshakeLimits_set_min_dust_limit_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); /** - * Maximum allowed threshold above which outputs will not be generated in their commitment - * transactions. - * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. + * Processes transactions in a newly connected block, which may result in any of the following: + * - update the monitor's state against resolved HTLCs + * - punish the counterparty in the case of seeing a revoked commitment transaction + * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration + * - detect settled outputs for later spending + * - schedule and bump any in-flight claims * - * Default value: u64::max_value. + * Returns any new outputs to watch from `txdata`; after called, these are also included in + * [`get_outputs_to_watch`]. + * + * [`get_outputs_to_watch`]: #method.get_outputs_to_watch */ -uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_block_connected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Maximum allowed threshold above which outputs will not be generated in their commitment - * transactions. - * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * - * Default value: u64::max_value. + * Determines if the disconnected block contained any transactions of interest and updates + * appropriately. */ -void ChannelHandshakeLimits_set_max_dust_limit_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Before a channel is usable the funding transaction will need to be confirmed by at least a - * certain number of blocks, specified by the node which is not the funder (as the funder can - * assume they aren't going to double-spend themselves). - * This config allows you to set a limit on the maximum amount of time to wait. + * Processes transactions confirmed in a block with the given header and height, returning new + * outputs to watch. See [`block_connected`] for details. * - * Default value: 144, or roughly one day and only applies to outbound channels. + * Used instead of [`block_connected`] by clients that are notified of transactions rather than + * blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_connected`]: Self::block_connected */ -uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Before a channel is usable the funding transaction will need to be confirmed by at least a - * certain number of blocks, specified by the node which is not the funder (as the funder can - * assume they aren't going to double-spend themselves). - * This config allows you to set a limit on the maximum amount of time to wait. + * Processes a transaction that was reorganized out of the chain. * - * Default value: 144, or roughly one day and only applies to outbound channels. + * Used instead of [`block_disconnected`] by clients that are notified of transactions rather + * than blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_disconnected`]: Self::block_disconnected */ -void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); +void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Set to force the incoming channel to match our announced channel preference in - * ChannelConfig. + * Updates the monitor with the current best chain tip, returning new outputs to watch. See + * [`block_connected`] for details. * - * Default value: true, to make the default that no announced channels are possible (which is - * appropriate for any nodes which are not online very reliably). + * Used instead of [`block_connected`] by clients that are notified of transactions rather than + * blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_connected`]: Self::block_connected */ -bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Set to force the incoming channel to match our announced channel preference in - * ChannelConfig. - * - * Default value: true, to make the default that no announced channels are possible (which is - * appropriate for any nodes which are not online very reliably). + * Returns the set of txids that should be monitored for re-organization out of the chain. */ -void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Set to the amount of time we're willing to wait to claim money back to us. - * - * Not checking this value would be a security issue, as our peer would be able to set it to - * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. - * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to - * reduce the loss of having useless locked funds (if your peer accepts) + * Calls the free function if one is set + */ +void Persist_free(struct LDKPersist this_ptr); + +/** + * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write */ -uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); /** - * Set to the amount of time we're willing to wait to claim money back to us. - * - * Not checking this value would be a security issue, as our peer would be able to set it to - * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. - * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to - * reduce the loss of having useless locked funds (if your peer accepts) + * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. */ -void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +void OutPoint_free(struct LDKOutPoint this_obj); /** - * Constructs a new ChannelHandshakeLimits given each field + * The referenced transaction's txid. */ -MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); +const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the ChannelHandshakeLimits + * The referenced transaction's txid. */ -struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); +void OutPoint_set_txid(struct LDKOutPoint *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. + * The index of the referenced output in its transaction's vout. */ -MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); +uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. + * The index of the referenced output in its transaction's vout. */ -void ChannelConfig_free(struct LDKChannelConfig this_obj); +void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); /** - * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * Default value: 0. + * Constructs a new OutPoint given each field */ -uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); /** - * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * Default value: 0. + * Creates a copy of the OutPoint */ -void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); +struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); /** - * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over - * the channel this config applies to. - * - * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight - * HTLC balance when a channel appears on-chain whereas - * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining - * (non-HTLC-encumbered) balance. - * - * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, - * we (or one of our watchtowers) MUST be online to check for broadcast of the current - * commitment transaction at least once per this many blocks (minus some margin to allow us - * enough time to broadcast and confirm a transaction, possibly with time in between to RBF - * the spending transaction). - * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. - * - * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + * Convert an `OutPoint` to a lightning channel id. */ -uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); /** - * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over - * the channel this config applies to. - * - * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight - * HTLC balance when a channel appears on-chain whereas - * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining - * (non-HTLC-encumbered) balance. - * - * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, - * we (or one of our watchtowers) MUST be online to check for broadcast of the current - * commitment transaction at least once per this many blocks (minus some margin to allow us - * enough time to broadcast and confirm a transaction, possibly with time in between to RBF - * the spending transaction). - * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. - * - * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + * Serialize the OutPoint object into a byte array which can be read by OutPoint_read */ -void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); /** - * Set to announce the channel publicly and notify all nodes that they can route via this - * channel. - * - * This should only be set to true for nodes which expect to be online reliably. - * - * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set. - * - * This cannot be changed after the initial channel handshake. - * - * Default value: false. + * Read a OutPoint from a byte array, created by OutPoint_write */ -bool ChannelConfig_get_announced_channel(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); /** - * Set to announce the channel publicly and notify all nodes that they can route via this - * channel. - * - * This should only be set to true for nodes which expect to be online reliably. - * - * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set. - * - * This cannot be changed after the initial channel handshake. - * - * Default value: false. + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -void ChannelConfig_set_announced_channel(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** - * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty - * supports it, they will then enforce the mutual-close output to us matches what we provided - * at intialization, preventing us from closing to an alternate pubkey. - * - * This is set to true by default to provide a slight increase in security, though ultimately - * any attacker who is able to take control of a channel can just as easily send the funds via - * lightning payments, so we never require that our counterparties support this option. - * - * This cannot be changed after a channel has been initialized. - * - * Default value: true. + * The outpoint which is spendable */ -bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty - * supports it, they will then enforce the mutual-close output to us matches what we provided - * at intialization, preventing us from closing to an alternate pubkey. - * - * This is set to true by default to provide a slight increase in security, though ultimately - * any attacker who is able to take control of a channel can just as easily send the funds via - * lightning payments, so we never require that our counterparties support this option. - * - * This cannot be changed after a channel has been initialized. - * - * Default value: true. + * The outpoint which is spendable */ -void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); +void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Constructs a new ChannelConfig given each field + * Per commitment point to derive delayed_payment_key by key holder */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelConfig + * Per commitment point to derive delayed_payment_key by key holder */ -struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); +void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. + * The nSequence value which must be set in the spending input to satisfy the OP_CSV in + * the witness_script. */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); +uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read + * The nSequence value which must be set in the spending input to satisfy the OP_CSV in + * the witness_script. */ -struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); +void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); /** - * Read a ChannelConfig from a byte array, created by ChannelConfig_write + * The output which is referenced by the given outpoint */ -struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); +void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -void UserConfig_free(struct LDKUserConfig this_obj); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Channel config that we propose to our counterparty. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -struct LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Channel config that we propose to our counterparty. + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -void UserConfig_set_own_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val); +const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Limits applied to our counterparty's proposed channel config settings. + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -struct LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Limits applied to our counterparty's proposed channel config settings. + * The value of the channel which this output originated from, possibly indirectly. */ -void UserConfig_set_peer_channel_config_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val); +uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Channel config which affects behavior during channel lifetime. + * The value of the channel which this output originated from, possibly indirectly. */ -struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Channel config which affects behavior during channel lifetime. + * Constructs a new DelayedPaymentOutputDescriptor given each field */ -void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); /** - * Constructs a new UserConfig given each field + * Creates a copy of the DelayedPaymentOutputDescriptor */ -MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg); +struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Creates a copy of the UserConfig + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** - * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. + * The outpoint which is spendable */ -MUST_USE_RES struct LDKUserConfig UserConfig_default(void); +struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates a copy of the AccessError + * The outpoint which is spendable */ -enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); +void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Calls the free function if one is set + * The output which is referenced by the given outpoint */ -void Access_free(struct LDKAccess this_ptr); +void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Calls the free function if one is set + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -void Listen_free(struct LDKListen this_ptr); +const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Calls the free function if one is set + * Arbitrary identification information returned by a call to + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in + * the channel to spend the output. */ -void Confirm_free(struct LDKConfirm this_ptr); +void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Calls the free function if one is set + * The value of the channel which this transactions spends. */ -void Watch_free(struct LDKWatch this_ptr); +uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The value of the channel which this transactions spends. */ -void Filter_free(struct LDKFilter this_ptr); +void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. + * Constructs a new StaticPaymentOutputDescriptor given each field */ -void WatchedOutput_free(struct LDKWatchedOutput this_obj); +MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); /** - * First block where the transaction output may have been spent. + * Creates a copy of the StaticPaymentOutputDescriptor */ -struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); /** - * First block where the transaction output may have been spent. + * Frees any resources used by the SpendableOutputDescriptor */ -void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); /** - * Outpoint identifying the transaction output. + * Creates a copy of the SpendableOutputDescriptor */ -struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); /** - * Outpoint identifying the transaction output. + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ -void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); /** - * Spending condition of the transaction output. + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write */ -struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); /** - * Spending condition of the transaction output. + * Calls the free function if one is set */ -void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void BaseSign_free(struct LDKBaseSign this_ptr); /** - * Constructs a new WatchedOutput given each field + * Creates a copy of a Sign */ -MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); +struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); /** * Calls the free function if one is set */ -void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); +void Sign_free(struct LDKSign this_ptr); /** - * Creates a copy of the ConfirmationTarget + * Calls the free function if one is set */ -enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); +void KeysInterface_free(struct LDKKeysInterface this_ptr); /** - * Calls the free function if one is set + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. */ -void FeeEstimator_free(struct LDKFeeEstimator this_ptr); +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** - * Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. + * Private key of anchor tx */ -void ChainMonitor_free(struct LDKChainMonitor this_obj); +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. - * - * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor - * will call back to it indicating transactions and outputs of interest. This allows clients to - * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may - * always need to fetch full blocks absent another means for determining which blocks contain - * transactions relevant to the watched channels. + * Private key of anchor tx */ -MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Constructs a new Watch which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is + * Holder secret key for blinded revocation pubkey */ -struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * Holder secret key for blinded revocation pubkey */ -struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * The sequence number of this update. Updates *must* be replayed in-order according to this - * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with one exception specified below. - * - * This sequence number is also used to track up to which points updates which returned - * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given - * ChannelMonitor when ChannelManager::channel_monitor_updated is called. - * - * The only instance where update_id values are not strictly increasing is the case where we - * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See - * its docs for more details. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * The sequence number of this update. Updates *must* be replayed in-order according to this - * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with one exception specified below. - * - * This sequence number is also used to track up to which points updates which returned - * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given - * ChannelMonitor when ChannelManager::channel_monitor_updated is called. - * - * The only instance where update_id values are not strictly increasing is the case where we - * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See - * its docs for more details. + * Holder secret key used in HTLC tx */ -void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the ChannelMonitorUpdate + * Holder secret key used in HTLC tx */ -struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read + * Holder htlc secret key used in commitment tx htlc outputs */ -struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write + * Holder htlc secret key used in commitment tx htlc outputs */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Creates a copy of the ChannelMonitorUpdateErr + * Commitment seed */ -enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *NONNULL_PTR orig); +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL. + * Commitment seed */ -void MonitorUpdateError_free(struct LDKMonitorUpdateError this_obj); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the MonitorUpdateError + * Creates a copy of the InMemorySigner */ -struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * Frees any resources used by the MonitorEvent + * Create a new InMemorySigner */ -void MonitorEvent_free(struct LDKMonitorEvent this_ptr); +MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); /** - * Creates a copy of the MonitorEvent + * Counterparty pubkeys. + * Will panic if ready_channel wasn't called. */ -struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. + * The contest_delay value specified by our counterparty and applied on holder-broadcastable + * transactions, ie the amount of time that we have to wait to recover our funds if we + * broadcast a transaction. + * Will panic if ready_channel wasn't called. */ -void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); +MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCUpdate + * The contest_delay value specified by us and applied on transactions broadcastable + * by our counterparty, ie the amount of time that they have to wait to recover their funds + * if they broadcast a transaction. + * Will panic if ready_channel wasn't called. */ -struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); +MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read + * Whether the holder is the initiator + * Will panic if ready_channel wasn't called. */ -struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); +MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write + * Funding outpoint + * Will panic if ready_channel wasn't called. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. + * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or + * building transactions. + * + * Will panic if ready_channel wasn't called. */ -void ChannelMonitor_free(struct LDKChannelMonitor this_obj); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read + * Sign the single input of spend_tx at index `input_idx` which spends the output + * described by descriptor, returning the witness stack for the input. + * + * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, + * or is not spending the outpoint described by `descriptor.outpoint`. */ -struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * Updates a ChannelMonitor on the basis of some new information provided by the Channel - * itself. + * Sign the single input of spend_tx at index `input_idx` which spends the output + * described by descriptor, returning the witness stack for the input. * - * panics if the given update is not the next update by update_id. + * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, + * is not spending the outpoint described by `descriptor.outpoint`, or does not have a + * sequence set to `descriptor.to_self_delay`. */ -MUST_USE_RES struct LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger); +MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this - * ChannelMonitor. + * Constructs a new BaseSign which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is */ -MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKBaseSign InMemorySigner_as_BaseSign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. + * Constructs a new Sign which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is */ -MUST_USE_RES struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKSign InMemorySigner_as_Sign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Gets a list of txids, with their output scripts (in the order they appear in the - * transaction), which we must learn about spends of via block_connected(). + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ -MUST_USE_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); /** - * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly - * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs - * have been registered. + * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR filter); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser); /** - * Get the list of HTLCs who's status has been updated on chain. This should be called by - * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +void KeysManager_free(struct LDKKeysManager this_obj); /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. + * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your + * CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). + * starting_time isn't strictly required to actually be a time, but it must absolutely, + * without a doubt, be unique to this instance. ie if you start multiple times with the same + * seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to + * simply use the current time (with very high precision). * - * This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to - * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do - * no internal locking in ChannelMonitors. + * The seed MUST be backed up safely prior to use so that the keys can be re-created, however, + * obviously, starting_time should be unique every time you reload the library - it is only + * used to generate new ephemeral key data (which will be stored by the individual channel if + * necessary). + * + * Note that the seed is required to recover certain on-chain funds independent of + * ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any + * channel, and some on-chain during-closing funds. + * + * Note that until the 0.1 release there is no guarantee of backward compatibility between + * versions. Once the library is more fully supported, the docs will be updated to include a + * detailed description of the guarantee. */ -MUST_USE_RES struct LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of - * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of - * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows - * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these - * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to - * broadcast them if counterparty don't close channel with his higher commitment transaction after a - * substantial amount of time (a month or even a year) to get back funds. Best may be to contact - * out-of-band the other node operator to coordinate with him if option is available to you. - * In any-case, choice is up to the user. + * Derive an old Sign containing per-channel secrets based on a key derivation parameters. + * + * Key derivation parameters are accessible through a per-channel secrets + * Sign::channel_keys_id and is provided inside DynamicOuputP2WSH in case of + * onchain output detection for which a corresponding delayed_payment_key must be derived. */ -MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); +MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * Processes transactions in a newly connected block, which may result in any of the following: - * - update the monitor's state against resolved HTLCs - * - punish the counterparty in the case of seeing a revoked commitment transaction - * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration - * - detect settled outputs for later spending - * - schedule and bump any in-flight claims + * Creates a Transaction which spends the given descriptors to the given outputs, plus an + * output to the given change destination (if sufficient change value remains). The + * transaction will have a feerate, at least, of the given value. * - * Returns any new outputs to watch from `txdata`; after called, these are also included in - * [`get_outputs_to_watch`]. + * Returns `Err(())` if the output value is greater than the input value minus required fee or + * if a descriptor was duplicated. * - * [`get_outputs_to_watch`]: #method.get_outputs_to_watch + * We do not enforce that outputs meet the dust limit or that any output scripts are standard. + * + * May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used + * this KeysManager or one of the `InMemorySigner` created by this KeysManager. + */ +MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight); + +/** + * Constructs a new KeysInterface which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_block_connected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * Determines if the disconnected block contained any transactions of interest and updates - * appropriately. + * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. */ -void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +void ChannelManager_free(struct LDKChannelManager this_obj); /** - * Processes transactions confirmed in a block with the given header and height, returning new - * outputs to watch. See [`block_connected`] for details. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_connected`]: Self::block_connected + * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +void ChainParameters_free(struct LDKChainParameters this_obj); /** - * Processes a transaction that was reorganized out of the chain. - * - * Used instead of [`block_disconnected`] by clients that are notified of transactions rather - * than blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_disconnected`]: Self::block_disconnected + * The network for determining the `chain_hash` in Lightning messages. */ -void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); /** - * Updates the monitor with the current best chain tip, returning new outputs to watch. See - * [`block_connected`] for details. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. See [`chain::Confirm`] for calling expectations. + * The network for determining the `chain_hash` in Lightning messages. + */ +void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); + +/** + * The hash and height of the latest block successfully connected. * - * [`block_connected`]: Self::block_connected + * Used to track on-chain channel funding outputs and send payments with reliable timelocks. */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); /** - * Returns the set of txids that should be monitored for re-organization out of the chain. + * The hash and height of the latest block successfully connected. + * + * Used to track on-chain channel funding outputs and send payments with reliable timelocks. */ -MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); /** - * Calls the free function if one is set + * Constructs a new ChainParameters given each field */ -void Persist_free(struct LDKPersist this_ptr); +MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); /** - * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write + * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); +void BestBlock_free(struct LDKBestBlock this_obj); /** - * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. + * Creates a copy of the BestBlock */ -void OutPoint_free(struct LDKOutPoint this_obj); +struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); /** - * The referenced transaction's txid. + * Returns the best block from the genesis of the given network. */ -const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); /** - * The referenced transaction's txid. + * Returns the best block as identified by the given block hash and height. */ -void OutPoint_set_txid(struct LDKOutPoint *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); /** - * The index of the referenced output in its transaction's vout. + * Returns the best block hash. */ -uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); /** - * The index of the referenced output in its transaction's vout. + * Returns the best block height. */ -void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); /** - * Constructs a new OutPoint given each field + * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); +void ChannelDetails_free(struct LDKChannelDetails this_obj); /** - * Creates a copy of the OutPoint + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. */ -struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); +const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; /** - * Convert an `OutPoint` to a lightning channel id. + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. */ -MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); +void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the OutPoint object into a byte array which can be read by OutPoint_read + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. */ -struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); +struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Read a OutPoint from a byte array, created by OutPoint_write + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. */ -struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); +void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * The node_id of our counterparty */ -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); +struct LDKPublicKey ChannelDetails_get_remote_network_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * The outpoint which is spendable + * The node_id of our counterparty */ -struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void ChannelDetails_set_remote_network_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The outpoint which is spendable + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. */ -void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKInitFeatures ChannelDetails_get_counterparty_features(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Per commitment point to derive delayed_payment_key by key holder + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void ChannelDetails_set_counterparty_features(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * Per commitment point to derive delayed_payment_key by key holder + * The value, in satoshis, of this channel as appears in the funding output */ -void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * The nSequence value which must be set in the spending input to satisfy the OP_CSV in - * the witness_script. + * The value, in satoshis, of this channel as appears in the funding output */ -uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * The nSequence value which must be set in the spending input to satisfy the OP_CSV in - * the witness_script. + * The user_id passed in to create_channel, or 0 if the channel was inbound. */ -void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +uint64_t ChannelDetails_get_user_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * The output which is referenced by the given outpoint + * The user_id passed in to create_channel, or 0 if the channel was inbound. */ -void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +void ChannelDetails_set_user_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. */ -void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. */ -const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. */ -void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * The value of the channel which this output originated from, possibly indirectly. + * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) + * the peer is connected, and (c) no monitor update failure is pending resolution. */ -uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +bool ChannelDetails_get_is_live(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * The value of the channel which this output originated from, possibly indirectly. + * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) + * the peer is connected, and (c) no monitor update failure is pending resolution. */ -void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +void ChannelDetails_set_is_live(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Constructs a new DelayedPaymentOutputDescriptor given each field + * Creates a copy of the ChannelDetails */ -MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); /** - * Creates a copy of the DelayedPaymentOutputDescriptor + * Frees any resources used by the PaymentSendFailure */ -struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); /** - * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * Creates a copy of the PaymentSendFailure */ -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); +struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); /** - * The outpoint which is spendable + * Constructs a new ChannelManager to hold several channels and route between them. + * + * This is the main \"logic hub\" for all channel-related actions, and implements + * ChannelMessageHandler. + * + * Non-proportional fees are fixed according to our risk using the provided fee estimator. + * + * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`! + * + * Users need to notify the new ChannelManager when a new block is connected or + * disconnected using its `block_connected` and `block_disconnected` methods, starting + * from after `params.latest_hash`. */ -struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params); /** - * The outpoint which is spendable + * Gets the current configuration applied to all new channels, as */ -void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The output which is referenced by the given outpoint + * Creates a new outbound channel to the given remote node and with the given value. + * + * user_id will be provided back as user_channel_id in FundingGenerationReady events to allow + * tracking of which events correspond with which create_channel call. Note that the + * user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for + * user_id here. user_id has no meaning inside of LDK, it is simply copied to events and + * otherwise ignored. + * + * If successful, will generate a SendOpenChannel message event, so you should probably poll + * PeerManager::process_events afterwards. + * + * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is + * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000. */ -void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, struct LDKUserConfig override_config); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * Gets the list of open channels, in random order. See ChannelDetail field documentation for + * more information. */ -const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Arbitrary identification information returned by a call to - * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in - * the channel to spend the output. + * Gets the list of usable channels, in random order. Useful as an argument to + * get_route to ensure non-announced channels are used. + * + * These are guaranteed to have their is_live value set to true, see the documentation for + * ChannelDetails::is_live for more info on exactly what the criteria are. */ -void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The value of the channel which this transactions spends. + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * May generate a SendShutdown message event on success, which should be relayed. */ -uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]); /** - * The value of the channel which this transactions spends. + * Force closes a channel, immediately broadcasting the latest local commitment transaction to + * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. */ -void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]); /** - * Constructs a new StaticPaymentOutputDescriptor given each field + * Force close all channels, immediately broadcasting the latest local commitment transaction + * for each to the chain and rejecting new HTLCs on each. */ -MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +void ChannelManager_force_close_all_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the StaticPaymentOutputDescriptor + * Sends a payment along a given route. + * + * Value parameters are provided via the last hop in route, see documentation for RouteHop + * fields for more info. + * + * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative + * payment), we don't do anything to stop you! We always try to ensure that if the provided + * next hop knows the preimage to payment_hash they can claim an additional amount as + * specified in the last hop in the route! Thus, you should probably do your own + * payment_preimage tracking (which you should already be doing as they represent \"proof of + * payment\") and prevent double-sends yourself. + * + * May generate SendHTLCs message(s) event on success, which should be relayed. + * + * Each path may have a different return value, and PaymentSendValue may return a Vec with + * each entry matching the corresponding-index entry in the route paths, see + * PaymentSendFailure for more info. + * + * In general, a path may raise: + * * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee, + * node public key) is specified. + * * APIError::ChannelUnavailable if the next-hop channel is not available for updates + * (including due to previous monitor update failure or new permanent monitor update + * failure). + * * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the + * relevant updates. + * + * Note that depending on the type of the PaymentSendFailure the HTLC may have been + * irrevocably committed to on our end. In such a case, do NOT retry the payment with a + * different route unless you intend to pay twice! + * + * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate + * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For + * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route + * must not contain multiple paths as multi-path payments require a recipient-provided + * payment_secret. + * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature + * bit set (either as required or as available). If multiple paths are present in the Route, + * we assume the invoice had the basic_mpp feature set. */ -struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); /** - * Frees any resources used by the SpendableOutputDescriptor + * Call this upon creation of a funding transaction for the given channel. + * + * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs + * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. + * + * Panics if a funding transaction has already been provided for this channel. + * + * May panic if the output found in the funding transaction is duplicative with some other + * channel (note that this should be trivially prevented by using unique funding transaction + * keys per-channel). + * + * Do NOT broadcast the funding transaction yourself. When we have safely received our + * counterparty's signature the funding transaction will automatically be broadcast via the + * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. + * + * Note that this includes RBF or similar transaction replacement strategies - lightning does + * not currently support replacing a funding transaction on an existing channel. Instead, + * create a new channel with a conflicting funding transaction. */ -void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKTransaction funding_transaction); /** - * Creates a copy of the SpendableOutputDescriptor + * Generates a signed node_announcement from the given arguments and creates a + * BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have + * seen a channel_announcement from us (ie unless we have public channels open). + * + * RGB is a node \"color\" and alias is a printable human-readable string to describe this node + * to humans. They carry no in-protocol meaning. + * + * addresses represent the set (possibly empty) of socket addresses on which this node accepts + * incoming connections. These will be broadcast to the network, publicly tying these + * addresses together. If you wish to preserve user privacy, addresses should likely contain + * only Tor Onion addresses. + * + * Panics if addresses is absurdly large (more than 500). */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); /** - * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + * Processes HTLCs which are pending waiting on random forward delay. + * + * Should only really ever be called in response to a PendingHTLCsForwardable event. + * Will likely generate further events. */ -struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + * If a peer is disconnected we mark any channels with that peer as 'disabled'. + * After some time, if channels are still disabled we need to broadcast a ChannelUpdate + * to inform the network about the uselessness of these channels. + * + * This method handles all the details, and must be called roughly once per minute. + * + * Note that in some rare cases this may generate a `chain::Watch::update_channel` call. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect + * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources + * along the path (including in our own channel on which we received it). + * Returns false if no payment was found to fail backwards, true if the process of failing the + * HTLC backwards has been started. */ -void BaseSign_free(struct LDKBaseSign this_ptr); +MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); /** - * Creates a copy of a Sign + * Provides a payment preimage in response to a PaymentReceived event, returning true and + * generating message events for the net layer to claim the payment, if possible. Thus, you + * should probably kick the net layer to go send messages if this returns true! + * + * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or + * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived` + * event matches your expectation. If you fail to do so and call this method, you may provide + * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. + * + * May panic if called except in response to a PaymentReceived event. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); +MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); /** - * Calls the free function if one is set + * Gets the node_id held by this ChannelManager */ -void Sign_free(struct LDKSign this_ptr); +MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Restores a single, given channel to normal operation after a + * ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update + * operation. + * + * All ChannelMonitor updates up to and including highest_applied_update_id must have been + * fully committed in every copy of the given channels' ChannelMonitors. + * + * Note that there is no effect to calling with a highest_applied_update_id other than the + * current latest ChannelMonitorUpdate and one call to this function after multiple + * ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field + * exists largely only to prevent races between this and concurrent update_monitor calls. + * + * Thus, the anticipated use is, at a high level: + * 1) You register a chain::Watch with this ChannelManager, + * 2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of + * said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures + * any time it cannot do so instantly, + * 3) update(s) are applied to each remote copy of a ChannelMonitor, + * 4) once all remote copies are updated, you call this function with the update_id that + * completed, and once it is the latest the Channel will be re-enabled. */ -void KeysInterface_free(struct LDKKeysInterface this_ptr); +void ChannelManager_channel_monitor_updated(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOutPoint *NONNULL_PTR funding_txo, uint64_t highest_applied_update_id); /** - * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + * Gets a payment secret and payment hash for use in an invoice given to a third party wishing + * to pay us. + * + * This differs from [`create_inbound_payment_for_hash`] only in that it generates the + * [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second. + * + * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which + * will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be + * passed directly to [`claim_funds`]. + * + * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. + * + * [`claim_funds`]: Self::claim_funds + * [`PaymentReceived`]: events::Event::PaymentReceived + * [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -void InMemorySigner_free(struct LDKInMemorySigner this_obj); +MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id); /** - * Private key of anchor tx + * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is + * stored external to LDK. + * + * A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a + * payment secret fetched via this method or [`create_inbound_payment`], and which is at least + * the `min_value_msat` provided here, if one is provided. + * + * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This + * method may return an Err if another payment with the same payment_hash is still pending. + * + * `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to + * allow tracking of which events correspond with which calls to this and + * [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply + * copied to events and otherwise ignored. It may be used to correlate PaymentReceived events + * with invoice metadata stored elsewhere. + * + * `min_value_msat` should be set if the invoice being generated contains a value. Any payment + * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` + * before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the + * sender \"proof-of-payment\" unless they have paid the required amount. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. This should roughly match the expiry time set in the invoice. + * After this many seconds, we will remove the inbound payment, resulting in any attempts to + * pay the invoice failing. The BOLT spec suggests 7,200 secs as a default validity time for + * invoices when no timeout is set. + * + * Note that we use block header time to time-out pending inbound payments (with some margin + * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will + * accept a payment and generate a [`PaymentReceived`] event for some time after the expiry. + * If you need exact expiry semantics, you should enforce them upon receipt of + * [`PaymentReceived`]. + * + * May panic if `invoice_expiry_delta_secs` is greater than one year. + * + * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry` + * set to at least [`MIN_FINAL_CLTV_EXPIRY`]. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`PaymentReceived`]: events::Event::PaymentReceived + * [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id */ -const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id); /** - * Private key of anchor tx + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Holder secret key for blinded revocation pubkey + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Holder secret key for blinded revocation pubkey + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is */ -void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions + * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool + * indicating whether persistence is necessary. Only one listener on + * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + * up. + * Note that the feature `allow_wallclock_use` must be enabled to use this function. */ -void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); /** - * Holder secret key used in HTLC tx + * Blocks until ChannelManager needs to be persisted. Only one listener on + * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + * up. */ -const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Holder secret key used in HTLC tx + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Holder htlc secret key used in commitment tx htlc outputs + * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read */ -const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); /** - * Holder htlc secret key used in commitment tx htlc outputs + * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. */ -void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); /** - * Commitment seed + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +const struct LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Commitment seed + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelManagerReadArgs_set_keys_manager(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKKeysInterface val); /** - * Creates a copy of the InMemorySigner + * The fee_estimator for use in the ChannelManager in the future. + * + * No calls to the FeeEstimator will be made during deserialization. */ -struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); +const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Create a new InMemorySigner + * The fee_estimator for use in the ChannelManager in the future. + * + * No calls to the FeeEstimator will be made during deserialization. */ -MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); +void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); /** - * Counterparty pubkeys. - * Will panic if ready_channel wasn't called. + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * The contest_delay value specified by our counterparty and applied on holder-broadcastable - * transactions, ie the amount of time that we have to wait to recover our funds if we - * broadcast a transaction. - * Will panic if ready_channel wasn't called. + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); /** - * The contest_delay value specified by us and applied on transactions broadcastable - * by our counterparty, ie the amount of time that they have to wait to recover their funds - * if they broadcast a transaction. - * Will panic if ready_channel wasn't called. + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Whether the holder is the initiator - * Will panic if ready_channel wasn't called. + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); /** - * Funding outpoint - * Will panic if ready_channel wasn't called. + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. */ -MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or - * building transactions. - * - * Will panic if ready_channel wasn't called. + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); /** - * Sign the single input of spend_tx at index `input_idx` which spends the output - * described by descriptor, returning the witness stack for the input. - * - * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, - * or is not spending the outpoint described by `descriptor.outpoint`. + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. */ -MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); +struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Sign the single input of spend_tx at index `input_idx` which spends the output - * described by descriptor, returning the witness stack for the input. - * - * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, - * is not spending the outpoint described by `descriptor.outpoint`, or does not have a - * sequence set to `descriptor.to_self_delay`. + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. */ -MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); /** - * Constructs a new BaseSign which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is + * Simple utility function to create a ChannelManagerReadArgs which creates the monitor + * HashMap for you. This is primarily useful for C bindings where it is not practical to + * populate a HashMap directly from C. */ -struct LDKBaseSign InMemorySigner_as_BaseSign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); /** - * Constructs a new Sign which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is + * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write */ -struct LDKSign InMemorySigner_as_Sign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); /** - * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + * Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +void DecodeError_free(struct LDKDecodeError this_obj); /** - * Read a InMemorySigner from a byte array, created by InMemorySigner_write + * Creates a copy of the DecodeError */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser); +struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); /** - * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. */ -void KeysManager_free(struct LDKKeysManager this_obj); +void Init_free(struct LDKInit this_obj); /** - * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your - * CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). - * starting_time isn't strictly required to actually be a time, but it must absolutely, - * without a doubt, be unique to this instance. ie if you start multiple times with the same - * seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to - * simply use the current time (with very high precision). - * - * The seed MUST be backed up safely prior to use so that the keys can be re-created, however, - * obviously, starting_time should be unique every time you reload the library - it is only - * used to generate new ephemeral key data (which will be stored by the individual channel if - * necessary). - * - * Note that the seed is required to recover certain on-chain funds independent of - * ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any - * channel, and some on-chain during-closing funds. - * - * Note that until the 0.1 release there is no guarantee of backward compatibility between - * versions. Once the library is more fully supported, the docs will be updated to include a - * detailed description of the guarantee. + * The relevant features which the sender supports */ -MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); +struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); /** - * Derive an old Sign containing per-channel secrets based on a key derivation parameters. - * - * Key derivation parameters are accessible through a per-channel secrets - * Sign::channel_keys_id and is provided inside DynamicOuputP2WSH in case of - * onchain output detection for which a corresponding delayed_payment_key must be derived. + * The relevant features which the sender supports */ -MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * Creates a Transaction which spends the given descriptors to the given outputs, plus an - * output to the given change destination (if sufficient change value remains). The - * transaction will have a feerate, at least, of the given value. - * - * Returns `Err(())` if the output value is greater than the input value minus required fee or - * if a descriptor was duplicated. - * - * We do not enforce that outputs meet the dust limit or that any output scripts are standard. - * - * May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used - * this KeysManager or one of the `InMemorySigner` created by this KeysManager. + * Constructs a new Init given each field */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight); +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg); /** - * Constructs a new KeysInterface which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is + * Creates a copy of the Init */ -struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. */ -void ChannelManager_free(struct LDKChannelManager this_obj); +void ErrorMessage_free(struct LDKErrorMessage this_obj); /** - * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. + * The channel ID involved in the error */ -void ChainParameters_free(struct LDKChainParameters this_obj); +const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; /** - * The network for determining the `chain_hash` in Lightning messages. + * The channel ID involved in the error */ -enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); +void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The network for determining the `chain_hash` in Lightning messages. + * A possibly human-readable error description. + * The string should be sanitized before it is used (e.g. emitted to logs + * or printed to stdout). Otherwise, a well crafted error message may trigger a security + * vulnerability in the terminal emulator or the logging subsystem. */ -void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); +struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); /** - * The hash and height of the latest block successfully connected. - * - * Used to track on-chain channel funding outputs and send payments with reliable timelocks. + * A possibly human-readable error description. + * The string should be sanitized before it is used (e.g. emitted to logs + * or printed to stdout). Otherwise, a well crafted error message may trigger a security + * vulnerability in the terminal emulator or the logging subsystem. */ -struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); +void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The hash and height of the latest block successfully connected. - * - * Used to track on-chain channel funding outputs and send payments with reliable timelocks. + * Constructs a new ErrorMessage given each field */ -void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); +MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z data_arg); /** - * Constructs a new ChainParameters given each field + * Creates a copy of the ErrorMessage */ -MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); +struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); /** - * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. */ -void BestBlock_free(struct LDKBestBlock this_obj); +void Ping_free(struct LDKPing this_obj); /** - * Creates a copy of the BestBlock + * The desired response length */ -struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); +uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); /** - * Returns the best block from the genesis of the given network. + * The desired response length */ -MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); +void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); /** - * Returns the best block as identified by the given block hash and height. + * The ping packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); +uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); /** - * Returns the best block hash. + * The ping packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); +void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); /** - * Returns the best block height. + * Constructs a new Ping given each field */ -MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); /** - * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + * Creates a copy of the Ping */ -void ChannelDetails_free(struct LDKChannelDetails this_obj); +struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. */ -const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; +void Pong_free(struct LDKPong this_obj); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * The pong packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. + * The pong packet size. + * This field is not sent on the wire. byteslen zeros are sent. */ -struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. + * Constructs a new Pong given each field */ -void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); /** - * The node_id of our counterparty + * Creates a copy of the Pong */ -struct LDKPublicKey ChannelDetails_get_remote_network_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); /** - * The node_id of our counterparty + * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. */ -void ChannelDetails_set_remote_network_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void OpenChannel_free(struct LDKOpenChannel this_obj); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The genesis hash of the blockchain where the channel is to be opened */ -struct LDKInitFeatures ChannelDetails_get_counterparty_features(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The genesis hash of the blockchain where the channel is to be opened */ -void ChannelDetails_set_counterparty_features(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The value, in satoshis, of this channel as appears in the funding output + * A temporary channel ID, until the funding outpoint is announced */ -uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; /** - * The value, in satoshis, of this channel as appears in the funding output + * A temporary channel ID, until the funding outpoint is announced */ -void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The user_id passed in to create_channel, or 0 if the channel was inbound. + * The channel value */ -uint64_t ChannelDetails_get_user_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The user_id passed in to create_channel, or 0 if the channel was inbound. + * The channel value */ -void ChannelDetails_set_user_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) - * the peer is connected, and (c) no monitor update failure is pending resolution. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -bool ChannelDetails_get_is_live(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) - * the peer is connected, and (c) no monitor update failure is pending resolution. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -void ChannelDetails_set_is_live(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ChannelDetails + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the PaymentSendFailure + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); +void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the PaymentSendFailure + * The minimum HTLC size incoming to sender, in milli-satoshi */ -struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); +uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelManager to hold several channels and route between them. - * - * This is the main \"logic hub\" for all channel-related actions, and implements - * ChannelMessageHandler. - * - * Non-proportional fees are fixed according to our risk using the provided fee estimator. - * - * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`! - * - * Users need to notify the new ChannelManager when a new block is connected or - * disconnected using its `block_connected` and `block_disconnected` methods, starting - * from after `params.latest_hash`. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, struct LDKChainParameters params); +void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets the current configuration applied to all new channels, as + * The feerate per 1000-weight of sender generated transactions, until updated by update_fee */ -MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Creates a new outbound channel to the given remote node and with the given value. - * - * user_id will be provided back as user_channel_id in FundingGenerationReady events to allow - * tracking of which events correspond with which create_channel call. Note that the - * user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for - * user_id here. user_id has no meaning inside of LDK, it is simply copied to events and - * otherwise ignored. - * - * If successful, will generate a SendOpenChannel message event, so you should probably poll - * PeerManager::process_events afterwards. - * - * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is - * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000. + * The feerate per 1000-weight of sender generated transactions, until updated by update_fee */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, struct LDKUserConfig override_config); +void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); /** - * Gets the list of open channels, in random order. See ChannelDetail field documentation for - * more information. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Gets the list of usable channels, in random order. Useful as an argument to - * get_route to ensure non-announced channels are used. - * - * These are guaranteed to have their is_live value set to true, see the documentation for - * ChannelDetails::is_live for more info on exactly what the criteria are. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * May generate a SendShutdown message event on success, which should be relayed. + * The maximum number of inbound HTLCs towards sender */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]); +uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Force closes a channel, immediately broadcasting the latest local commitment transaction to - * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. + * The maximum number of inbound HTLCs towards sender */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32]); +void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Force close all channels, immediately broadcasting the latest local commitment transaction - * for each to the chain and rejecting new HTLCs on each. + * The sender's key controlling the funding transaction */ -void ChannelManager_force_close_all_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Sends a payment along a given route. - * - * Value parameters are provided via the last hop in route, see documentation for RouteHop - * fields for more info. - * - * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative - * payment), we don't do anything to stop you! We always try to ensure that if the provided - * next hop knows the preimage to payment_hash they can claim an additional amount as - * specified in the last hop in the route! Thus, you should probably do your own - * payment_preimage tracking (which you should already be doing as they represent \"proof of - * payment\") and prevent double-sends yourself. - * - * May generate SendHTLCs message(s) event on success, which should be relayed. - * - * Each path may have a different return value, and PaymentSendValue may return a Vec with - * each entry matching the corresponding-index entry in the route paths, see - * PaymentSendFailure for more info. - * - * In general, a path may raise: - * * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee, - * node public key) is specified. - * * APIError::ChannelUnavailable if the next-hop channel is not available for updates - * (including due to previous monitor update failure or new permanent monitor update - * failure). - * * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the - * relevant updates. - * - * Note that depending on the type of the PaymentSendFailure the HTLC may have been - * irrevocably committed to on our end. In such a case, do NOT retry the payment with a - * different route unless you intend to pay twice! - * - * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate - * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For - * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route - * must not contain multiple paths as multi-path payments require a recipient-provided - * payment_secret. - * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature - * bit set (either as required or as available). If multiple paths are present in the Route, - * we assume the invoice had the basic_mpp feature set. + * The sender's key controlling the funding transaction */ -MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); +void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Call this upon creation of a funding transaction for the given channel. - * - * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs - * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. - * - * Panics if a funding transaction has already been provided for this channel. - * - * May panic if the output found in the funding transaction is duplicative with some other - * channel (note that this should be trivially prevented by using unique funding transaction - * keys per-channel). - * - * Do NOT broadcast the funding transaction yourself. When we have safely received our - * counterparty's signature the funding transaction will automatically be broadcast via the - * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. - * - * Note that this includes RBF or similar transaction replacement strategies - lightning does - * not currently support replacing a funding transaction on an existing channel. Instead, - * create a new channel with a conflicting funding transaction. + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKTransaction funding_transaction); +struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Generates a signed node_announcement from the given arguments and creates a - * BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have - * seen a channel_announcement from us (ie unless we have public channels open). - * - * RGB is a node \"color\" and alias is a printable human-readable string to describe this node - * to humans. They carry no in-protocol meaning. - * - * addresses represent the set (possibly empty) of socket addresses on which this node accepts - * incoming connections. These will be broadcast to the network, publicly tying these - * addresses together. If you wish to preserve user privacy, addresses should likely contain - * only Tor Onion addresses. - * - * Panics if addresses is absurdly large (more than 500). + * Used to derive a revocation key for transactions broadcast by counterparty */ -void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); +void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Processes HTLCs which are pending waiting on random forward delay. - * - * Should only really ever be called in response to a PendingHTLCsForwardable event. - * Will likely generate further events. + * A payment key to sender for transactions broadcast by counterparty */ -void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * If a peer is disconnected we mark any channels with that peer as 'disabled'. - * After some time, if channels are still disabled we need to broadcast a ChannelUpdate - * to inform the network about the uselessness of these channels. - * - * This method handles all the details, and must be called roughly once per minute. - * - * Note that in some rare cases this may generate a `chain::Watch::update_channel` call. + * A payment key to sender for transactions broadcast by counterparty */ -void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); +void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect - * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources - * along the path (including in our own channel on which we received it). - * Returns false if no payment was found to fail backwards, true if the process of failing the - * HTLC backwards has been started. + * Used to derive a payment key to sender for transactions broadcast by sender */ -MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32], struct LDKThirtyTwoBytes payment_secret); +struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Provides a payment preimage in response to a PaymentReceived event, returning true and - * generating message events for the net layer to claim the payment, if possible. Thus, you - * should probably kick the net layer to go send messages if this returns true! - * - * You must specify the expected amounts for this HTLC, and we will only claim HTLCs - * available within a few percent of the expected amount. This is critical for several - * reasons : a) it avoids providing senders with `proof-of-payment` (in the form of the - * payment_preimage without having provided the full value and b) it avoids certain - * privacy-breaking recipient-probing attacks which may reveal payment activity to - * motivated attackers. - * - * Note that the privacy concerns in (b) are not relevant in payments with a payment_secret - * set. Thus, for such payments we will claim any payments which do not under-pay. - * - * May panic if called except in response to a PaymentReceived event. + * Used to derive a payment key to sender for transactions broadcast by sender */ -MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret, uint64_t expected_amount); +void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Gets the node_id held by this ChannelManager + * Used to derive an HTLC payment key to sender */ -MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Restores a single, given channel to normal operation after a - * ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update - * operation. - * - * All ChannelMonitor updates up to and including highest_applied_update_id must have been - * fully committed in every copy of the given channels' ChannelMonitors. - * - * Note that there is no effect to calling with a highest_applied_update_id other than the - * current latest ChannelMonitorUpdate and one call to this function after multiple - * ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field - * exists largely only to prevent races between this and concurrent update_monitor calls. - * - * Thus, the anticipated use is, at a high level: - * 1) You register a chain::Watch with this ChannelManager, - * 2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of - * said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures - * any time it cannot do so instantly, - * 3) update(s) are applied to each remote copy of a ChannelMonitor, - * 4) once all remote copies are updated, you call this function with the update_id that - * completed, and once it is the latest the Channel will be re-enabled. + * Used to derive an HTLC payment key to sender */ -void ChannelManager_channel_monitor_updated(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOutPoint *NONNULL_PTR funding_txo, uint64_t highest_applied_update_id); +void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new Listen which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + * Channel flags */ -struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * Channel flags */ -struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); +void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); /** - * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool - * indicating whether persistence is necessary. Only one listener on - * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken - * up. - * Note that the feature `allow_wallclock_use` must be enabled to use this function. + * Creates a copy of the OpenChannel */ -MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); +struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); /** - * Blocks until ChannelManager needs to be persisted. Only one listener on - * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken - * up. + * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. */ -void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); +void AcceptChannel_free(struct LDKAcceptChannel this_obj); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * A temporary channel ID, until the funding outpoint is announced */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; /** - * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + * A temporary channel ID, until the funding outpoint is announced */ -struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); +void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); +uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -const struct LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -void ChannelManagerReadArgs_set_keys_manager(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKKeysInterface val); +uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); +uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); +uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * Minimum depth of the funding transaction before the channel is considered open */ -void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); +uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Minimum depth of the funding transaction before the channel is considered open */ -const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t val); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); +uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * The maximum number of inbound HTLCs towards sender */ -void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); +uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Simple utility function to create a ChannelManagerReadArgs which creates the monitor - * HashMap for you. This is primarily useful for C bindings where it is not practical to - * populate a HashMap directly from C. + * The maximum number of inbound HTLCs towards sender */ -MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); +void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write + * The sender's key controlling the funding transaction */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); +struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL. + * The sender's key controlling the funding transaction */ -void DecodeError_free(struct LDKDecodeError this_obj); +void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the DecodeError + * Used to derive a revocation key for transactions broadcast by counterparty */ -struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); +struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + * Used to derive a revocation key for transactions broadcast by counterparty */ -void Init_free(struct LDKInit this_obj); +void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The relevant features which the sender supports + * A payment key to sender for transactions broadcast by counterparty */ -struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); +struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The relevant features which the sender supports + * A payment key to sender for transactions broadcast by counterparty */ -void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new Init given each field + * Used to derive a payment key to sender for transactions broadcast by sender */ -MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg); +struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Creates a copy of the Init + * Used to derive a payment key to sender for transactions broadcast by sender */ -struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); +void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -void ErrorMessage_free(struct LDKErrorMessage this_obj); +struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The channel ID involved in the error + * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; +void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The channel ID involved in the error + * The first to-be-broadcast-by-sender transaction's per commitment point */ -void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * A possibly human-readable error description. - * The string should be sanitized before it is used (e.g. emitted to logs - * or printed to stdout). Otherwise, a well crafted error message may trigger a security - * vulnerability in the terminal emulator or the logging subsystem. + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); +void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * A possibly human-readable error description. - * The string should be sanitized before it is used (e.g. emitted to logs - * or printed to stdout). Otherwise, a well crafted error message may trigger a security - * vulnerability in the terminal emulator or the logging subsystem. + * Creates a copy of the AcceptChannel */ -void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); /** - * Constructs a new ErrorMessage given each field + * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z data_arg); +void FundingCreated_free(struct LDKFundingCreated this_obj); /** - * Creates a copy of the ErrorMessage + * A temporary channel ID, until the funding is established */ -struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + * A temporary channel ID, until the funding is established */ -void Ping_free(struct LDKPing this_obj); +void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The desired response length + * The funding transaction ID */ -uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); +const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; /** - * The desired response length + * The funding transaction ID */ -void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The ping packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * The specific output index funding this channel */ -uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); +uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * The ping packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * The specific output index funding this channel */ -void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); /** - * Constructs a new Ping given each field + * The signature of the channel initiator (funder) on the funding transaction */ -MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * Creates a copy of the Ping + * The signature of the channel initiator (funder) on the funding transaction */ -struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); +void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + * Constructs a new FundingCreated given each field */ -void Pong_free(struct LDKPong this_obj); +MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); /** - * The pong packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * Creates a copy of the FundingCreated */ -uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); +struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); /** - * The pong packet size. - * This field is not sent on the wire. byteslen zeros are sent. + * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. */ -void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); +void FundingSigned_free(struct LDKFundingSigned this_obj); /** - * Constructs a new Pong given each field + * The channel ID */ -MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); +const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the Pong + * The channel ID */ -struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); +void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + * The signature of the channel acceptor (fundee) on the funding transaction */ -void OpenChannel_free(struct LDKOpenChannel this_obj); +struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain where the channel is to be opened + * The signature of the channel acceptor (fundee) on the funding transaction */ -const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The genesis hash of the blockchain where the channel is to be opened + * Constructs a new FundingSigned given each field */ -void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); /** - * A temporary channel ID, until the funding outpoint is announced + * Creates a copy of the FundingSigned */ -const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding outpoint is announced + * Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL. */ -void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void FundingLocked_free(struct LDKFundingLocked this_obj); /** - * The channel value + * The channel ID */ -uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +const uint8_t (*FundingLocked_get_channel_id(const struct LDKFundingLocked *NONNULL_PTR this_ptr))[32]; /** - * The channel value + * The channel ID */ -void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void FundingLocked_set_channel_id(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * The per-commitment point of the second commitment transaction */ -uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDKFundingLocked *NONNULL_PTR this_ptr); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * The per-commitment point of the second commitment transaction */ -void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Constructs a new FundingLocked given each field */ -uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Creates a copy of the FundingLocked */ -void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKFundingLocked FundingLocked_clone(const struct LDKFundingLocked *NONNULL_PTR orig); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. */ -uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void Shutdown_free(struct LDKShutdown this_obj); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * The channel ID */ -void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * The channel ID */ -uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * The destination of this peer's funds on closing. + * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. */ -void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * The destination of this peer's funds on closing. + * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. */ -uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Constructs a new Shutdown given each field */ -void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); /** - * The feerate per 1000-weight of sender generated transactions, until updated by update_fee + * Creates a copy of the Shutdown */ -uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); /** - * The feerate per 1000-weight of sender generated transactions, until updated by update_fee + * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. */ -void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); +void ClosingSigned_free(struct LDKClosingSigned this_obj); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The channel ID */ -uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The channel ID */ -void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The maximum number of inbound HTLCs towards sender + * The proposed total fee for the closing transaction */ -uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards sender + * The proposed total fee for the closing transaction */ -void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); /** - * The sender's key controlling the funding transaction + * A signature on the closing transaction */ -struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * The sender's key controlling the funding transaction + * A signature on the closing transaction */ -void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Constructs a new ClosingSigned given each field */ -struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Creates a copy of the ClosingSigned */ -void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); /** - * A payment key to sender for transactions broadcast by counterparty + * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); /** - * A payment key to sender for transactions broadcast by counterparty + * The channel ID */ -void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Used to derive a payment key to sender for transactions broadcast by sender + * The channel ID */ -struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * The HTLC ID */ -void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Used to derive an HTLC payment key to sender + * The HTLC ID */ -struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Used to derive an HTLC payment key to sender + * The HTLC value in milli-satoshi */ -void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The HTLC value in milli-satoshi */ -struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The payment hash, the pre-image of which controls HTLC redemption */ -void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Channel flags + * The payment hash, the pre-image of which controls HTLC redemption */ -uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Channel flags + * The expiry height of the HTLC */ -void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); +uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Creates a copy of the OpenChannel + * The expiry height of the HTLC */ -struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); +void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + * Creates a copy of the UpdateAddHTLC */ -void AcceptChannel_free(struct LDKAcceptChannel this_obj); +struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding outpoint is announced + * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. */ -const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); /** - * A temporary channel ID, until the funding outpoint is announced + * The channel ID */ -void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The channel ID */ -uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The HTLC ID */ -void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * The HTLC ID */ -uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * The pre-image of the payment hash, allowing HTLC redemption */ -void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * The pre-image of the payment hash, allowing HTLC redemption */ -uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Constructs a new UpdateFulfillHTLC given each field */ -void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Creates a copy of the UpdateFulfillHTLC */ -uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. */ -void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); /** - * Minimum depth of the funding transaction before the channel is considered open + * The channel ID */ -uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; /** - * Minimum depth of the funding transaction before the channel is considered open + * The channel ID */ -void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t val); +void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The HTLC ID */ -uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The HTLC ID */ -void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * The maximum number of inbound HTLCs towards sender + * Creates a copy of the UpdateFailHTLC */ -uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); /** - * The maximum number of inbound HTLCs towards sender + * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. */ -void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); /** - * The sender's key controlling the funding transaction + * The channel ID */ -struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; /** - * The sender's key controlling the funding transaction + * The channel ID */ -void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The HTLC ID */ -struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The HTLC ID */ -void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * A payment key to sender for transactions broadcast by counterparty + * The failure code */ -struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * A payment key to sender for transactions broadcast by counterparty + * The failure code */ -void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Creates a copy of the UpdateFailMalformedHTLC */ -struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. */ -void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * The channel ID */ -struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * The channel ID */ -void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * A signature on the commitment transaction */ -struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * A signature on the commitment transaction */ -void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Creates a copy of the AcceptChannel + * Signatures on the HTLC transactions */ -struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); +void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); /** - * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + * Constructs a new CommitmentSigned given each field */ -void FundingCreated_free(struct LDKFundingCreated this_obj); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); /** - * A temporary channel ID, until the funding is established + * Creates a copy of the CommitmentSigned */ -const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding is established + * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. */ -void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); /** - * The funding transaction ID + * The channel ID */ -const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * The funding transaction ID + * The channel ID */ -void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The specific output index funding this channel + * The secret corresponding to the per-commitment point */ -uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * The specific output index funding this channel + * The secret corresponding to the per-commitment point */ -void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); +void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The signature of the channel initiator (funder) on the funding transaction + * The next sender-broadcast commitment transaction's per-commitment point */ -struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * The signature of the channel initiator (funder) on the funding transaction + * The next sender-broadcast commitment transaction's per-commitment point */ -void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); +void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new FundingCreated given each field + * Constructs a new RevokeAndACK given each field */ -MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); +MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); /** - * Creates a copy of the FundingCreated + * Creates a copy of the RevokeAndACK */ -struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); +struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); /** - * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. */ -void FundingSigned_free(struct LDKFundingSigned this_obj); +void UpdateFee_free(struct LDKUpdateFee this_obj); /** * The channel ID */ -const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; +const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; /** * The channel ID */ -void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The signature of the channel acceptor (fundee) on the funding transaction + * Fee rate per 1000-weight of the transaction */ -struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); +uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * The signature of the channel acceptor (fundee) on the funding transaction + * Fee rate per 1000-weight of the transaction */ -void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new FundingSigned given each field + * Constructs a new UpdateFee given each field */ -MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); +MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); /** - * Creates a copy of the FundingSigned + * Creates a copy of the UpdateFee */ -struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); +struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); /** - * Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL. + * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. */ -void FundingLocked_free(struct LDKFundingLocked this_obj); +void DataLossProtect_free(struct LDKDataLossProtect this_obj); /** - * The channel ID + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -const uint8_t (*FundingLocked_get_channel_id(const struct LDKFundingLocked *NONNULL_PTR this_ptr))[32]; +const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const struct LDKDataLossProtect *NONNULL_PTR this_ptr))[32]; /** - * The channel ID + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -void FundingLocked_set_channel_id(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void DataLossProtect_set_your_last_per_commitment_secret(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The per-commitment point of the second commitment transaction + * The sender's per-commitment point for their current commitment transaction */ -struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDKFundingLocked *NONNULL_PTR this_ptr); +struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const struct LDKDataLossProtect *NONNULL_PTR this_ptr); /** - * The per-commitment point of the second commitment transaction + * The sender's per-commitment point for their current commitment transaction */ -void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new FundingLocked given each field + * Constructs a new DataLossProtect given each field */ -MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg); +MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); /** - * Creates a copy of the FundingLocked + * Creates a copy of the DataLossProtect */ -struct LDKFundingLocked FundingLocked_clone(const struct LDKFundingLocked *NONNULL_PTR orig); +struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); /** - * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. */ -void Shutdown_free(struct LDKShutdown this_obj); +void ChannelReestablish_free(struct LDKChannelReestablish this_obj); /** * The channel ID */ -const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; +const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; /** * The channel ID */ -void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The destination of this peer's funds on closing. - * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. + * The next commitment number for the sender */ -struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); +uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The destination of this peer's funds on closing. - * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. + * The next commitment number for the sender */ -void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new Shutdown given each field + * The next commitment number for the recipient */ -MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); +uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Creates a copy of the Shutdown + * The next commitment number for the recipient */ -struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); +void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelReestablish */ -void ClosingSigned_free(struct LDKClosingSigned this_obj); +struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); /** - * The channel ID + * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. */ -const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); /** * The channel ID */ -void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); - -/** - * The proposed total fee for the closing transaction - */ -uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); - -/** - * The proposed total fee for the closing transaction - */ -void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; /** - * A signature on the closing transaction + * The channel ID */ -struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * A signature on the closing transaction + * The short channel ID */ -void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Constructs a new ClosingSigned given each field + * The short channel ID */ -MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg); +void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ClosingSigned + * A signature by the node key */ -struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); +struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. + * A signature by the node key */ -void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); +void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The channel ID + * A signature by the funding key */ -const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The channel ID + * A signature by the funding key */ -void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The HTLC ID + * Constructs a new AnnouncementSignatures given each field */ -uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); /** - * The HTLC ID + * Creates a copy of the AnnouncementSignatures */ -void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); /** - * The HTLC value in milli-satoshi + * Frees any resources used by the NetAddress */ -uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +void NetAddress_free(struct LDKNetAddress this_ptr); /** - * The HTLC value in milli-satoshi + * Creates a copy of the NetAddress */ -void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); /** - * The payment hash, the pre-image of which controls HTLC redemption + * Serialize the NetAddress object into a byte array which can be read by NetAddress_read */ -const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); /** - * The payment hash, the pre-image of which controls HTLC redemption + * Read a Result from a byte array, created by Result_write */ -void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser); /** - * The expiry height of the HTLC + * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. */ -uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); /** - * The expiry height of the HTLC + * The advertised features */ -void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); +struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the UpdateAddHTLC + * The advertised features */ -struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); +void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. + * A strictly monotonic announcement counter, with gaps allowed */ -void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); +uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID + * A strictly monotonic announcement counter, with gaps allowed */ -const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * The node_id this announcement originated from (don't rebroadcast the node_announcement back + * to this node). */ -void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The HTLC ID + * The node_id this announcement originated from (don't rebroadcast the node_announcement back + * to this node). */ -uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); +void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The HTLC ID + * An RGB color for UI purposes */ -void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; /** - * The pre-image of the payment hash, allowing HTLC redemption + * An RGB color for UI purposes */ -const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * The pre-image of the payment hash, allowing HTLC redemption + * An alias, for UI purposes. This should be sanitized before use. There is no guarantee + * of uniqueness. */ -void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new UpdateFulfillHTLC given each field + * An alias, for UI purposes. This should be sanitized before use. There is no guarantee + * of uniqueness. */ -MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the UpdateFulfillHTLC + * List of addresses on which this node is reachable */ -struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); +void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); /** - * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. + * Creates a copy of the UnsignedNodeAnnouncement */ -void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); /** - * The channel ID + * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. */ -const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); /** - * The channel ID + * The signature by the node key */ -void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The HTLC ID + * The signature by the node key */ -uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); +void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The HTLC ID + * The actual content of the announcement */ -void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the UpdateFailHTLC + * The actual content of the announcement */ -struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); +void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); /** - * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. + * Constructs a new NodeAnnouncement given each field */ -void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); /** - * The channel ID + * Creates a copy of the NodeAnnouncement */ -const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); /** - * The channel ID + * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); /** - * The HTLC ID + * The advertised channel features */ -uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The HTLC ID + * The advertised channel features */ -void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * The failure code + * The genesis hash of the blockchain where the channel is to be opened */ -uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * The failure code + * The genesis hash of the blockchain where the channel is to be opened */ -void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the UpdateFailMalformedHTLC + * The short channel ID */ -struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); +uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. + * The short channel ID */ -void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); +void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel ID + * One of the two node_ids which are endpoints of this channel */ -const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID + * One of the two node_ids which are endpoints of this channel */ -void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * A signature on the commitment transaction + * The other of the two node_ids which are endpoints of this channel */ -struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * A signature on the commitment transaction + * The other of the two node_ids which are endpoints of this channel */ -void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Signatures on the HTLC transactions + * The funding key for the first node */ -void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new CommitmentSigned given each field + * The funding key for the first node */ -MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); +void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the CommitmentSigned + * The funding key for the second node */ -struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); +struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. + * The funding key for the second node */ -void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); +void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The channel ID + * Creates a copy of the UnsignedChannelAnnouncement */ -const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); /** - * The channel ID + * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); /** - * The secret corresponding to the per-commitment point + * Authentication of the announcement by the first public node */ -const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The secret corresponding to the per-commitment point + * Authentication of the announcement by the first public node */ -void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Authentication of the announcement by the second public node */ -struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); +struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Authentication of the announcement by the second public node */ -void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Constructs a new RevokeAndACK given each field + * Proof of funding UTXO ownership by the first public node */ -MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the RevokeAndACK + * Proof of funding UTXO ownership by the first public node */ -struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); +void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. + * Proof of funding UTXO ownership by the second public node */ -void UpdateFee_free(struct LDKUpdateFee this_obj); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel ID + * Proof of funding UTXO ownership by the second public node */ -const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; +void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The channel ID + * The actual announcement */ -void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Fee rate per 1000-weight of the transaction + * The actual announcement */ -uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); /** - * Fee rate per 1000-weight of the transaction + * Constructs a new ChannelAnnouncement given each field */ -void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); /** - * Constructs a new UpdateFee given each field + * Creates a copy of the ChannelAnnouncement */ -MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); +struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); /** - * Creates a copy of the UpdateFee + * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. */ -struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); /** - * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain where the channel is to be opened */ -void DataLossProtect_free(struct LDKDataLossProtect this_obj); +const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * The genesis hash of the blockchain where the channel is to be opened */ -const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const struct LDKDataLossProtect *NONNULL_PTR this_ptr))[32]; +void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * The short channel ID */ -void DataLossProtect_set_your_last_per_commitment_secret(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The sender's per-commitment point for their current commitment transaction + * The short channel ID */ -struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const struct LDKDataLossProtect *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * The sender's per-commitment point for their current commitment transaction + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new DataLossProtect given each field + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); +void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the DataLossProtect + * Channel flags */ -struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); +uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. + * Channel flags */ -void ChannelReestablish_free(struct LDKChannelReestablish this_obj); +void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * The channel ID + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines + * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a + * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, + * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; +uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines + * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a + * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, + * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); /** - * The next commitment number for the sender + * The minimum HTLC size incoming to sender, in milli-satoshi */ -uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The next commitment number for the sender + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * The next commitment number for the recipient + * The base HTLC fee charged by sender, in milli-satoshi */ -uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The next commitment number for the recipient + * The base HTLC fee charged by sender, in milli-satoshi */ -void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the ChannelReestablish + * The amount to fee multiplier, in micro-satoshi */ -struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); +uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. + * The amount to fee multiplier, in micro-satoshi */ -void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); +void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The channel ID + * Creates a copy of the UnsignedChannelUpdate */ -const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); /** - * The channel ID + * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. */ -void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelUpdate_free(struct LDKChannelUpdate this_obj); /** - * The short channel ID + * A signature of the channel update */ -uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * The short channel ID + * A signature of the channel update */ -void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); +void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * A signature by the node key + * The actual channel update */ -struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * A signature by the node key + * The actual channel update */ -void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); /** - * A signature by the funding key + * Constructs a new ChannelUpdate given each field */ -struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); /** - * A signature by the funding key + * Creates a copy of the ChannelUpdate */ -void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); /** - * Constructs a new AnnouncementSignatures given each field + * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); +void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); /** - * Creates a copy of the AnnouncementSignatures + * The genesis hash of the blockchain being queried */ -struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the NetAddress + * The genesis hash of the blockchain being queried */ -void NetAddress_free(struct LDKNetAddress this_ptr); +void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the NetAddress + * The height of the first block for the channel UTXOs being queried */ -struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); +uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * Serialize the NetAddress object into a byte array which can be read by NetAddress_read + * The height of the first block for the channel UTXOs being queried */ -struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); +void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Read a Result from a byte array, created by Result_write + * The number of blocks to include in the query results */ -struct LDKCResult_CResult_NetAddressu8ZDecodeErrorZ Result_read(struct LDKu8slice ser); +uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. + * The number of blocks to include in the query results */ -void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); +void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * The advertised features + * Constructs a new QueryChannelRange given each field */ -struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); /** - * The advertised features + * Creates a copy of the QueryChannelRange */ -void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); /** - * A strictly monotonic announcement counter, with gaps allowed + * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. */ -uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); /** - * A strictly monotonic announcement counter, with gaps allowed + * The genesis hash of the blockchain being queried */ -void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); +const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The node_id this announcement originated from (don't rebroadcast the node_announcement back - * to this node). + * The genesis hash of the blockchain being queried */ -struct LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The node_id this announcement originated from (don't rebroadcast the node_announcement back - * to this node). + * The height of the first block in the range of the reply */ -void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * An RGB color for UI purposes + * The height of the first block in the range of the reply */ -const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; +void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * An RGB color for UI purposes + * The number of blocks included in the range of the reply */ -void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * An alias, for UI purposes. This should be sanitized before use. There is no guarantee - * of uniqueness. + * The number of blocks included in the range of the reply */ -const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[32]; +void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * An alias, for UI purposes. This should be sanitized before use. There is no guarantee - * of uniqueness. + * True when this is the final reply for a query */ -void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * List of addresses on which this node is reachable + * True when this is the final reply for a query */ -void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); +void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); /** - * Creates a copy of the UnsignedNodeAnnouncement + * The short_channel_ids in the channel range */ -struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); +void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. + * Constructs a new ReplyChannelRange given each field */ -void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); +MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * The signature by the node key + * Creates a copy of the ReplyChannelRange */ -struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); /** - * The signature by the node key + * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. */ -void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); /** - * The actual content of the announcement + * The genesis hash of the blockchain being queried */ -struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; /** - * The actual content of the announcement + * The genesis hash of the blockchain being queried */ -void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); +void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new NodeAnnouncement given each field + * The short_channel_ids that are being queried */ -MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); +void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Creates a copy of the NodeAnnouncement + * Constructs a new QueryShortChannelIds given each field */ -struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Creates a copy of the QueryShortChannelIds */ -void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); +struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); /** - * The advertised channel features + * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. */ -struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); /** - * The advertised channel features + * The genesis hash of the blockchain that was queried */ -void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; /** - * The genesis hash of the blockchain where the channel is to be opened + * The genesis hash of the blockchain that was queried */ -const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; +void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The genesis hash of the blockchain where the channel is to be opened + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash */ -void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); /** - * The short channel ID + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash */ -uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); /** - * The short channel ID + * Constructs a new ReplyShortChannelIdsEnd given each field */ -void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); /** - * One of the two node_ids which are endpoints of this channel + * Creates a copy of the ReplyShortChannelIdsEnd */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); /** - * One of the two node_ids which are endpoints of this channel + * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. */ -void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); /** - * The other of the two node_ids which are endpoints of this channel + * The genesis hash of the blockchain for channel and node information */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; /** - * The other of the two node_ids which are endpoints of this channel + * The genesis hash of the blockchain for channel and node information */ -void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The funding key for the first node + * The starting unix timestamp */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The funding key for the first node + * The starting unix timestamp */ -void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * The funding key for the second node + * The range of information in seconds */ -struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The funding key for the second node + * The range of information in seconds */ -void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the UnsignedChannelAnnouncement + * Constructs a new GossipTimestampFilter given each field */ -struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); +MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); /** - * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Creates a copy of the GossipTimestampFilter */ -void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); +struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); /** - * Authentication of the announcement by the first public node + * Frees any resources used by the ErrorAction */ -struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +void ErrorAction_free(struct LDKErrorAction this_ptr); /** - * Authentication of the announcement by the first public node + * Creates a copy of the ErrorAction */ -void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); /** - * Authentication of the announcement by the second public node + * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. */ -struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +void LightningError_free(struct LDKLightningError this_obj); /** - * Authentication of the announcement by the second public node + * A human-readable message describing the error */ -void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * Proof of funding UTXO ownership by the first public node + * A human-readable message describing the error */ -struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Proof of funding UTXO ownership by the first public node + * The action which should be taken against the offending peer. */ -void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * Proof of funding UTXO ownership by the second public node + * The action which should be taken against the offending peer. */ -struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); /** - * Proof of funding UTXO ownership by the second public node + * Constructs a new LightningError given each field */ -void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKCVec_u8Z err_arg, struct LDKErrorAction action_arg); /** - * The actual announcement + * Creates a copy of the LightningError */ -struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); /** - * The actual announcement + * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. */ -void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); /** - * Constructs a new ChannelAnnouncement given each field + * update_add_htlc messages which should be sent */ -MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); +void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); /** - * Creates a copy of the ChannelAnnouncement + * update_fulfill_htlc messages which should be sent */ -struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); +void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); /** - * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. + * update_fail_htlc messages which should be sent */ -void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); +void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); /** - * The genesis hash of the blockchain where the channel is to be opened + * update_fail_malformed_htlc messages which should be sent */ -const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; +void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); /** - * The genesis hash of the blockchain where the channel is to be opened + * An update_fee message which should be sent */ -void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The short channel ID + * An update_fee message which should be sent */ -uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); /** - * The short channel ID + * Finally, the commitment_signed message which should be sent */ -void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Finally, the commitment_signed message which should be sent */ -uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Constructs a new CommitmentUpdate given each field */ -void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); /** - * Channel flags + * Creates a copy of the CommitmentUpdate */ -uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); /** - * Channel flags + * Frees any resources used by the HTLCFailChannelUpdate */ -void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines - * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a - * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, - * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Creates a copy of the HTLCFailChannelUpdate */ -uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines - * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a - * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10, - * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Calls the free function if one is set */ -void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); +void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Calls the free function if one is set */ -uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ -void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Read a AcceptChannel from a byte array, created by AcceptChannel_write */ -uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read */ -void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); /** - * The amount to fee multiplier, in micro-satoshi + * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write */ -uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); /** - * The amount to fee multiplier, in micro-satoshi + * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read */ -void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); /** - * Creates a copy of the UnsignedChannelUpdate + * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write */ -struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); +struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); /** - * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read */ -void ChannelUpdate_free(struct LDKChannelUpdate this_obj); +struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); /** - * A signature of the channel update + * Read a ClosingSigned from a byte array, created by ClosingSigned_write */ -struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); /** - * A signature of the channel update + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read */ -void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); /** - * The actual channel update + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write */ -struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); /** - * The actual channel update + * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read */ -void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); +struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); /** - * Constructs a new ChannelUpdate given each field + * Read a FundingCreated from a byte array, created by FundingCreated_write */ -MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); +struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelUpdate + * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read */ -struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); +struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); /** - * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. + * Read a FundingSigned from a byte array, created by FundingSigned_write */ -void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); +struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain being queried + * Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read */ -const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z FundingLocked_write(const struct LDKFundingLocked *NONNULL_PTR obj); /** - * The genesis hash of the blockchain being queried + * Read a FundingLocked from a byte array, created by FundingLocked_write */ -void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_FundingLockedDecodeErrorZ FundingLocked_read(struct LDKu8slice ser); /** - * The height of the first block for the channel UTXOs being queried + * Serialize the Init object into a byte array which can be read by Init_read */ -uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); /** - * The height of the first block for the channel UTXOs being queried + * Read a Init from a byte array, created by Init_write */ -void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); /** - * The number of blocks to include in the query results + * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read */ -uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); /** - * The number of blocks to include in the query results + * Read a OpenChannel from a byte array, created by OpenChannel_write */ -void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); /** - * Constructs a new QueryChannelRange given each field + * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read */ -MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); +struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); /** - * Creates a copy of the QueryChannelRange + * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write */ -struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); +struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); /** - * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. + * Serialize the Shutdown object into a byte array which can be read by Shutdown_read */ -void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); +struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); /** - * The genesis hash of the blockchain being queried + * Read a Shutdown from a byte array, created by Shutdown_write */ -const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain being queried + * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read */ -void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); /** - * The height of the first block in the range of the reply + * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write */ -uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); /** - * The height of the first block in the range of the reply + * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read */ -void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); /** - * The number of blocks included in the range of the reply + * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write */ -uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); /** - * The number of blocks included in the range of the reply + * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read */ -void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); /** - * True when this is the final reply for a query + * Read a UpdateFee from a byte array, created by UpdateFee_write */ -bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); /** - * True when this is the final reply for a query + * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read */ -void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); /** - * The short_channel_ids in the channel range + * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write */ -void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); /** - * Constructs a new ReplyChannelRange given each field + * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read */ -MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); +struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); /** - * Creates a copy of the ReplyChannelRange + * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write */ -struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); /** - * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. + * Serialize the Ping object into a byte array which can be read by Ping_read */ -void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); +struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); /** - * The genesis hash of the blockchain being queried + * Read a Ping from a byte array, created by Ping_write */ -const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain being queried + * Serialize the Pong object into a byte array which can be read by Pong_read */ -void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); /** - * The short_channel_ids that are being queried + * Read a Pong from a byte array, created by Pong_write */ -void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); /** - * Constructs a new QueryShortChannelIds given each field + * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read */ -MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); /** - * Creates a copy of the QueryShortChannelIds + * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write */ -struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); /** - * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. + * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read */ -void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); +struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); /** - * The genesis hash of the blockchain that was queried + * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write */ -const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain that was queried + * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read */ -void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the chain_hash + * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write */ -bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the chain_hash + * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read */ -void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); /** - * Constructs a new ReplyShortChannelIdsEnd given each field + * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write */ -MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); /** - * Creates a copy of the ReplyShortChannelIdsEnd + * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read */ -struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); +struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); /** - * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. + * Read a ErrorMessage from a byte array, created by ErrorMessage_write */ -void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); +struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain for channel and node information + * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */ -const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); /** - * The genesis hash of the blockchain for channel and node information + * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write */ -void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); /** - * The starting unix timestamp + * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read */ -uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); /** - * The starting unix timestamp + * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write */ -void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); /** - * The range of information in seconds + * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write */ -uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); /** - * The range of information in seconds + * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read */ -void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); /** - * Constructs a new GossipTimestampFilter given each field + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write */ -MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); /** - * Creates a copy of the GossipTimestampFilter + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read */ -struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); /** - * Frees any resources used by the ErrorAction + *\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t */ -void ErrorAction_free(struct LDKErrorAction this_ptr); +MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); /** - * Creates a copy of the ErrorAction + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ -struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); +struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); /** - * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read */ -void LightningError_free(struct LDKLightningError this_obj); +struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); /** - * A human-readable message describing the error + * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write */ -struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); /** - * A human-readable message describing the error + * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read */ -void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); /** - * The action which should be taken against the offending peer. + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write */ -struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); /** - * The action which should be taken against the offending peer. + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read */ -void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); +struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); /** - * Constructs a new LightningError given each field + * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKCVec_u8Z err_arg, struct LDKErrorAction action_arg); +void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); /** - * Creates a copy of the LightningError + * Constructs a new IgnoringMessageHandler given each field */ -struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); +MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); /** - * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); +struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * update_add_htlc messages which should be sent + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); +struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * update_fulfill_htlc messages which should be sent + * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. */ -void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); +void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); /** - * update_fail_htlc messages which should be sent + * Constructs a new ErroringMessageHandler */ -void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); +MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); /** - * update_fail_malformed_htlc messages which should be sent + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); +struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * An update_fee message which should be sent + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * An update_fee message which should be sent + * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. */ -void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); +void MessageHandler_free(struct LDKMessageHandler this_obj); /** - * Finally, the commitment_signed message which should be sent + * A message handler which handles messages specific to channels. Usually this is just a + * ChannelManager object or a ErroringMessageHandler. */ -struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Finally, the commitment_signed message which should be sent + * A message handler which handles messages specific to channels. Usually this is just a + * ChannelManager object or a ErroringMessageHandler. */ -void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); +void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); /** - * Constructs a new CommitmentUpdate given each field + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. */ -MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); +const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Creates a copy of the CommitmentUpdate + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. */ -struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); /** - * Frees any resources used by the HTLCFailChannelUpdate + * Constructs a new MessageHandler given each field */ -void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg); /** - * Creates a copy of the HTLCFailChannelUpdate + * Creates a copy of a SocketDescriptor */ -struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig); +struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); /** * Calls the free function if one is set */ -void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); +void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); /** - * Calls the free function if one is set + * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. */ -void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +void PeerHandleError_free(struct LDKPeerHandleError this_obj); /** - * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read + * Used to indicate that we probably can't make any future connections to this peer, implying + * we should go ahead and force-close any channels we have with it. */ -struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); +bool PeerHandleError_get_no_connection_possible(const struct LDKPeerHandleError *NONNULL_PTR this_ptr); /** - * Read a AcceptChannel from a byte array, created by AcceptChannel_write + * Used to indicate that we probably can't make any future connections to this peer, implying + * we should go ahead and force-close any channels we have with it. */ -struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); +void PeerHandleError_set_no_connection_possible(struct LDKPeerHandleError *NONNULL_PTR this_ptr, bool val); /** - * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read + * Constructs a new PeerHandleError given each field */ -struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); /** - * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write + * Creates a copy of the PeerHandleError */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); +struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); /** - * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read + * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); +void PeerManager_free(struct LDKPeerManager this_obj); /** - * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write + * Constructs a new PeerManager with the given message handlers and node_id secret key + * ephemeral_random_data is used to derive per-connection ephemeral keys and must be + * cryptographically secure random bytes. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger); /** - * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + * Get the list of node ids for peers which have completed the initial handshake. + * + * For outbound connections, this will be the same as the their_node_id parameter passed in to + * new_outbound_connection, however entries will only appear once the initial handshake has + * completed and we are sure the remote peer has the private key for the given node_id. */ -struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); +MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Read a ClosingSigned from a byte array, created by ClosingSigned_write + * Indicates a new outbound connection has been established to a node with the given node_id. + * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new + * descriptor but must disconnect the connection immediately. + * + * Returns a small number of bytes to send to the remote node (currently always 50). + * + * Panics if descriptor is duplicative with some other descriptor which has not yet had a + * socket_disconnected(). */ -struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor); /** - * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + * Indicates a new inbound connection has been established. + * + * May refuse the connection by returning an Err, but will never write bytes to the remote end + * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT + * call socket_disconnected for the new descriptor but must disconnect the connection + * immediately. + * + * Panics if descriptor is duplicative with some other descriptor which has not yet had + * socket_disconnected called. */ -struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor); /** - * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + * Indicates that there is room to write data to the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * Will most likely call send_data on the descriptor passed in (or the descriptor handed into + * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The + * invariants around calling write_buffer_space_avail in case a write did not fully complete + * must still hold - be ready to call write_buffer_space_avail again if a write call generated + * here isn't sufficient! Panics if the descriptor was not previously registered in a + * new_\\*_connection event. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read + * Indicates that data was read from the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity. + * Thus, however, you almost certainly want to call process_events() after any read_event to + * generate send_data calls to handle responses. + * + * If Ok(true) is returned, further read_events should not be triggered until a send_data call + * on this file descriptor has resume_read set (preventing DoS issues in the send buffer). + * + * Panics if the descriptor was not previously registered in a new_*_connection event. */ -struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); /** - * Read a FundingCreated from a byte array, created by FundingCreated_write + * Checks for any events generated by our handlers and processes them. Includes sending most + * response messages as well as messages generated by calls to handler functions directly (eg + * functions like ChannelManager::process_pending_htlc_forward or send_payment). */ -struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); +void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read + * Indicates that the given socket descriptor's connection is now closed. + * + * This must only be called if the socket has been disconnected by the peer or your own + * decision to disconnect it and must NOT be called in any case where other parts of this + * library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect + * the peer. + * + * Panics if the descriptor was not previously registered in a successful new_*_connection event. */ -struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); +void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * Read a FundingSigned from a byte array, created by FundingSigned_write + * Disconnect a peer given its node id. + * + * Set no_connection_possible to true to prevent any further connection with this peer, + * force-closing any channels we have with it. + * + * If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, + * so be careful about reentrancy issues. */ -struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); +void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible); /** - * Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read + * This function should be called roughly once every 30 seconds. + * It will send pings to each peer and disconnect those which did not respond to the last round of pings. + * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues! */ -struct LDKCVec_u8Z FundingLocked_write(const struct LDKFundingLocked *NONNULL_PTR obj); +void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Read a FundingLocked from a byte array, created by FundingLocked_write + * Build the commitment secret from the seed and the commitment number */ -struct LDKCResult_FundingLockedDecodeErrorZ FundingLocked_read(struct LDKu8slice ser); +struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); /** - * Serialize the Init object into a byte array which can be read by Init_read + * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) + * from the base secret and the per_commitment_point. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); +struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); /** - * Read a Init from a byte array, created by Init_write + * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) + * from the base point and the per_commitment_key. This is the public equivalent of + * derive_private_key - using only public keys to derive a public key instead of private keys. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); +struct LDKCResult_PublicKeyErrorZ derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); /** - * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read + * Derives a per-commitment-transaction revocation key from its constituent parts. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_secret always come from cheater + * and revocation_base_secret always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); +struct LDKCResult_SecretKeyErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); /** - * Read a OpenChannel from a byte array, created by OpenChannel_write + * Derives a per-commitment-transaction revocation public key from its constituent parts. This is + * the public equivalend of derive_private_revocation_key - using only public keys to derive a + * public key instead of private keys. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_point always come from cheater + * and revocation_base_point always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); +struct LDKCResult_PublicKeyErrorZ derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); /** - * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read + * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); +void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); /** - * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); +struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Serialize the Shutdown object into a byte array which can be read by Shutdown_read + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); +void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a Shutdown from a byte array, created by Shutdown_write + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); +struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); +void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write + * Broadcaster's HTLC Key */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); +struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read + * Broadcaster's HTLC Key */ -struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); +void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write + * Countersignatory's HTLC Key */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); +struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read + * Countersignatory's HTLC Key */ -struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); +void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a UpdateFee from a byte array, created by UpdateFee_write + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); +struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); +void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write + * Constructs a new TxCreationKeys given each field */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); /** - * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read + * Creates a copy of the TxCreationKeys */ -struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); +struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); /** - * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write + * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); /** - * Serialize the Ping object into a byte array which can be read by Ping_read + * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write */ -struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); +struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); /** - * Read a Ping from a byte array, created by Ping_write + * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); /** - * Serialize the Pong object into a byte array which can be read by Pong_read + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a Pong from a byte array, created by Pong_write + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read + * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write + * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read + * Constructs a new ChannelPublicKeys given each field */ -struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); /** - * Read a ErrorMessage from a byte array, created by ErrorMessage_write + * Creates a copy of the ChannelPublicKeys */ -struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); /** - * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read + * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); +struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); /** - * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write + * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); /** - * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read + * Create per-state keys from channel base points and the per-commitment point. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); /** - * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write + * Generate per-state keys from channel static keys. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write + * A script either spendable by the revocation + * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. + * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); +struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); /** - * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read + * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); /** - * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); +bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); /** - *\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); +uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); +void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + * The CLTV lock-time at which this HTLC expires. */ -struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); +uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write + * The CLTV lock-time at which this HTLC expires. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); +void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); /** - * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read + * The hash of the preimage which unlocks this HTLC. */ -struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); +const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; /** - * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + * The hash of the preimage which unlocks this HTLC. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); +void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); +struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); +void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Constructs a new IgnoringMessageHandler given each field + * Constructs a new HTLCOutputInCommitment given each field */ -MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); +MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Creates a copy of the HTLCOutputInCommitment */ -struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ -struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); /** - * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. + * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write */ -void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); /** - * Constructs a new ErroringMessageHandler + * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc + * does not need to have its previous_output_index filled. */ -MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); +struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKTxCreationKeys *NONNULL_PTR keys); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Gets the redeemscript for a funding output from the two funding public keys. + * Note that the order of funding public keys does not matter. */ -struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * panics if htlc.transaction_output_index.is_none()! */ -struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +struct LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); /** - * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -void MessageHandler_free(struct LDKMessageHandler this_obj); +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); /** - * A message handler which handles messages specific to channels. Usually this is just a - * ChannelManager object or a ErroringMessageHandler. + * Holder public keys */ -const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * A message handler which handles messages specific to channels. Usually this is just a - * ChannelManager object or a ErroringMessageHandler. + * Holder public keys */ -void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); +void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Constructs a new MessageHandler given each field + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg); +bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of a SocketDescriptor + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); +void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); /** - * Calls the free function if one is set + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. */ -void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); +struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. */ -void PeerHandleError_free(struct LDKPeerHandleError this_obj); +void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); /** - * Used to indicate that we probably can't make any future connections to this peer, implying - * we should go ahead and force-close any channels we have with it. + * The late-bound funding outpoint */ -bool PeerHandleError_get_no_connection_possible(const struct LDKPeerHandleError *NONNULL_PTR this_ptr); +struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Used to indicate that we probably can't make any future connections to this peer, implying - * we should go ahead and force-close any channels we have with it. + * The late-bound funding outpoint */ -void PeerHandleError_set_no_connection_possible(struct LDKPeerHandleError *NONNULL_PTR this_ptr, bool val); +void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Constructs a new PeerHandleError given each field + * Constructs a new ChannelTransactionParameters given each field */ -MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); +MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg); /** - * Creates a copy of the PeerHandleError + * Creates a copy of the ChannelTransactionParameters */ -struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); +struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); /** - * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. + * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -void PeerManager_free(struct LDKPeerManager this_obj); +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); /** - * Constructs a new PeerManager with the given message handlers and node_id secret key - * ephemeral_random_data is used to derive per-connection ephemeral keys and must be - * cryptographically secure random bytes. + * Counter-party public keys */ -MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger); +struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Get the list of node ids for peers which have completed the initial handshake. - * - * For outbound connections, this will be the same as the their_node_id parameter passed in to - * new_outbound_connection, however entries will only appear once the initial handshake has - * completed and we are sure the remote peer has the private key for the given node_id. + * Counter-party public keys */ -MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); +void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Indicates a new outbound connection has been established to a node with the given node_id. - * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new - * descriptor but must disconnect the connection immediately. - * - * Returns a small number of bytes to send to the remote node (currently always 50). - * - * Panics if descriptor is duplicative with some other descriptor which has not yet had a - * socket_disconnected(). + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor); +uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Indicates a new inbound connection has been established. - * - * May refuse the connection by returning an Err, but will never write bytes to the remote end - * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT - * call socket_disconnected for the new descriptor but must disconnect the connection - * immediately. - * - * Panics if descriptor is duplicative with some other descriptor which has not yet had - * socket_disconnected called. + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor); +void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Indicates that there is room to write data to the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * Will most likely call send_data on the descriptor passed in (or the descriptor handed into - * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The - * invariants around calling write_buffer_space_avail in case a write did not fully complete - * must still hold - be ready to call write_buffer_space_avail again if a write call generated - * here isn't sufficient! Panics if the descriptor was not previously registered in a - * new_\\*_connection event. + * Constructs a new CounterpartyChannelTransactionParameters given each field */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); /** - * Indicates that data was read from the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity. - * Thus, however, you almost certainly want to call process_events() after any read_event to - * generate send_data calls to handle responses. - * - * If Ok(true) is returned, further read_events should not be triggered until a send_data call - * on this file descriptor has resume_read set (preventing DoS issues in the send buffer). - * - * Panics if the descriptor was not previously registered in a new_*_connection event. + * Creates a copy of the CounterpartyChannelTransactionParameters */ -MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); /** - * Checks for any events generated by our handlers and processes them. Includes sending most - * response messages as well as messages generated by calls to handler functions directly (eg - * functions like ChannelManager::process_pending_htlc_forward or send_payment). + * Whether the late bound parameters are populated. */ -void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Indicates that the given socket descriptor's connection is now closed. - * - * This must only be called if the socket has been disconnected by the peer or your own - * decision to disconnect it and must NOT be called in any case where other parts of this - * library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect - * the peer. + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the holder is the broadcaster. * - * Panics if the descriptor was not previously registered in a successful new_*_connection event. + * self.is_populated() must be true before calling this function. */ -void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Disconnect a peer given its node id. - * - * Set no_connection_possible to true to prevent any further connection with this peer, - * force-closing any channels we have with it. + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the counterparty is the broadcaster. * - * If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, - * so be careful about reentrancy issues. + * self.is_populated() must be true before calling this function. */ -void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * This function should be called roughly once every 30 seconds. - * It will send pings to each peer and disconnect those which did not respond to the last round of pings. - * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues! + * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read */ -void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); /** - * Build the commitment secret from the seed and the commitment number + * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write */ -struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) - * from the base secret and the per_commitment_point. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read */ -struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); +struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); /** - * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) - * from the base point and the per_commitment_key. This is the public equivalent of - * derive_private_key - using only public keys to derive a public key instead of private keys. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write */ -struct LDKCResult_PublicKeyErrorZ derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Derives a per-commitment-transaction revocation key from its constituent parts. - * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_secret always come from cheater - * and revocation_base_secret always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_SecretKeyErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); /** - * Derives a per-commitment-transaction revocation public key from its constituent parts. This is - * the public equivalend of derive_private_revocation_key - using only public keys to derive a - * public key instead of private keys. - * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_point always come from cheater - * and revocation_base_point always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * Get the channel pubkeys for the broadcaster */ -struct LDKCResult_PublicKeyErrorZ derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. + * Get the channel pubkeys for the countersignatory */ -void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Get the contest delay applicable to the transactions. + * Note that the contest delay was selected by the countersignatory. */ -struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Whether the channel is outbound from the broadcaster. + * + * The boolean representing the side that initiated the channel is + * an input to the commitment number obscure factor computation. */ -void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * The funding outpoint */ -struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); /** - * Broadcaster's HTLC Key + * Our counterparty's signature for the transaction */ -struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Broadcaster's HTLC Key + * Our counterparty's signature for the transaction */ -void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Countersignatory's HTLC Key + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction */ -struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); /** - * Countersignatory's HTLC Key + * Creates a copy of the HolderCommitmentTransaction */ -void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read */ -struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write */ -void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); /** - * Constructs a new TxCreationKeys given each field + * Create a new holder transaction with the given counterparty signatures. + * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); +MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); /** - * Creates a copy of the TxCreationKeys + * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); /** - * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read + * The commitment transaction */ -struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); +struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write + * The commitment transaction */ -struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); +void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); /** - * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); +const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Constructs a new BuiltCommitmentTransaction given each field */ -void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * Creates a copy of the BuiltCommitmentTransaction */ -struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read */ -void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write */ -struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. */ -void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. */ -struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Creates a copy of the CommitmentTransaction */ -struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read */ -void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); /** - * Constructs a new ChannelPublicKeys given each field + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write */ -MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelPublicKeys + * The backwards-counting commitment number */ -struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read + * The value to be sent to the broadcaster */ -struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); +MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write + * The value to be sent to the counterparty */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); +MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Create per-state keys from channel base points and the per-commitment point. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * The feerate paid per 1000-weight-unit in this commitment transaction. */ -MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); +MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Generate per-state keys from channel static keys. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Trust our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * This should only be used if you fully trust the builder of this object. It should not + *\tbe used by an external signer - instead use the verify function. */ -MUST_USE_RES struct LDKCResult_TxCreationKeysErrorZ TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * A script either spendable by the revocation - * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. - * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. + * Verify our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); +MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. + * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * The transaction ID of the built Bitcoin transaction */ -bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * The pre-built Bitcoin commitment transaction */ -void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * The pre-calculated transaction creation public keys. */ -uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Get a signature for each HTLC which was included in the commitment transaction (ie for + * which HTLCOutputInCommitment::transaction_output_index.is_some()). + * + * The returned Vec has one entry for each HTLC, and in the same order. */ -void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters); /** - * The CLTV lock-time at which this HTLC expires. + * Get the transaction number obscure factor */ -uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); /** - * The CLTV lock-time at which this HTLC expires. + * Creates a copy of the InitFeatures */ -void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); +struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); /** - * The hash of the preimage which unlocks this HTLC. + * Creates a copy of the NodeFeatures */ -const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; +struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); /** - * The hash of the preimage which unlocks this HTLC. + * Creates a copy of the ChannelFeatures */ -void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * Creates a copy of the InvoiceFeatures */ -struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ -void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +void InitFeatures_free(struct LDKInitFeatures this_obj); /** - * Constructs a new HTLCOutputInCommitment given each field + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); +void NodeFeatures_free(struct LDKNodeFeatures this_obj); /** - * Creates a copy of the HTLCOutputInCommitment + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); /** - * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read + * Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); +void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); /** - * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write + * Create a blank Features with no features set */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc - * does not need to have its previous_output_index filled. + * Creates a Features with the bits set which are known by the implementation */ -struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKTxCreationKeys *NONNULL_PTR keys); +MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); /** - * Gets the redeemscript for a funding output from the two funding public keys. - * Note that the order of funding public keys does not matter. + * Create a blank Features with no features set */ -struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * panics if htlc.transaction_output_index.is_none()! + * Creates a Features with the bits set which are known by the implementation */ -struct LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); /** - * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Create a blank Features with no features set */ -void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Holder public keys + * Creates a Features with the bits set which are known by the implementation */ -struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); /** - * Holder public keys + * Create a blank Features with no features set */ -void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Creates a Features with the bits set which are known by the implementation */ -uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read */ -void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ -void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. + * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read */ -struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** - * The late-bound funding outpoint + * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ -struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * The late-bound funding outpoint + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * Constructs a new ChannelTransactionParameters given each field + * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write */ -MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg); +struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelTransactionParameters + * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. */ -struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); +void RouteHop_free(struct LDKRouteHop this_obj); /** - * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * The node_id of the node at this hop. */ -void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); +struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Counter-party public keys + * The node_id of the node at this hop. */ -struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Counter-party public keys + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * The channel that should be used from the previous hop to reach this node. */ -void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Constructs a new CounterpartyChannelTransactionParameters given each field + * The channel that should be used from the previous hop to reach this node. */ -MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); +void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the CounterpartyChannelTransactionParameters + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); +struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Whether the late bound parameters are populated. + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the holder is the broadcaster. - * - * self.is_populated() must be true before calling this function. + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * For the last hop, this should be the full value of the payment (might be more than + * requested if we had to match htlc_minimum_msat). */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the counterparty is the broadcaster. - * - * self.is_populated() must be true before calling this function. + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * For the last hop, this should be the full value of the payment (might be more than + * requested if we had to match htlc_minimum_msat). */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read + * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value + * expected at the destination, in excess of the current block height. */ -struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); +uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write + * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value + * expected at the destination, in excess of the current block height. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); +void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); /** - * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read + * Constructs a new RouteHop given each field */ -struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); +MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); /** - * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write + * Creates a copy of the RouteHop */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); +struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); /** - * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. */ -void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); +void Route_free(struct LDKRoute this_obj); /** - * Get the channel pubkeys for the broadcaster + * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the + * last RouteHop in each path must be the same. + * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the + * destination. Thus, this must always be at least length one. While the maximum length of any + * given path is variable, keeping the length of any path to less than 20 should currently + * ensure it is viable. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); /** - * Get the channel pubkeys for the countersignatory + * Constructs a new Route given each field */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg); /** - * Get the contest delay applicable to the transactions. - * Note that the contest delay was selected by the countersignatory. + * Creates a copy of the Route */ -MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); /** - * Whether the channel is outbound from the broadcaster. - * - * The boolean representing the side that initiated the channel is - * an input to the commitment number obscure factor computation. + * Serialize the Route object into a byte array which can be read by Route_read */ -MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); /** - * The funding outpoint + * Read a Route from a byte array, created by Route_write */ -MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); /** - * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. */ -void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); +void RouteHintHop_free(struct LDKRouteHintHop this_obj); /** - * Our counterparty's signature for the transaction + * The node_id of the non-target end of the route */ -struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Our counterparty's signature for the transaction + * The node_id of the non-target end of the route */ -void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); +void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * The short_channel_id of this channel */ -void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the HolderCommitmentTransaction + * The short_channel_id of this channel */ -struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); +void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read + * The fees which must be paid to use this channel */ -struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); +struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write + * The fees which must be paid to use this channel */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); +void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Create a new holder transaction with the given counterparty signatures. - * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. + * The difference in CLTV values between this node and the next node. */ -MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); +uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. + * The difference in CLTV values between this node and the next node. */ -void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); +void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); /** - * The commitment transaction + * The minimum value, in msat, which must be relayed to the next hop. */ -struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The commitment transaction + * The minimum value, in msat, which must be relayed to the next hop. */ -void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); +void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * The maximum value in msat available for routing with a single HTLC. */ -const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; +struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * The maximum value in msat available for routing with a single HTLC. */ -void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Constructs a new BuiltCommitmentTransaction given each field + * Constructs a new RouteHintHop given each field */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); +MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); /** - * Creates a copy of the BuiltCommitmentTransaction + * Creates a copy of the RouteHintHop */ -struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); +struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); /** - * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read + * Gets a route from us (payer) to the given target node (payee). + * + * If the payee provided features in their invoice, they should be provided via payee_features. + * Without this, MPP will only be used if the payee's features are available in the network graph. + * + * Extra routing hops between known nodes and the target will be used if they are included in + * last_hops. + * + * If some channels aren't announced, it may be useful to fill in a first_hops with the + * results from a local ChannelManager::list_usable_channels() call. If it is filled in, our + * view of our local channels (from net_graph_msg_handler) will be ignored, and only those + * in first_hops will be used. + * + * Panics if first_hops contains channels without short_channel_ids + * (ChannelManager::list_usable_channels will never include such channels). + * + * The fees on channels from us to next-hops are ignored (as they are assumed to all be + * equal), however the enabled/disabled bit on such channels as well as the + * htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node. */ -struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); +struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintHopZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); /** - * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write + * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); +void NetworkGraph_free(struct LDKNetworkGraph this_obj); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Creates a copy of the NetworkGraph */ -MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj); /** - * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL. */ -void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); +void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); /** - * Creates a copy of the CommitmentTransaction + * Creates a new tracker of the actual state of the network of channels and nodes, + * assuming a fresh network graph. + * Chain monitor is used to make sure announced channels exist on-chain, + * channel data is correct, and that the announcement is signed with + * channel owners' keys. */ -struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); +MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger); /** - * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + * Creates a new tracker of the actual state of the network of channels and nodes, + * assuming an existing Network Graph. */ -struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph); /** - * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + * Adds a provider used to check new announcements. Does not affect + * existing announcements unless they are updated. + * Add, update or remove the provider would replace the current one. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); +void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKAccess *chain_access); /** - * The backwards-counting commitment number + * Take a read lock on the network_graph and return it in the C-bindings + * newtype helper. This is likely only useful when called via the C + * bindings as you can call `self.network_graph.read().unwrap()` in Rust + * yourself. */ -MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); /** - * The value to be sent to the broadcaster + * Get a reference to the NetworkGraph which this read-lock contains. */ -MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *NONNULL_PTR this_arg); /** - * The value to be sent to the counterparty + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); /** - * Trust our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. - * - * This should only be used if you fully trust the builder of this object. It should not - *\tbe used by an external signer - instead use the verify function. + * Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void DirectionalChannelInfo_free(struct LDKDirectionalChannelInfo this_obj); /** - * Verify our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +uint32_t DirectionalChannelInfo_get_last_update(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); +void DirectionalChannelInfo_set_last_update(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * The transaction ID of the built Bitcoin transaction + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +bool DirectionalChannelInfo_get_enabled(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * The pre-built Bitcoin commitment transaction + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +void DirectionalChannelInfo_set_enabled(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, bool val); /** - * The pre-calculated transaction creation public keys. + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * Get a signature for each HTLC which was included in the commitment transaction (ie for - * which HTLCOutputInCommitment::transaction_output_index.is_some()). - * - * The returned Vec has one entry for each HTLC, and in the same order. + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters); +void DirectionalChannelInfo_set_cltv_expiry_delta(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Get the transaction number obscure factor + * The minimum value, which must be relayed to the next hop via the channel */ -uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); +uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the InitFeatures + * The minimum value, which must be relayed to the next hop via the channel */ -struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +void DirectionalChannelInfo_set_htlc_minimum_msat(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the NodeFeatures + * The maximum value which may be relayed to the next hop via the channel. */ -struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +struct LDKCOption_u64Z DirectionalChannelInfo_get_htlc_maximum_msat(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelFeatures + * The maximum value which may be relayed to the next hop via the channel. */ -struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); +void DirectionalChannelInfo_set_htlc_maximum_msat(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a copy of the InvoiceFeatures + * Fees charged when the channel is used for routing */ -struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); +struct LDKRoutingFees DirectionalChannelInfo_get_fees(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. + * Fees charged when the channel is used for routing */ -void InitFeatures_free(struct LDKInitFeatures this_obj); +void DirectionalChannelInfo_set_fees(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. */ -void NodeFeatures_free(struct LDKNodeFeatures this_obj); +struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. */ -void ChannelFeatures_free(struct LDKChannelFeatures this_obj); +void DirectionalChannelInfo_set_last_update_message(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); /** - * Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Constructs a new DirectionalChannelInfo given each field */ -void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); +MUST_USE_RES struct LDKDirectionalChannelInfo DirectionalChannelInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); /** - * Create a blank Features with no features set + * Creates a copy of the DirectionalChannelInfo */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); +struct LDKDirectionalChannelInfo DirectionalChannelInfo_clone(const struct LDKDirectionalChannelInfo *NONNULL_PTR orig); /** - * Creates a Features with the bits set which are known by the implementation + * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); +struct LDKCVec_u8Z DirectionalChannelInfo_write(const struct LDKDirectionalChannelInfo *NONNULL_PTR obj); /** - * Create a blank Features with no features set + * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); +struct LDKCResult_DirectionalChannelInfoDecodeErrorZ DirectionalChannelInfo_read(struct LDKu8slice ser); /** - * Creates a Features with the bits set which are known by the implementation + * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void); +void ChannelInfo_free(struct LDKChannelInfo this_obj); /** - * Create a blank Features with no features set + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); +struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a Features with the bits set which are known by the implementation + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); +void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Create a blank Features with no features set + * Source node of the first direction of a channel */ -MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); +struct LDKPublicKey ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a Features with the bits set which are known by the implementation + * Source node of the first direction of a channel */ -MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); +void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + * Details about the first direction of a channel */ -struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +struct LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * Details about the first direction of a channel */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); /** - * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + * Source node of the second direction of a channel */ -struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +struct LDKPublicKey ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read + * Source node of the second direction of a channel */ -struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); +void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * Details about the second direction of a channel */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +struct LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Read a NodeFeatures from a byte array, created by NodeFeatures_write + * Details about the second direction of a channel */ -struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * The channel capacity as seen on-chain, if chain lookup is available. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write + * The channel capacity as seen on-chain, if chain lookup is available. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); +void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. */ -void RouteHop_free(struct LDKRouteHop this_obj); +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * The node_id of the node at this hop. + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. */ -struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); /** - * The node_id of the node at this hop. + * Constructs a new ChannelInfo given each field */ -void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKChannelInfo ChannelInfo_new(struct LDKChannelFeatures features_arg, struct LDKPublicKey node_one_arg, struct LDKDirectionalChannelInfo one_to_two_arg, struct LDKPublicKey node_two_arg, struct LDKDirectionalChannelInfo two_to_one_arg, struct LDKCOption_u64Z capacity_sats_arg, struct LDKChannelAnnouncement announcement_message_arg); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * Creates a copy of the ChannelInfo */ -struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ -void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); /** - * The channel that should be used from the previous hop to reach this node. + * Read a ChannelInfo from a byte array, created by ChannelInfo_write */ -uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); /** - * The channel that should be used from the previous hop to reach this node. + * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. */ -void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +void RoutingFees_free(struct LDKRoutingFees this_obj); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Flat routing fee in satoshis */ -struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Flat routing fee in satoshis */ -void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * For the last hop, this should be the full value of the payment (might be more than - * requested if we had to match htlc_minimum_msat). + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); +uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * For the last hop, this should be the full value of the payment (might be more than - * requested if we had to match htlc_minimum_msat). + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value - * expected at the destination, in excess of the current block height. + * Constructs a new RoutingFees given each field */ -uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); /** - * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value - * expected at the destination, in excess of the current block height. + * Creates a copy of the RoutingFees */ -void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); +struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); /** - * Constructs a new RouteHop given each field + * Read a RoutingFees from a byte array, created by RoutingFees_write */ -MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); +struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); /** - * Creates a copy of the RouteHop + * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read */ -struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); +struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); /** - * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. */ -void Route_free(struct LDKRoute this_obj); +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); /** - * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the - * last RouteHop in each path must be the same. - * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the - * destination. Thus, this must always be at least length one. While the maximum length of any - * given path is variable, keeping the length of any path to less than 20 should currently - * ensure it is viable. + * Protocol features the node announced support for */ -void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); +struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * Constructs a new Route given each field + * Protocol features the node announced support for */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg); +void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Creates a copy of the Route + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); +uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * Serialize the Route object into a byte array which can be read by Route_read + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); +void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Read a Route from a byte array, created by Route_write + * Color assigned to the node */ -struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); +const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[3]; /** - * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. + * Color assigned to the node */ -void RouteHintHop_free(struct LDKRouteHintHop this_obj); +void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * The node_id of the non-target end of the route + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +const uint8_t (*NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[32]; /** - * The node_id of the non-target end of the route + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The short_channel_id of this channel + * Internet-level addresses via which one can connect to the node */ -uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void NodeAnnouncementInfo_set_addresses(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); /** - * The short_channel_id of this channel + * An initial announcement of the node + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. */ -void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * The fees which must be paid to use this channel + * An initial announcement of the node + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. */ -struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); /** - * The fees which must be paid to use this channel + * Constructs a new NodeAnnouncementInfo given each field */ -void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKThirtyTwoBytes alias_arg, struct LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); /** - * The difference in CLTV values between this node and the next node. + * Creates a copy of the NodeAnnouncementInfo */ -uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); /** - * The difference in CLTV values between this node and the next node. + * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ -void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. */ -void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void NodeInfo_free(struct LDKNodeInfo this_obj); /** - * The maximum value in msat available for routing with a single HTLC. + * All valid channels a node has announced */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * The maximum value in msat available for routing with a single HTLC. + * Lowest fees enabling routing via any of the enabled, known channels to a node. + * The two fields (flat and proportional fee) are independent, + * meaning they don't have to refer to the same channel. */ -void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Constructs a new RouteHintHop given each field + * Lowest fees enabling routing via any of the enabled, known channels to a node. + * The two fields (flat and proportional fee) are independent, + * meaning they don't have to refer to the same channel. */ -MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); +void NodeInfo_set_lowest_inbound_channel_fees(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Creates a copy of the RouteHintHop + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. */ -struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); +struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Gets a route from us (payer) to the given target node (payee). - * - * If the payee provided features in their invoice, they should be provided via payee_features. - * Without this, MPP will only be used if the payee's features are available in the network graph. - * - * Extra routing hops between known nodes and the target will be used if they are included in - * last_hops. - * - * If some channels aren't announced, it may be useful to fill in a first_hops with the - * results from a local ChannelManager::list_usable_channels() call. If it is filled in, our - * view of our local channels (from net_graph_msg_handler) will be ignored, and only those - * in first_hops will be used. - * - * Panics if first_hops contains channels without short_channel_ids - * (ChannelManager::list_usable_channels will never include such channels). - * - * The fees on channels from us to next-hops are ignored (as they are assumed to all be - * equal), however the enabled/disabled bit on such channels as well as the - * htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node. + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. */ -struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintHopZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); +void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); /** - * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. + * Constructs a new NodeInfo given each field */ -void NetworkGraph_free(struct LDKNetworkGraph this_obj); +MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKRoutingFees lowest_inbound_channel_fees_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); /** - * Creates a copy of the NetworkGraph + * Creates a copy of the NodeInfo */ -struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); +struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); /** - * Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL. + * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read */ -void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj); +struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); /** - * Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL. + * Read a NodeInfo from a byte array, created by NodeInfo_write */ -void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj); +struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); /** - * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming a fresh network graph. - * Chain monitor is used to make sure announced channels exist on-chain, - * channel data is correct, and that the announcement is signed with - * channel owners' keys. + * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read */ -MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger); +struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); /** - * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming an existing Network Graph. + * Read a NetworkGraph from a byte array, created by NetworkGraph_write */ -MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph); +struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser); /** - * Adds a provider used to check new announcements. Does not affect - * existing announcements unless they are updated. - * Add, update or remove the provider would replace the current one. + * Creates a new, empty, network graph. */ -void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKAccess *chain_access); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash); /** - * Take a read lock on the network_graph and return it in the C-bindings - * newtype helper. This is likely only useful when called via the C - * bindings as you can call `self.network_graph.read().unwrap()` in Rust - * yourself. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement. + * + * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. */ -MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Get a reference to the NetworkGraph which this read-lock contains. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement without verifying the associated signatures. Because we aren't + * given the associated signatures here we cannot relay the node announcement to any of our + * peers. */ -MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Store or update channel info from a channel announcement. + * + * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If a `chain::Access` object is provided via `chain_access`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Store or update channel info from a channel announcement without verifying the associated + * signatures. Because we aren't given the associated signatures here we cannot relay the + * channel announcement to any of our peers. + * + * If a `chain::Access` object is provided via `chain_access`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); /** - * Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. + * Close a channel if a corresponding HTLC fail was sent. + * If permanent, removes a channel from the local storage. + * May cause the removal of nodes too, if this was their last channel. + * If not permanent, makes channels unavailable for routing. */ -void DirectionalChannelInfo_free(struct LDKDirectionalChannelInfo this_obj); +void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel. + * + * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. */ -uint32_t DirectionalChannelInfo_get_last_update(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel without verifying the associated signatures. Because we aren't given the + * associated signatures here we cannot relay the channel update to any of our peers. */ -void DirectionalChannelInfo_set_last_update(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); /** - * Whether the channel can be currently used for payments (in this one direction). + * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. */ -bool DirectionalChannelInfo_get_enabled(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +void FilesystemPersister_free(struct LDKFilesystemPersister this_obj); /** - * Whether the channel can be currently used for payments (in this one direction). + * Initialize a new FilesystemPersister and set the path to the individual channels' + * files. */ -void DirectionalChannelInfo_set_enabled(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKFilesystemPersister FilesystemPersister_new(struct LDKCVec_u8Z path_to_channel_data); /** - * The difference in CLTV values that you must have when routing through this channel. + * Get the directory which was provided when this persister was initialized. */ -uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_u8Z FilesystemPersister_get_data_dir(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); /** - * The difference in CLTV values that you must have when routing through this channel. + * Writes the provided `ChannelManager` to the path provided at `FilesystemPersister` + * initialization, within a file called \"manager\". */ -void DirectionalChannelInfo_set_cltv_expiry_delta(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_manager(struct LDKCVec_u8Z data_dir, const struct LDKChannelManager *NONNULL_PTR manager); /** - * The minimum value, which must be relayed to the next hop via the channel + * Read `ChannelMonitor`s from disk. */ -uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ FilesystemPersister_read_channelmonitors(const struct LDKFilesystemPersister *NONNULL_PTR this_arg, struct LDKKeysInterface keys_manager); /** - * The minimum value, which must be relayed to the next hop via the channel + * Constructs a new Persist which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Persist must be freed before this_arg is */ -void DirectionalChannelInfo_set_htlc_minimum_msat(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPersist FilesystemPersister_as_Persist(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); /** - * The maximum value which may be relayed to the next hop via the channel. + * **Call this function on startup to ensure that all assumptions about the platform are valid.** + * + * Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on + * your platform which we can't fully verify at compile time and which isn't part of it's contract. + * To our best knowledge our assumptions hold for all platforms officially supported by rust, but + * since this check is fast we recommend to do it anyway. + * + * If this function fails this is considered a bug. Please open an issue describing your + * platform and stating your current system time. + * + * # Panics + * If the check fails this function panics. By calling this function on startup you ensure that + * this wont happen at an arbitrary later point in time. */ -struct LDKCOption_u64Z DirectionalChannelInfo_get_htlc_maximum_msat(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +void check_platform(void); /** - * The maximum value which may be relayed to the next hop via the channel. + * Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. */ -void DirectionalChannelInfo_set_htlc_maximum_msat(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void Invoice_free(struct LDKInvoice this_obj); /** - * Fees charged when the channel is used for routing + * Creates a copy of the Invoice */ -struct LDKRoutingFees DirectionalChannelInfo_get_fees(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +struct LDKInvoice Invoice_clone(const struct LDKInvoice *NONNULL_PTR orig); /** - * Fees charged when the channel is used for routing + * Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL. */ -void DirectionalChannelInfo_set_fees(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +void SignedRawInvoice_free(struct LDKSignedRawInvoice this_obj); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Creates a copy of the SignedRawInvoice */ -struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +struct LDKSignedRawInvoice SignedRawInvoice_clone(const struct LDKSignedRawInvoice *NONNULL_PTR orig); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL. */ -void DirectionalChannelInfo_set_last_update_message(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +void RawInvoice_free(struct LDKRawInvoice this_obj); /** - * Constructs a new DirectionalChannelInfo given each field + * data part */ -MUST_USE_RES struct LDKDirectionalChannelInfo DirectionalChannelInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); +struct LDKRawDataPart RawInvoice_get_data(const struct LDKRawInvoice *NONNULL_PTR this_ptr); /** - * Creates a copy of the DirectionalChannelInfo + * data part */ -struct LDKDirectionalChannelInfo DirectionalChannelInfo_clone(const struct LDKDirectionalChannelInfo *NONNULL_PTR orig); +void RawInvoice_set_data(struct LDKRawInvoice *NONNULL_PTR this_ptr, struct LDKRawDataPart val); /** - * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read + * Creates a copy of the RawInvoice */ -struct LDKCVec_u8Z DirectionalChannelInfo_write(const struct LDKDirectionalChannelInfo *NONNULL_PTR obj); +struct LDKRawInvoice RawInvoice_clone(const struct LDKRawInvoice *NONNULL_PTR orig); /** - * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write + * Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ DirectionalChannelInfo_read(struct LDKu8slice ser); +void RawDataPart_free(struct LDKRawDataPart this_obj); /** - * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. + * generation time of the invoice */ -void ChannelInfo_free(struct LDKChannelInfo this_obj); +struct LDKPositiveTimestamp RawDataPart_get_timestamp(const struct LDKRawDataPart *NONNULL_PTR this_ptr); /** - * Protocol features of a channel communicated during its announcement + * generation time of the invoice */ -struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void RawDataPart_set_timestamp(struct LDKRawDataPart *NONNULL_PTR this_ptr, struct LDKPositiveTimestamp val); /** - * Protocol features of a channel communicated during its announcement + * tagged fields of the payment request */ -void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +void RawDataPart_set_tagged_fields(struct LDKRawDataPart *NONNULL_PTR this_ptr, struct LDKCVec_RawTaggedFieldZ val); /** - * Source node of the first direction of a channel + * Constructs a new RawDataPart given each field */ -struct LDKPublicKey ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKRawDataPart RawDataPart_new(struct LDKPositiveTimestamp timestamp_arg, struct LDKCVec_RawTaggedFieldZ tagged_fields_arg); /** - * Source node of the first direction of a channel + * Creates a copy of the RawDataPart */ -void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKRawDataPart RawDataPart_clone(const struct LDKRawDataPart *NONNULL_PTR orig); /** - * Details about the first direction of a channel + * Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL. */ -struct LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void PositiveTimestamp_free(struct LDKPositiveTimestamp this_obj); /** - * Details about the first direction of a channel + * Creates a copy of the PositiveTimestamp */ -void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); +struct LDKPositiveTimestamp PositiveTimestamp_clone(const struct LDKPositiveTimestamp *NONNULL_PTR orig); /** - * Source node of the second direction of a channel + * Creates a copy of the SiPrefix */ -struct LDKPublicKey ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +enum LDKSiPrefix SiPrefix_clone(const enum LDKSiPrefix *NONNULL_PTR orig); /** - * Source node of the second direction of a channel + * Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix. + * This is effectively 10^12 * the prefix multiplier */ -void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES uint64_t SiPrefix_multiplier(const enum LDKSiPrefix *NONNULL_PTR this_arg); /** - * Details about the second direction of a channel + * Creates a copy of the Currency */ -struct LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +enum LDKCurrency Currency_clone(const enum LDKCurrency *NONNULL_PTR orig); /** - * Details about the second direction of a channel + * Frees any resources used by the RawTaggedField */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); +void RawTaggedField_free(struct LDKRawTaggedField this_ptr); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Creates a copy of the RawTaggedField */ -struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKRawTaggedField RawTaggedField_clone(const struct LDKRawTaggedField *NONNULL_PTR orig); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Frees any resources used by the TaggedField */ -void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TaggedField_free(struct LDKTaggedField this_ptr); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Creates a copy of the TaggedField */ -struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKTaggedField TaggedField_clone(const struct LDKTaggedField *NONNULL_PTR orig); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL. */ -void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +void Sha256_free(struct LDKSha256 this_obj); /** - * Constructs a new ChannelInfo given each field + * Creates a copy of the Sha256 */ -MUST_USE_RES struct LDKChannelInfo ChannelInfo_new(struct LDKChannelFeatures features_arg, struct LDKPublicKey node_one_arg, struct LDKDirectionalChannelInfo one_to_two_arg, struct LDKPublicKey node_two_arg, struct LDKDirectionalChannelInfo two_to_one_arg, struct LDKCOption_u64Z capacity_sats_arg, struct LDKChannelAnnouncement announcement_message_arg); +struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); /** - * Creates a copy of the ChannelInfo + * Frees any resources used by the Description, if is_owned is set and inner is non-NULL. */ -struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +void Description_free(struct LDKDescription this_obj); /** - * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + * Creates a copy of the Description */ -struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); +struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); /** - * Read a ChannelInfo from a byte array, created by ChannelInfo_write + * Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +void PayeePubKey_free(struct LDKPayeePubKey this_obj); /** - * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. + * Creates a copy of the PayeePubKey */ -void RoutingFees_free(struct LDKRoutingFees this_obj); +struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); /** - * Flat routing fee in satoshis + * Frees any resources used by the PaymentSecret, if is_owned is set and inner is non-NULL. */ -uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +void PaymentSecret_free(struct LDKPaymentSecret this_obj); /** - * Flat routing fee in satoshis + * Creates a copy of the PaymentSecret */ -void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPaymentSecret PaymentSecret_clone(const struct LDKPaymentSecret *NONNULL_PTR orig); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL. */ -uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +void ExpiryTime_free(struct LDKExpiryTime this_obj); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Creates a copy of the ExpiryTime */ -void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); /** - * Constructs a new RoutingFees given each field + * Frees any resources used by the MinFinalCltvExpiry, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +void MinFinalCltvExpiry_free(struct LDKMinFinalCltvExpiry this_obj); /** - * Creates a copy of the RoutingFees + * Creates a copy of the MinFinalCltvExpiry */ -struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); +struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig); /** - * Read a RoutingFees from a byte array, created by RoutingFees_write + * Frees any resources used by the Fallback */ -struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); +void Fallback_free(struct LDKFallback this_ptr); /** - * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read + * Creates a copy of the Fallback */ -struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); +struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig); /** - * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL. */ -void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); +void InvoiceSignature_free(struct LDKInvoiceSignature this_obj); /** - * Protocol features the node announced support for + * Creates a copy of the InvoiceSignature */ -struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); /** - * Protocol features the node announced support for + * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. */ -void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +void RouteHint_free(struct LDKRouteHint this_obj); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Creates a copy of the RouteHint */ -uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Disassembles the `SignedRawInvoice` into its three parts: + * 1. raw invoice + * 2. hash of the raw invoice + * 3. signature */ -void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ SignedRawInvoice_into_parts(struct LDKSignedRawInvoice this_arg); /** - * Color assigned to the node + * The `RawInvoice` which was signed. */ -const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[3]; +MUST_USE_RES struct LDKRawInvoice SignedRawInvoice_raw_invoice(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); /** - * Color assigned to the node + * The hash of the `RawInvoice` that was signed. */ -void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +MUST_USE_RES const uint8_t (*SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32]; /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * InvoiceSignature for the invoice. */ -const uint8_t (*NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKInvoiceSignature SignedRawInvoice_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * Recovers the public key used for signing the invoice from the recoverable signature. */ -void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCResult_PayeePubKeyErrorZ SignedRawInvoice_recover_payee_pub_key(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); /** - * Internet-level addresses via which one can connect to the node + * Checks if the signature is valid for the included payee public key or if none exists if it's + * valid for the recovered signature (which should always be true?). */ -void NodeAnnouncementInfo_set_addresses(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); +MUST_USE_RES bool SignedRawInvoice_check_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); /** - * An initial announcement of the node - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Calculate the hash of the encoded `RawInvoice` */ -struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKSha256 RawInvoice_payment_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKDescription RawInvoice_description(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKPayeePubKey RawInvoice_payee_pub_key(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKSha256 RawInvoice_description_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKExpiryTime RawInvoice_expiry_time(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKMinFinalCltvExpiry RawInvoice_min_final_cltv_expiry(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKPaymentSecret RawInvoice_payment_secret(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKInvoiceFeatures RawInvoice_features(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKCVec_RouteHintZ RawInvoice_routes(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES struct LDKCOption_u64Z RawInvoice_amount_pico_btc(const struct LDKRawInvoice *NONNULL_PTR this_arg); + +MUST_USE_RES enum LDKCurrency RawInvoice_currency(const struct LDKRawInvoice *NONNULL_PTR this_arg); /** - * An initial announcement of the node - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Create a new `PositiveTimestamp` from a unix timestamp in the Range + * `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a + * `CreationError::TimestampOutOfBounds`. */ -void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); +MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_unix_timestamp(uint64_t unix_seconds); /** - * Constructs a new NodeAnnouncementInfo given each field + * Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in + * the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a + * `CreationError::TimestampOutOfBounds`. */ -MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKThirtyTwoBytes alias_arg, struct LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); +MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time); /** - * Creates a copy of the NodeAnnouncementInfo + * Returns the UNIX timestamp representing the stored time */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +MUST_USE_RES uint64_t PositiveTimestamp_as_unix_timestamp(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read + * Returns a reference to the internal `SystemTime` time representation */ -struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); +MUST_USE_RES uint64_t PositiveTimestamp_as_time(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write + * Transform the `Invoice` into it's unchecked version */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKSignedRawInvoice Invoice_into_signed_raw(struct LDKInvoice this_arg); /** - * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + * Check that the invoice is signed correctly and that key recovery works */ -void NodeInfo_free(struct LDKNodeInfo this_obj); +MUST_USE_RES struct LDKCResult_NoneSemanticErrorZ Invoice_check_signature(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * All valid channels a node has announced + * Constructs an `Invoice` from a `SignedInvoice` by checking all its invariants. + * ``` + * use lightning_invoice::*; + * + * let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\ + * \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\ + * \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\ + * \tky03ylcqca784w\"; + * + * let signed = invoice.parse::().unwrap(); + * + * assert!(Invoice::from_signed(signed).is_ok()); + * ``` */ -void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +MUST_USE_RES struct LDKCResult_InvoiceSemanticErrorZ Invoice_from_signed(struct LDKSignedRawInvoice signed_invoice); /** - * Lowest fees enabling routing via any of the enabled, known channels to a node. - * The two fields (flat and proportional fee) are independent, - * meaning they don't have to refer to the same channel. + * Returns the `Invoice`'s timestamp (should equal it's creation time) */ -struct LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +MUST_USE_RES uint64_t Invoice_timestamp(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Lowest fees enabling routing via any of the enabled, known channels to a node. - * The two fields (flat and proportional fee) are independent, - * meaning they don't have to refer to the same channel. + * Returns the hash to which we will receive the preimage on completion of the payment */ -void NodeInfo_set_lowest_inbound_channel_fees(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +MUST_USE_RES const uint8_t (*Invoice_payment_hash(const struct LDKInvoice *NONNULL_PTR this_arg))[32]; /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. + * Get the payee's public key if one was included in the invoice */ -struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPublicKey Invoice_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. + * Get the payment secret if one was included in the invoice */ -void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); +MUST_USE_RES struct LDKPaymentSecret Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Constructs a new NodeInfo given each field + * Get the invoice features if they were included in the invoice */ -MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKRoutingFees lowest_inbound_channel_fees_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); +MUST_USE_RES struct LDKInvoiceFeatures Invoice_features(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Creates a copy of the NodeInfo + * Recover the payee's public key (only to be used if none was included in the invoice) */ -struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +MUST_USE_RES struct LDKPublicKey Invoice_recover_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read + * Returns the invoice's expiry time if present */ -struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); +MUST_USE_RES uint64_t Invoice_expiry_time(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Read a NodeInfo from a byte array, created by NodeInfo_write + * Returns the invoice's `min_cltv_expiry` time if present */ -struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCOption_u64Z Invoice_min_final_cltv_expiry(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read + * Returns a list of all routes included in the invoice */ -struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); +MUST_USE_RES struct LDKCVec_RouteHintZ Invoice_routes(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Read a NetworkGraph from a byte array, created by NetworkGraph_write + * Returns the currency for which the invoice was issued */ -struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser); +MUST_USE_RES enum LDKCurrency Invoice_currency(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Creates a new, empty, network graph. + * Returns the amount if specified in the invoice as pico . */ -MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash); +MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_pico_btc(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement. - * - * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. + * Numeric representation of the field's tag */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); +MUST_USE_RES struct LDKu5 TaggedField_tag(const struct LDKTaggedField *NONNULL_PTR this_arg); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement without verifying the associated signatures. Because we aren't - * given the associated signatures here we cannot relay the node announcement to any of our - * peers. + * Creates a new `Description` if `description` is at most 1023 __bytes__ long, + * returns `CreationError::DescriptionTooLong` otherwise + * + * Please note that single characters may use more than one byte due to UTF8 encoding. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); +MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct LDKCVec_u8Z description); /** - * Store or update channel info from a channel announcement. - * - * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If a `chain::Access` object is provided via `chain_access`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * Returns the underlying description `String` */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); +MUST_USE_RES struct LDKCVec_u8Z Description_into_inner(struct LDKDescription this_arg); /** - * Store or update channel info from a channel announcement without verifying the associated - * signatures. Because we aren't given the associated signatures here we cannot relay the - * channel announcement to any of our peers. - * - * If a `chain::Access` object is provided via `chain_access`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would + * overflow on adding the `EpiryTime` to it then this function will return a + * `CreationError::ExpiryTimeOutOfBounds`. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access); +MUST_USE_RES struct LDKCResult_ExpiryTimeCreationErrorZ ExpiryTime_from_seconds(uint64_t seconds); /** - * Close a channel if a corresponding HTLC fail was sent. - * If permanent, removes a channel from the local storage. - * May cause the removal of nodes too, if this was their last channel. - * If not permanent, makes channels unavailable for routing. + * Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which + * would overflow on adding the `EpiryTime` to it then this function will return a + * `CreationError::ExpiryTimeOutOfBounds`. */ -void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); +MUST_USE_RES struct LDKCResult_ExpiryTimeCreationErrorZ ExpiryTime_from_duration(uint64_t duration); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel. - * - * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. + * Returns the expiry time in seconds */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +MUST_USE_RES uint64_t ExpiryTime_as_seconds(const struct LDKExpiryTime *NONNULL_PTR this_arg); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel without verifying the associated signatures. Because we aren't given the - * associated signatures here we cannot relay the channel update to any of our peers. + * Returns a reference to the underlying `Duration` (=expiry time) */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); +MUST_USE_RES uint64_t ExpiryTime_as_duration(const struct LDKExpiryTime *NONNULL_PTR this_arg); /** - * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. + * Create a new (partial) route from a list of hops */ -void FilesystemPersister_free(struct LDKFilesystemPersister this_obj); +MUST_USE_RES struct LDKCResult_RouteHintCreationErrorZ RouteHint_new(struct LDKCVec_RouteHintHopZ hops); /** - * Initialize a new FilesystemPersister and set the path to the individual channels' - * files. + * Returrn the underlying vector of hops */ -MUST_USE_RES struct LDKFilesystemPersister FilesystemPersister_new(struct LDKCVec_u8Z path_to_channel_data); +MUST_USE_RES struct LDKCVec_RouteHintHopZ RouteHint_into_inner(struct LDKRouteHint this_arg); /** - * Get the directory which was provided when this persister was initialized. + * Creates a copy of the CreationError */ -MUST_USE_RES struct LDKCVec_u8Z FilesystemPersister_get_data_dir(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); +enum LDKCreationError CreationError_clone(const enum LDKCreationError *NONNULL_PTR orig); /** - * Writes the provided `ChannelManager` to the path provided at `FilesystemPersister` - * initialization, within a file called \"manager\". + * Get the string representation of a CreationError object */ -MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_manager(struct LDKCVec_u8Z data_dir, const struct LDKChannelManager *NONNULL_PTR manager); +struct LDKStr CreationError_to_str(const enum LDKCreationError *NONNULL_PTR o); /** - * Read `ChannelMonitor`s from disk. + * Creates a copy of the SemanticError */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ FilesystemPersister_read_channelmonitors(const struct LDKFilesystemPersister *NONNULL_PTR this_arg, struct LDKKeysInterface keys_manager); +enum LDKSemanticError SemanticError_clone(const enum LDKSemanticError *NONNULL_PTR orig); /** - * Constructs a new Persist which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Persist must be freed before this_arg is + * Get the string representation of a SemanticError object */ -struct LDKPersist FilesystemPersister_as_Persist(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); +struct LDKStr SemanticError_to_str(const enum LDKSemanticError *NONNULL_PTR o); #endif /* LDK_C_BINDINGS_H */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 269e76a..7c21ba9 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -240,6 +240,302 @@ public: const LDKTrustedCommitmentTransaction* operator &() const { return &self; } const LDKTrustedCommitmentTransaction* operator ->() const { return &self; } }; +class Invoice { +private: + LDKInvoice self; +public: + Invoice(const Invoice&) = delete; + Invoice(Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(Invoice)); } + Invoice(LDKInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoice)); } + operator LDKInvoice() && { LDKInvoice res = self; memset(&self, 0, sizeof(LDKInvoice)); return res; } + ~Invoice() { Invoice_free(self); } + Invoice& operator=(Invoice&& o) { Invoice_free(self); self = o.self; memset(&o, 0, sizeof(Invoice)); return *this; } + LDKInvoice* operator &() { return &self; } + LDKInvoice* operator ->() { return &self; } + const LDKInvoice* operator &() const { return &self; } + const LDKInvoice* operator ->() const { return &self; } +}; +class SignedRawInvoice { +private: + LDKSignedRawInvoice self; +public: + SignedRawInvoice(const SignedRawInvoice&) = delete; + SignedRawInvoice(SignedRawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(SignedRawInvoice)); } + SignedRawInvoice(LDKSignedRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignedRawInvoice)); } + operator LDKSignedRawInvoice() && { LDKSignedRawInvoice res = self; memset(&self, 0, sizeof(LDKSignedRawInvoice)); return res; } + ~SignedRawInvoice() { SignedRawInvoice_free(self); } + SignedRawInvoice& operator=(SignedRawInvoice&& o) { SignedRawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(SignedRawInvoice)); return *this; } + LDKSignedRawInvoice* operator &() { return &self; } + LDKSignedRawInvoice* operator ->() { return &self; } + const LDKSignedRawInvoice* operator &() const { return &self; } + const LDKSignedRawInvoice* operator ->() const { return &self; } +}; +class RawInvoice { +private: + LDKRawInvoice self; +public: + RawInvoice(const RawInvoice&) = delete; + RawInvoice(RawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(RawInvoice)); } + RawInvoice(LDKRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawInvoice)); } + operator LDKRawInvoice() && { LDKRawInvoice res = self; memset(&self, 0, sizeof(LDKRawInvoice)); return res; } + ~RawInvoice() { RawInvoice_free(self); } + RawInvoice& operator=(RawInvoice&& o) { RawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(RawInvoice)); return *this; } + LDKRawInvoice* operator &() { return &self; } + LDKRawInvoice* operator ->() { return &self; } + const LDKRawInvoice* operator &() const { return &self; } + const LDKRawInvoice* operator ->() const { return &self; } +}; +class RawDataPart { +private: + LDKRawDataPart self; +public: + RawDataPart(const RawDataPart&) = delete; + RawDataPart(RawDataPart&& o) : self(o.self) { memset(&o, 0, sizeof(RawDataPart)); } + RawDataPart(LDKRawDataPart&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawDataPart)); } + operator LDKRawDataPart() && { LDKRawDataPart res = self; memset(&self, 0, sizeof(LDKRawDataPart)); return res; } + ~RawDataPart() { RawDataPart_free(self); } + RawDataPart& operator=(RawDataPart&& o) { RawDataPart_free(self); self = o.self; memset(&o, 0, sizeof(RawDataPart)); return *this; } + LDKRawDataPart* operator &() { return &self; } + LDKRawDataPart* operator ->() { return &self; } + const LDKRawDataPart* operator &() const { return &self; } + const LDKRawDataPart* operator ->() const { return &self; } +}; +class PositiveTimestamp { +private: + LDKPositiveTimestamp self; +public: + PositiveTimestamp(const PositiveTimestamp&) = delete; + PositiveTimestamp(PositiveTimestamp&& o) : self(o.self) { memset(&o, 0, sizeof(PositiveTimestamp)); } + PositiveTimestamp(LDKPositiveTimestamp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPositiveTimestamp)); } + operator LDKPositiveTimestamp() && { LDKPositiveTimestamp res = self; memset(&self, 0, sizeof(LDKPositiveTimestamp)); return res; } + ~PositiveTimestamp() { PositiveTimestamp_free(self); } + PositiveTimestamp& operator=(PositiveTimestamp&& o) { PositiveTimestamp_free(self); self = o.self; memset(&o, 0, sizeof(PositiveTimestamp)); return *this; } + LDKPositiveTimestamp* operator &() { return &self; } + LDKPositiveTimestamp* operator ->() { return &self; } + const LDKPositiveTimestamp* operator &() const { return &self; } + const LDKPositiveTimestamp* operator ->() const { return &self; } +}; +class SiPrefix { +private: + LDKSiPrefix self; +public: + SiPrefix(const SiPrefix&) = delete; + SiPrefix(SiPrefix&& o) : self(o.self) { memset(&o, 0, sizeof(SiPrefix)); } + SiPrefix(LDKSiPrefix&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSiPrefix)); } + operator LDKSiPrefix() && { LDKSiPrefix res = self; memset(&self, 0, sizeof(LDKSiPrefix)); return res; } + SiPrefix& operator=(SiPrefix&& o) { self = o.self; memset(&o, 0, sizeof(SiPrefix)); return *this; } + LDKSiPrefix* operator &() { return &self; } + LDKSiPrefix* operator ->() { return &self; } + const LDKSiPrefix* operator &() const { return &self; } + const LDKSiPrefix* operator ->() const { return &self; } +}; +class Currency { +private: + LDKCurrency self; +public: + Currency(const Currency&) = delete; + Currency(Currency&& o) : self(o.self) { memset(&o, 0, sizeof(Currency)); } + Currency(LDKCurrency&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCurrency)); } + operator LDKCurrency() && { LDKCurrency res = self; memset(&self, 0, sizeof(LDKCurrency)); return res; } + Currency& operator=(Currency&& o) { self = o.self; memset(&o, 0, sizeof(Currency)); return *this; } + LDKCurrency* operator &() { return &self; } + LDKCurrency* operator ->() { return &self; } + const LDKCurrency* operator &() const { return &self; } + const LDKCurrency* operator ->() const { return &self; } +}; +class RawTaggedField { +private: + LDKRawTaggedField self; +public: + RawTaggedField(const RawTaggedField&) = delete; + RawTaggedField(RawTaggedField&& o) : self(o.self) { memset(&o, 0, sizeof(RawTaggedField)); } + RawTaggedField(LDKRawTaggedField&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawTaggedField)); } + operator LDKRawTaggedField() && { LDKRawTaggedField res = self; memset(&self, 0, sizeof(LDKRawTaggedField)); return res; } + ~RawTaggedField() { RawTaggedField_free(self); } + RawTaggedField& operator=(RawTaggedField&& o) { RawTaggedField_free(self); self = o.self; memset(&o, 0, sizeof(RawTaggedField)); return *this; } + LDKRawTaggedField* operator &() { return &self; } + LDKRawTaggedField* operator ->() { return &self; } + const LDKRawTaggedField* operator &() const { return &self; } + const LDKRawTaggedField* operator ->() const { return &self; } +}; +class TaggedField { +private: + LDKTaggedField self; +public: + TaggedField(const TaggedField&) = delete; + TaggedField(TaggedField&& o) : self(o.self) { memset(&o, 0, sizeof(TaggedField)); } + TaggedField(LDKTaggedField&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTaggedField)); } + operator LDKTaggedField() && { LDKTaggedField res = self; memset(&self, 0, sizeof(LDKTaggedField)); return res; } + ~TaggedField() { TaggedField_free(self); } + TaggedField& operator=(TaggedField&& o) { TaggedField_free(self); self = o.self; memset(&o, 0, sizeof(TaggedField)); return *this; } + LDKTaggedField* operator &() { return &self; } + LDKTaggedField* operator ->() { return &self; } + const LDKTaggedField* operator &() const { return &self; } + const LDKTaggedField* operator ->() const { return &self; } +}; +class Sha256 { +private: + LDKSha256 self; +public: + Sha256(const Sha256&) = delete; + Sha256(Sha256&& o) : self(o.self) { memset(&o, 0, sizeof(Sha256)); } + Sha256(LDKSha256&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSha256)); } + operator LDKSha256() && { LDKSha256 res = self; memset(&self, 0, sizeof(LDKSha256)); return res; } + ~Sha256() { Sha256_free(self); } + Sha256& operator=(Sha256&& o) { Sha256_free(self); self = o.self; memset(&o, 0, sizeof(Sha256)); return *this; } + LDKSha256* operator &() { return &self; } + LDKSha256* operator ->() { return &self; } + const LDKSha256* operator &() const { return &self; } + const LDKSha256* operator ->() const { return &self; } +}; +class Description { +private: + LDKDescription self; +public: + Description(const Description&) = delete; + Description(Description&& o) : self(o.self) { memset(&o, 0, sizeof(Description)); } + Description(LDKDescription&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDescription)); } + operator LDKDescription() && { LDKDescription res = self; memset(&self, 0, sizeof(LDKDescription)); return res; } + ~Description() { Description_free(self); } + Description& operator=(Description&& o) { Description_free(self); self = o.self; memset(&o, 0, sizeof(Description)); return *this; } + LDKDescription* operator &() { return &self; } + LDKDescription* operator ->() { return &self; } + const LDKDescription* operator &() const { return &self; } + const LDKDescription* operator ->() const { return &self; } +}; +class PayeePubKey { +private: + LDKPayeePubKey self; +public: + PayeePubKey(const PayeePubKey&) = delete; + PayeePubKey(PayeePubKey&& o) : self(o.self) { memset(&o, 0, sizeof(PayeePubKey)); } + PayeePubKey(LDKPayeePubKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayeePubKey)); } + operator LDKPayeePubKey() && { LDKPayeePubKey res = self; memset(&self, 0, sizeof(LDKPayeePubKey)); return res; } + ~PayeePubKey() { PayeePubKey_free(self); } + PayeePubKey& operator=(PayeePubKey&& o) { PayeePubKey_free(self); self = o.self; memset(&o, 0, sizeof(PayeePubKey)); return *this; } + LDKPayeePubKey* operator &() { return &self; } + LDKPayeePubKey* operator ->() { return &self; } + const LDKPayeePubKey* operator &() const { return &self; } + const LDKPayeePubKey* operator ->() const { return &self; } +}; +class PaymentSecret { +private: + LDKPaymentSecret self; +public: + PaymentSecret(const PaymentSecret&) = delete; + PaymentSecret(PaymentSecret&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentSecret)); } + PaymentSecret(LDKPaymentSecret&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentSecret)); } + operator LDKPaymentSecret() && { LDKPaymentSecret res = self; memset(&self, 0, sizeof(LDKPaymentSecret)); return res; } + ~PaymentSecret() { PaymentSecret_free(self); } + PaymentSecret& operator=(PaymentSecret&& o) { PaymentSecret_free(self); self = o.self; memset(&o, 0, sizeof(PaymentSecret)); return *this; } + LDKPaymentSecret* operator &() { return &self; } + LDKPaymentSecret* operator ->() { return &self; } + const LDKPaymentSecret* operator &() const { return &self; } + const LDKPaymentSecret* operator ->() const { return &self; } +}; +class ExpiryTime { +private: + LDKExpiryTime self; +public: + ExpiryTime(const ExpiryTime&) = delete; + ExpiryTime(ExpiryTime&& o) : self(o.self) { memset(&o, 0, sizeof(ExpiryTime)); } + ExpiryTime(LDKExpiryTime&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpiryTime)); } + operator LDKExpiryTime() && { LDKExpiryTime res = self; memset(&self, 0, sizeof(LDKExpiryTime)); return res; } + ~ExpiryTime() { ExpiryTime_free(self); } + ExpiryTime& operator=(ExpiryTime&& o) { ExpiryTime_free(self); self = o.self; memset(&o, 0, sizeof(ExpiryTime)); return *this; } + LDKExpiryTime* operator &() { return &self; } + LDKExpiryTime* operator ->() { return &self; } + const LDKExpiryTime* operator &() const { return &self; } + const LDKExpiryTime* operator ->() const { return &self; } +}; +class MinFinalCltvExpiry { +private: + LDKMinFinalCltvExpiry self; +public: + MinFinalCltvExpiry(const MinFinalCltvExpiry&) = delete; + MinFinalCltvExpiry(MinFinalCltvExpiry&& o) : self(o.self) { memset(&o, 0, sizeof(MinFinalCltvExpiry)); } + MinFinalCltvExpiry(LDKMinFinalCltvExpiry&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMinFinalCltvExpiry)); } + operator LDKMinFinalCltvExpiry() && { LDKMinFinalCltvExpiry res = self; memset(&self, 0, sizeof(LDKMinFinalCltvExpiry)); return res; } + ~MinFinalCltvExpiry() { MinFinalCltvExpiry_free(self); } + MinFinalCltvExpiry& operator=(MinFinalCltvExpiry&& o) { MinFinalCltvExpiry_free(self); self = o.self; memset(&o, 0, sizeof(MinFinalCltvExpiry)); return *this; } + LDKMinFinalCltvExpiry* operator &() { return &self; } + LDKMinFinalCltvExpiry* operator ->() { return &self; } + const LDKMinFinalCltvExpiry* operator &() const { return &self; } + const LDKMinFinalCltvExpiry* operator ->() const { return &self; } +}; +class Fallback { +private: + LDKFallback self; +public: + Fallback(const Fallback&) = delete; + Fallback(Fallback&& o) : self(o.self) { memset(&o, 0, sizeof(Fallback)); } + Fallback(LDKFallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFallback)); } + operator LDKFallback() && { LDKFallback res = self; memset(&self, 0, sizeof(LDKFallback)); return res; } + ~Fallback() { Fallback_free(self); } + Fallback& operator=(Fallback&& o) { Fallback_free(self); self = o.self; memset(&o, 0, sizeof(Fallback)); return *this; } + LDKFallback* operator &() { return &self; } + LDKFallback* operator ->() { return &self; } + const LDKFallback* operator &() const { return &self; } + const LDKFallback* operator ->() const { return &self; } +}; +class InvoiceSignature { +private: + LDKInvoiceSignature self; +public: + InvoiceSignature(const InvoiceSignature&) = delete; + InvoiceSignature(InvoiceSignature&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceSignature)); } + InvoiceSignature(LDKInvoiceSignature&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceSignature)); } + operator LDKInvoiceSignature() && { LDKInvoiceSignature res = self; memset(&self, 0, sizeof(LDKInvoiceSignature)); return res; } + ~InvoiceSignature() { InvoiceSignature_free(self); } + InvoiceSignature& operator=(InvoiceSignature&& o) { InvoiceSignature_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceSignature)); return *this; } + LDKInvoiceSignature* operator &() { return &self; } + LDKInvoiceSignature* operator ->() { return &self; } + const LDKInvoiceSignature* operator &() const { return &self; } + const LDKInvoiceSignature* operator ->() const { return &self; } +}; +class RouteHint { +private: + LDKRouteHint self; +public: + RouteHint(const RouteHint&) = delete; + RouteHint(RouteHint&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHint)); } + RouteHint(LDKRouteHint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHint)); } + operator LDKRouteHint() && { LDKRouteHint res = self; memset(&self, 0, sizeof(LDKRouteHint)); return res; } + ~RouteHint() { RouteHint_free(self); } + RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } + LDKRouteHint* operator &() { return &self; } + LDKRouteHint* operator ->() { return &self; } + const LDKRouteHint* operator &() const { return &self; } + const LDKRouteHint* operator ->() const { return &self; } +}; +class CreationError { +private: + LDKCreationError self; +public: + CreationError(const CreationError&) = delete; + CreationError(CreationError&& o) : self(o.self) { memset(&o, 0, sizeof(CreationError)); } + CreationError(LDKCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCreationError)); } + operator LDKCreationError() && { LDKCreationError res = self; memset(&self, 0, sizeof(LDKCreationError)); return res; } + CreationError& operator=(CreationError&& o) { self = o.self; memset(&o, 0, sizeof(CreationError)); return *this; } + LDKCreationError* operator &() { return &self; } + LDKCreationError* operator ->() { return &self; } + const LDKCreationError* operator &() const { return &self; } + const LDKCreationError* operator ->() const { return &self; } +}; +class SemanticError { +private: + LDKSemanticError self; +public: + SemanticError(const SemanticError&) = delete; + SemanticError(SemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(SemanticError)); } + SemanticError(LDKSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSemanticError)); } + operator LDKSemanticError() && { LDKSemanticError res = self; memset(&self, 0, sizeof(LDKSemanticError)); return res; } + SemanticError& operator=(SemanticError&& o) { self = o.self; memset(&o, 0, sizeof(SemanticError)); return *this; } + LDKSemanticError* operator &() { return &self; } + LDKSemanticError* operator ->() { return &self; } + const LDKSemanticError* operator &() const { return &self; } + const LDKSemanticError* operator ->() const { return &self; } +}; class ChannelMonitorUpdate { private: LDKChannelMonitorUpdate self; @@ -1871,6 +2167,21 @@ public: const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() const { return &self; } const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() const { return &self; } }; +class CResult_PositiveTimestampCreationErrorZ { +private: + LDKCResult_PositiveTimestampCreationErrorZ self; +public: + CResult_PositiveTimestampCreationErrorZ(const CResult_PositiveTimestampCreationErrorZ&) = delete; + CResult_PositiveTimestampCreationErrorZ(CResult_PositiveTimestampCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PositiveTimestampCreationErrorZ)); } + CResult_PositiveTimestampCreationErrorZ(LDKCResult_PositiveTimestampCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PositiveTimestampCreationErrorZ)); } + operator LDKCResult_PositiveTimestampCreationErrorZ() && { LDKCResult_PositiveTimestampCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PositiveTimestampCreationErrorZ)); return res; } + ~CResult_PositiveTimestampCreationErrorZ() { CResult_PositiveTimestampCreationErrorZ_free(self); } + CResult_PositiveTimestampCreationErrorZ& operator=(CResult_PositiveTimestampCreationErrorZ&& o) { CResult_PositiveTimestampCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PositiveTimestampCreationErrorZ)); return *this; } + LDKCResult_PositiveTimestampCreationErrorZ* operator &() { return &self; } + LDKCResult_PositiveTimestampCreationErrorZ* operator ->() { return &self; } + const LDKCResult_PositiveTimestampCreationErrorZ* operator &() const { return &self; } + const LDKCResult_PositiveTimestampCreationErrorZ* operator ->() const { return &self; } +}; class CResult_CVec_u8ZPeerHandleErrorZ { private: LDKCResult_CVec_u8ZPeerHandleErrorZ self; @@ -2081,6 +2392,21 @@ public: const LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() const { return &self; } const LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ExpiryTimeCreationErrorZ { +private: + LDKCResult_ExpiryTimeCreationErrorZ self; +public: + CResult_ExpiryTimeCreationErrorZ(const CResult_ExpiryTimeCreationErrorZ&) = delete; + CResult_ExpiryTimeCreationErrorZ(CResult_ExpiryTimeCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ExpiryTimeCreationErrorZ)); } + CResult_ExpiryTimeCreationErrorZ(LDKCResult_ExpiryTimeCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ExpiryTimeCreationErrorZ)); } + operator LDKCResult_ExpiryTimeCreationErrorZ() && { LDKCResult_ExpiryTimeCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ExpiryTimeCreationErrorZ)); return res; } + ~CResult_ExpiryTimeCreationErrorZ() { CResult_ExpiryTimeCreationErrorZ_free(self); } + CResult_ExpiryTimeCreationErrorZ& operator=(CResult_ExpiryTimeCreationErrorZ&& o) { CResult_ExpiryTimeCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ExpiryTimeCreationErrorZ)); return *this; } + LDKCResult_ExpiryTimeCreationErrorZ* operator &() { return &self; } + LDKCResult_ExpiryTimeCreationErrorZ* operator ->() { return &self; } + const LDKCResult_ExpiryTimeCreationErrorZ* operator &() const { return &self; } + const LDKCResult_ExpiryTimeCreationErrorZ* operator ->() const { return &self; } +}; class COption_C2Tuple_usizeTransactionZZ { private: LDKCOption_C2Tuple_usizeTransactionZZ self; @@ -2441,6 +2767,21 @@ public: const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; } const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; } }; +class C3Tuple_RawInvoice_u832InvoiceSignatureZ { +private: + LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ self; +public: + C3Tuple_RawInvoice_u832InvoiceSignatureZ(const C3Tuple_RawInvoice_u832InvoiceSignatureZ&) = delete; + C3Tuple_RawInvoice_u832InvoiceSignatureZ(C3Tuple_RawInvoice_u832InvoiceSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_RawInvoice_u832InvoiceSignatureZ)); } + C3Tuple_RawInvoice_u832InvoiceSignatureZ(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ)); } + operator LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ() && { LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ)); return res; } + ~C3Tuple_RawInvoice_u832InvoiceSignatureZ() { C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(self); } + C3Tuple_RawInvoice_u832InvoiceSignatureZ& operator=(C3Tuple_RawInvoice_u832InvoiceSignatureZ&& o) { C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_RawInvoice_u832InvoiceSignatureZ)); return *this; } + LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator &() { return &self; } + LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator ->() { return &self; } + const LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator &() const { return &self; } + const LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator ->() const { return &self; } +}; class CResult_NetworkGraphDecodeErrorZ { private: LDKCResult_NetworkGraphDecodeErrorZ self; @@ -2471,6 +2812,21 @@ public: const LDKCVec_RouteHopZ* operator &() const { return &self; } const LDKCVec_RouteHopZ* operator ->() const { return &self; } }; +class CResult_RouteHintCreationErrorZ { +private: + LDKCResult_RouteHintCreationErrorZ self; +public: + CResult_RouteHintCreationErrorZ(const CResult_RouteHintCreationErrorZ&) = delete; + CResult_RouteHintCreationErrorZ(CResult_RouteHintCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteHintCreationErrorZ)); } + CResult_RouteHintCreationErrorZ(LDKCResult_RouteHintCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteHintCreationErrorZ)); } + operator LDKCResult_RouteHintCreationErrorZ() && { LDKCResult_RouteHintCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteHintCreationErrorZ)); return res; } + ~CResult_RouteHintCreationErrorZ() { CResult_RouteHintCreationErrorZ_free(self); } + CResult_RouteHintCreationErrorZ& operator=(CResult_RouteHintCreationErrorZ&& o) { CResult_RouteHintCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteHintCreationErrorZ)); return *this; } + LDKCResult_RouteHintCreationErrorZ* operator &() { return &self; } + LDKCResult_RouteHintCreationErrorZ* operator ->() { return &self; } + const LDKCResult_RouteHintCreationErrorZ* operator &() const { return &self; } + const LDKCResult_RouteHintCreationErrorZ* operator ->() const { return &self; } +}; class CResult_NodeInfoDecodeErrorZ { private: LDKCResult_NodeInfoDecodeErrorZ self; @@ -2501,20 +2857,20 @@ public: const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator ->() const { return &self; } }; -class CResult_RouteLightningErrorZ { +class CVec_u8Z { private: - LDKCResult_RouteLightningErrorZ self; + LDKCVec_u8Z self; public: - CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; - CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); } - CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); } - operator LDKCResult_RouteLightningErrorZ() && { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; } - ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } - CResult_RouteLightningErrorZ& operator=(CResult_RouteLightningErrorZ&& o) { CResult_RouteLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); return *this; } - LDKCResult_RouteLightningErrorZ* operator &() { return &self; } - LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } - const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } - const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } + CVec_u8Z(const CVec_u8Z&) = delete; + CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); } + CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } + operator LDKCVec_u8Z() && { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } + ~CVec_u8Z() { CVec_u8Z_free(self); } + CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } + LDKCVec_u8Z* operator &() { return &self; } + LDKCVec_u8Z* operator ->() { return &self; } + const LDKCVec_u8Z* operator &() const { return &self; } + const LDKCVec_u8Z* operator ->() const { return &self; } }; class CResult_ChannelPublicKeysDecodeErrorZ { private: @@ -2531,20 +2887,20 @@ public: const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_u8Z { +class CResult_RouteLightningErrorZ { private: - LDKCVec_u8Z self; + LDKCResult_RouteLightningErrorZ self; public: - CVec_u8Z(const CVec_u8Z&) = delete; - CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); } - CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } - operator LDKCVec_u8Z() && { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } - ~CVec_u8Z() { CVec_u8Z_free(self); } - CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } - LDKCVec_u8Z* operator &() { return &self; } - LDKCVec_u8Z* operator ->() { return &self; } - const LDKCVec_u8Z* operator &() const { return &self; } - const LDKCVec_u8Z* operator ->() const { return &self; } + CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; + CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); } + CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); } + operator LDKCResult_RouteLightningErrorZ() && { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; } + ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } + CResult_RouteLightningErrorZ& operator=(CResult_RouteLightningErrorZ&& o) { CResult_RouteLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); return *this; } + LDKCResult_RouteLightningErrorZ* operator &() { return &self; } + LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } + const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } + const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } }; class CResult_NonePaymentSendFailureZ { private: @@ -2621,21 +2977,6 @@ public: const LDKCResult_SignatureNoneZ* operator &() const { return &self; } const LDKCResult_SignatureNoneZ* operator ->() const { return &self; } }; -class C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { -private: - LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ self; -public: - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ(const C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&) = delete; - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); } - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); } - operator LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ() && { LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); return res; } - ~C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ() { C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(self); } - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ& operator=(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&& o) { C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); return *this; } - LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator &() { return &self; } - LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator ->() { return &self; } - const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator &() const { return &self; } - const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator ->() const { return &self; } -}; class CVec_RouteHintHopZ { private: LDKCVec_RouteHintHopZ self; @@ -2651,6 +2992,21 @@ public: const LDKCVec_RouteHintHopZ* operator &() const { return &self; } const LDKCVec_RouteHintHopZ* operator ->() const { return &self; } }; +class C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { +private: + LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ self; +public: + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ(const C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&) = delete; + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); } + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); } + operator LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ() && { LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); return res; } + ~C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ() { C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(self); } + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ& operator=(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ&& o) { C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ)); return *this; } + LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator &() { return &self; } + LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator ->() { return &self; } + const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator &() const { return &self; } + const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator ->() const { return &self; } +}; class CResult_InitDecodeErrorZ { private: LDKCResult_InitDecodeErrorZ self; @@ -2681,6 +3037,21 @@ public: const LDKCResult_OutPointDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OutPointDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_RawTaggedFieldZ { +private: + LDKCVec_RawTaggedFieldZ self; +public: + CVec_RawTaggedFieldZ(const CVec_RawTaggedFieldZ&) = delete; + CVec_RawTaggedFieldZ(CVec_RawTaggedFieldZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RawTaggedFieldZ)); } + CVec_RawTaggedFieldZ(LDKCVec_RawTaggedFieldZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RawTaggedFieldZ)); } + operator LDKCVec_RawTaggedFieldZ() && { LDKCVec_RawTaggedFieldZ res = self; memset(&self, 0, sizeof(LDKCVec_RawTaggedFieldZ)); return res; } + ~CVec_RawTaggedFieldZ() { CVec_RawTaggedFieldZ_free(self); } + CVec_RawTaggedFieldZ& operator=(CVec_RawTaggedFieldZ&& o) { CVec_RawTaggedFieldZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_RawTaggedFieldZ)); return *this; } + LDKCVec_RawTaggedFieldZ* operator &() { return &self; } + LDKCVec_RawTaggedFieldZ* operator ->() { return &self; } + const LDKCVec_RawTaggedFieldZ* operator &() const { return &self; } + const LDKCVec_RawTaggedFieldZ* operator ->() const { return &self; } +}; class CVec_ChannelDetailsZ { private: LDKCVec_ChannelDetailsZ self; @@ -2696,21 +3067,6 @@ public: const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } }; -class CResult_SignDecodeErrorZ { -private: - LDKCResult_SignDecodeErrorZ self; -public: - CResult_SignDecodeErrorZ(const CResult_SignDecodeErrorZ&) = delete; - CResult_SignDecodeErrorZ(CResult_SignDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); } - CResult_SignDecodeErrorZ(LDKCResult_SignDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); } - operator LDKCResult_SignDecodeErrorZ() && { LDKCResult_SignDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); return res; } - ~CResult_SignDecodeErrorZ() { CResult_SignDecodeErrorZ_free(self); } - CResult_SignDecodeErrorZ& operator=(CResult_SignDecodeErrorZ&& o) { CResult_SignDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); return *this; } - LDKCResult_SignDecodeErrorZ* operator &() { return &self; } - LDKCResult_SignDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_SignDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_SignDecodeErrorZ* operator ->() const { return &self; } -}; class CVec_MessageSendEventZ { private: LDKCVec_MessageSendEventZ self; @@ -2726,6 +3082,21 @@ public: const LDKCVec_MessageSendEventZ* operator &() const { return &self; } const LDKCVec_MessageSendEventZ* operator ->() const { return &self; } }; +class CResult_SignDecodeErrorZ { +private: + LDKCResult_SignDecodeErrorZ self; +public: + CResult_SignDecodeErrorZ(const CResult_SignDecodeErrorZ&) = delete; + CResult_SignDecodeErrorZ(CResult_SignDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); } + CResult_SignDecodeErrorZ(LDKCResult_SignDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); } + operator LDKCResult_SignDecodeErrorZ() && { LDKCResult_SignDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignDecodeErrorZ)); return res; } + ~CResult_SignDecodeErrorZ() { CResult_SignDecodeErrorZ_free(self); } + CResult_SignDecodeErrorZ& operator=(CResult_SignDecodeErrorZ&& o) { CResult_SignDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignDecodeErrorZ)); return *this; } + LDKCResult_SignDecodeErrorZ* operator &() { return &self; } + LDKCResult_SignDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_SignDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_SignDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_OutPointScriptZ { private: LDKC2Tuple_OutPointScriptZ self; @@ -2816,20 +3187,20 @@ public: const LDKCVec_TxidZ* operator &() const { return &self; } const LDKCVec_TxidZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +class CResult_NoneMonitorUpdateErrorZ { private: - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self; + LDKCResult_NoneMonitorUpdateErrorZ self; public: - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete; - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } - operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() && { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; } - ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); } - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ& operator=(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return *this; } - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; } - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; } + CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete; + CResult_NoneMonitorUpdateErrorZ(CResult_NoneMonitorUpdateErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); } + CResult_NoneMonitorUpdateErrorZ(LDKCResult_NoneMonitorUpdateErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); } + operator LDKCResult_NoneMonitorUpdateErrorZ() && { LDKCResult_NoneMonitorUpdateErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); return res; } + ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); } + CResult_NoneMonitorUpdateErrorZ& operator=(CResult_NoneMonitorUpdateErrorZ&& o) { CResult_NoneMonitorUpdateErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); return *this; } + LDKCResult_NoneMonitorUpdateErrorZ* operator &() { return &self; } + LDKCResult_NoneMonitorUpdateErrorZ* operator ->() { return &self; } + const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; } + const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; } }; class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { private: @@ -2846,20 +3217,20 @@ public: const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; } const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; } }; -class CResult_NoneMonitorUpdateErrorZ { +class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { private: - LDKCResult_NoneMonitorUpdateErrorZ self; + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self; public: - CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete; - CResult_NoneMonitorUpdateErrorZ(CResult_NoneMonitorUpdateErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); } - CResult_NoneMonitorUpdateErrorZ(LDKCResult_NoneMonitorUpdateErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); } - operator LDKCResult_NoneMonitorUpdateErrorZ() && { LDKCResult_NoneMonitorUpdateErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); return res; } - ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); } - CResult_NoneMonitorUpdateErrorZ& operator=(CResult_NoneMonitorUpdateErrorZ&& o) { CResult_NoneMonitorUpdateErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); return *this; } - LDKCResult_NoneMonitorUpdateErrorZ* operator &() { return &self; } - LDKCResult_NoneMonitorUpdateErrorZ* operator ->() { return &self; } - const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; } - const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete; + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } + operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() && { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; } + ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ& operator=(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return *this; } + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; } + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; } }; class CResult_AcceptChannelDecodeErrorZ { private: @@ -2891,20 +3262,20 @@ public: const LDKCResult_CVec_CVec_u8ZZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_CVec_u8ZZNoneZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +class C2Tuple_PaymentHashPaymentSecretZ { private: - LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ self; + LDKC2Tuple_PaymentHashPaymentSecretZ self; public: - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(const CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&) = delete; - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } - operator LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() && { LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return res; } - ~CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ& operator=(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return *this; } - LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() { return &self; } - LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() const { return &self; } + C2Tuple_PaymentHashPaymentSecretZ(const C2Tuple_PaymentHashPaymentSecretZ&) = delete; + C2Tuple_PaymentHashPaymentSecretZ(C2Tuple_PaymentHashPaymentSecretZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PaymentHashPaymentSecretZ)); } + C2Tuple_PaymentHashPaymentSecretZ(LDKC2Tuple_PaymentHashPaymentSecretZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ)); } + operator LDKC2Tuple_PaymentHashPaymentSecretZ() && { LDKC2Tuple_PaymentHashPaymentSecretZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ)); return res; } + ~C2Tuple_PaymentHashPaymentSecretZ() { C2Tuple_PaymentHashPaymentSecretZ_free(self); } + C2Tuple_PaymentHashPaymentSecretZ& operator=(C2Tuple_PaymentHashPaymentSecretZ&& o) { C2Tuple_PaymentHashPaymentSecretZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PaymentHashPaymentSecretZ)); return *this; } + LDKC2Tuple_PaymentHashPaymentSecretZ* operator &() { return &self; } + LDKC2Tuple_PaymentHashPaymentSecretZ* operator ->() { return &self; } + const LDKC2Tuple_PaymentHashPaymentSecretZ* operator &() const { return &self; } + const LDKC2Tuple_PaymentHashPaymentSecretZ* operator ->() const { return &self; } }; class C2Tuple_BlockHashChannelManagerZ { private: @@ -2936,6 +3307,21 @@ public: const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +private: + LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ self; +public: + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(const CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&) = delete; + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); } + operator LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() && { LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return res; } + ~CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ() { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ& operator=(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ&& o) { CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ)); return *this; } + LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() { return &self; } + LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_SignatureZ { private: LDKCVec_SignatureZ self; @@ -3011,6 +3397,21 @@ public: const LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator &() const { return &self; } const LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator ->() const { return &self; } }; +class CVec_RouteHintZ { +private: + LDKCVec_RouteHintZ self; +public: + CVec_RouteHintZ(const CVec_RouteHintZ&) = delete; + CVec_RouteHintZ(CVec_RouteHintZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHintZ)); } + CVec_RouteHintZ(LDKCVec_RouteHintZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHintZ)); } + operator LDKCVec_RouteHintZ() && { LDKCVec_RouteHintZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHintZ)); return res; } + ~CVec_RouteHintZ() { CVec_RouteHintZ_free(self); } + CVec_RouteHintZ& operator=(CVec_RouteHintZ&& o) { CVec_RouteHintZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_RouteHintZ)); return *this; } + LDKCVec_RouteHintZ* operator &() { return &self; } + LDKCVec_RouteHintZ* operator ->() { return &self; } + const LDKCVec_RouteHintZ* operator &() const { return &self; } + const LDKCVec_RouteHintZ* operator ->() const { return &self; } +}; class CVec_CVec_RouteHopZZ { private: LDKCVec_CVec_RouteHopZZ self; @@ -3086,6 +3487,21 @@ public: const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; } }; +class CResult_DescriptionCreationErrorZ { +private: + LDKCResult_DescriptionCreationErrorZ self; +public: + CResult_DescriptionCreationErrorZ(const CResult_DescriptionCreationErrorZ&) = delete; + CResult_DescriptionCreationErrorZ(CResult_DescriptionCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DescriptionCreationErrorZ)); } + CResult_DescriptionCreationErrorZ(LDKCResult_DescriptionCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DescriptionCreationErrorZ)); } + operator LDKCResult_DescriptionCreationErrorZ() && { LDKCResult_DescriptionCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DescriptionCreationErrorZ)); return res; } + ~CResult_DescriptionCreationErrorZ() { CResult_DescriptionCreationErrorZ_free(self); } + CResult_DescriptionCreationErrorZ& operator=(CResult_DescriptionCreationErrorZ&& o) { CResult_DescriptionCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DescriptionCreationErrorZ)); return *this; } + LDKCResult_DescriptionCreationErrorZ* operator &() { return &self; } + LDKCResult_DescriptionCreationErrorZ* operator ->() { return &self; } + const LDKCResult_DescriptionCreationErrorZ* operator &() const { return &self; } + const LDKCResult_DescriptionCreationErrorZ* operator ->() const { return &self; } +}; class CResult_RoutingFeesDecodeErrorZ { private: LDKCResult_RoutingFeesDecodeErrorZ self; @@ -3101,6 +3517,21 @@ public: const LDKCResult_RoutingFeesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RoutingFeesDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_PayeePubKeyErrorZ { +private: + LDKCResult_PayeePubKeyErrorZ self; +public: + CResult_PayeePubKeyErrorZ(const CResult_PayeePubKeyErrorZ&) = delete; + CResult_PayeePubKeyErrorZ(CResult_PayeePubKeyErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PayeePubKeyErrorZ)); } + CResult_PayeePubKeyErrorZ(LDKCResult_PayeePubKeyErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PayeePubKeyErrorZ)); } + operator LDKCResult_PayeePubKeyErrorZ() && { LDKCResult_PayeePubKeyErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PayeePubKeyErrorZ)); return res; } + ~CResult_PayeePubKeyErrorZ() { CResult_PayeePubKeyErrorZ_free(self); } + CResult_PayeePubKeyErrorZ& operator=(CResult_PayeePubKeyErrorZ&& o) { CResult_PayeePubKeyErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PayeePubKeyErrorZ)); return *this; } + LDKCResult_PayeePubKeyErrorZ* operator &() { return &self; } + LDKCResult_PayeePubKeyErrorZ* operator ->() { return &self; } + const LDKCResult_PayeePubKeyErrorZ* operator &() const { return &self; } + const LDKCResult_PayeePubKeyErrorZ* operator ->() const { return &self; } +}; class CResult_QueryShortChannelIdsDecodeErrorZ { private: LDKCResult_QueryShortChannelIdsDecodeErrorZ self; @@ -3116,6 +3547,21 @@ public: const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceSemanticErrorZ { +private: + LDKCResult_InvoiceSemanticErrorZ self; +public: + CResult_InvoiceSemanticErrorZ(const CResult_InvoiceSemanticErrorZ&) = delete; + CResult_InvoiceSemanticErrorZ(CResult_InvoiceSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); } + CResult_InvoiceSemanticErrorZ(LDKCResult_InvoiceSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); } + operator LDKCResult_InvoiceSemanticErrorZ() && { LDKCResult_InvoiceSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); return res; } + ~CResult_InvoiceSemanticErrorZ() { CResult_InvoiceSemanticErrorZ_free(self); } + CResult_InvoiceSemanticErrorZ& operator=(CResult_InvoiceSemanticErrorZ&& o) { CResult_InvoiceSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); return *this; } + LDKCResult_InvoiceSemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceSemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceSemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceSemanticErrorZ* operator ->() const { return &self; } +}; class CResult_UpdateAddHTLCDecodeErrorZ { private: LDKCResult_UpdateAddHTLCDecodeErrorZ self; @@ -3176,21 +3622,6 @@ public: const LDKCVec_NetAddressZ* operator &() const { return &self; } const LDKCVec_NetAddressZ* operator ->() const { return &self; } }; -class CVec_PublicKeyZ { -private: - LDKCVec_PublicKeyZ self; -public: - CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete; - CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); } - CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); } - operator LDKCVec_PublicKeyZ() && { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; } - ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); } - CVec_PublicKeyZ& operator=(CVec_PublicKeyZ&& o) { CVec_PublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PublicKeyZ)); return *this; } - LDKCVec_PublicKeyZ* operator &() { return &self; } - LDKCVec_PublicKeyZ* operator ->() { return &self; } - const LDKCVec_PublicKeyZ* operator &() const { return &self; } - const LDKCVec_PublicKeyZ* operator ->() const { return &self; } -}; class CVec_C2Tuple_usizeTransactionZZ { private: LDKCVec_C2Tuple_usizeTransactionZZ self; @@ -3206,6 +3637,21 @@ public: const LDKCVec_C2Tuple_usizeTransactionZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; } }; +class CVec_PublicKeyZ { +private: + LDKCVec_PublicKeyZ self; +public: + CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete; + CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); } + CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); } + operator LDKCVec_PublicKeyZ() && { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; } + ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); } + CVec_PublicKeyZ& operator=(CVec_PublicKeyZ&& o) { CVec_PublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PublicKeyZ)); return *this; } + LDKCVec_PublicKeyZ* operator &() { return &self; } + LDKCVec_PublicKeyZ* operator ->() { return &self; } + const LDKCVec_PublicKeyZ* operator &() const { return &self; } + const LDKCVec_PublicKeyZ* operator ->() const { return &self; } +}; class CResult_DirectionalChannelInfoDecodeErrorZ { private: LDKCResult_DirectionalChannelInfoDecodeErrorZ self; @@ -3341,6 +3787,21 @@ public: const LDKCVec_EventZ* operator &() const { return &self; } const LDKCVec_EventZ* operator ->() const { return &self; } }; +class CResult_NoneSemanticErrorZ { +private: + LDKCResult_NoneSemanticErrorZ self; +public: + CResult_NoneSemanticErrorZ(const CResult_NoneSemanticErrorZ&) = delete; + CResult_NoneSemanticErrorZ(CResult_NoneSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneSemanticErrorZ)); } + CResult_NoneSemanticErrorZ(LDKCResult_NoneSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneSemanticErrorZ)); } + operator LDKCResult_NoneSemanticErrorZ() && { LDKCResult_NoneSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneSemanticErrorZ)); return res; } + ~CResult_NoneSemanticErrorZ() { CResult_NoneSemanticErrorZ_free(self); } + CResult_NoneSemanticErrorZ& operator=(CResult_NoneSemanticErrorZ&& o) { CResult_NoneSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneSemanticErrorZ)); return *this; } + LDKCResult_NoneSemanticErrorZ* operator &() { return &self; } + LDKCResult_NoneSemanticErrorZ* operator ->() { return &self; } + const LDKCResult_NoneSemanticErrorZ* operator &() const { return &self; } + const LDKCResult_NoneSemanticErrorZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_u32ScriptZZ { private: LDKCVec_C2Tuple_u32ScriptZZ self; @@ -3521,6 +3982,21 @@ public: const LDKCResult_NodeFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_u5Z { +private: + LDKCVec_u5Z self; +public: + CVec_u5Z(const CVec_u5Z&) = delete; + CVec_u5Z(CVec_u5Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u5Z)); } + CVec_u5Z(LDKCVec_u5Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u5Z)); } + operator LDKCVec_u5Z() && { LDKCVec_u5Z res = self; memset(&self, 0, sizeof(LDKCVec_u5Z)); return res; } + ~CVec_u5Z() { CVec_u5Z_free(self); } + CVec_u5Z& operator=(CVec_u5Z&& o) { CVec_u5Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u5Z)); return *this; } + LDKCVec_u5Z* operator &() { return &self; } + LDKCVec_u5Z* operator ->() { return &self; } + const LDKCVec_u5Z* operator &() const { return &self; } + const LDKCVec_u5Z* operator ->() const { return &self; } +}; class CResult_ReplyShortChannelIdsEndDecodeErrorZ { private: LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ self; @@ -3536,21 +4012,6 @@ public: const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InMemorySignerDecodeErrorZ { -private: - LDKCResult_InMemorySignerDecodeErrorZ self; -public: - CResult_InMemorySignerDecodeErrorZ(const CResult_InMemorySignerDecodeErrorZ&) = delete; - CResult_InMemorySignerDecodeErrorZ(CResult_InMemorySignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); } - CResult_InMemorySignerDecodeErrorZ(LDKCResult_InMemorySignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); } - operator LDKCResult_InMemorySignerDecodeErrorZ() && { LDKCResult_InMemorySignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); return res; } - ~CResult_InMemorySignerDecodeErrorZ() { CResult_InMemorySignerDecodeErrorZ_free(self); } - CResult_InMemorySignerDecodeErrorZ& operator=(CResult_InMemorySignerDecodeErrorZ&& o) { CResult_InMemorySignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); return *this; } - LDKCResult_InMemorySignerDecodeErrorZ* operator &() { return &self; } - LDKCResult_InMemorySignerDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InMemorySignerDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InMemorySignerDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_u32ScriptZ { private: LDKC2Tuple_u32ScriptZ self; @@ -3581,35 +4042,35 @@ public: const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +class CResult_InMemorySignerDecodeErrorZ { private: - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ self; + LDKCResult_InMemorySignerDecodeErrorZ self; public: - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ(const CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&) = delete; - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); } - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); } - operator LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ() && { LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); return res; } - ~CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ() { CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(self); } - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ& operator=(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&& o) { CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); return *this; } - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator &() { return &self; } - LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator ->() const { return &self; } + CResult_InMemorySignerDecodeErrorZ(const CResult_InMemorySignerDecodeErrorZ&) = delete; + CResult_InMemorySignerDecodeErrorZ(CResult_InMemorySignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); } + CResult_InMemorySignerDecodeErrorZ(LDKCResult_InMemorySignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); } + operator LDKCResult_InMemorySignerDecodeErrorZ() && { LDKCResult_InMemorySignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InMemorySignerDecodeErrorZ)); return res; } + ~CResult_InMemorySignerDecodeErrorZ() { CResult_InMemorySignerDecodeErrorZ_free(self); } + CResult_InMemorySignerDecodeErrorZ& operator=(CResult_InMemorySignerDecodeErrorZ&& o) { CResult_InMemorySignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InMemorySignerDecodeErrorZ)); return *this; } + LDKCResult_InMemorySignerDecodeErrorZ* operator &() { return &self; } + LDKCResult_InMemorySignerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InMemorySignerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InMemorySignerDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_BuiltCommitmentTransactionDecodeErrorZ { +class CResult_PaymentSecretAPIErrorZ { private: - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ self; + LDKCResult_PaymentSecretAPIErrorZ self; public: - CResult_BuiltCommitmentTransactionDecodeErrorZ(const CResult_BuiltCommitmentTransactionDecodeErrorZ&) = delete; - CResult_BuiltCommitmentTransactionDecodeErrorZ(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); } - CResult_BuiltCommitmentTransactionDecodeErrorZ(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); } - operator LDKCResult_BuiltCommitmentTransactionDecodeErrorZ() && { LDKCResult_BuiltCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); return res; } - ~CResult_BuiltCommitmentTransactionDecodeErrorZ() { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); } - CResult_BuiltCommitmentTransactionDecodeErrorZ& operator=(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); return *this; } - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() { return &self; } - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } + CResult_PaymentSecretAPIErrorZ(const CResult_PaymentSecretAPIErrorZ&) = delete; + CResult_PaymentSecretAPIErrorZ(CResult_PaymentSecretAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentSecretAPIErrorZ)); } + CResult_PaymentSecretAPIErrorZ(LDKCResult_PaymentSecretAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentSecretAPIErrorZ)); } + operator LDKCResult_PaymentSecretAPIErrorZ() && { LDKCResult_PaymentSecretAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentSecretAPIErrorZ)); return res; } + ~CResult_PaymentSecretAPIErrorZ() { CResult_PaymentSecretAPIErrorZ_free(self); } + CResult_PaymentSecretAPIErrorZ& operator=(CResult_PaymentSecretAPIErrorZ&& o) { CResult_PaymentSecretAPIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentSecretAPIErrorZ)); return *this; } + LDKCResult_PaymentSecretAPIErrorZ* operator &() { return &self; } + LDKCResult_PaymentSecretAPIErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentSecretAPIErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentSecretAPIErrorZ* operator ->() const { return &self; } }; class CResult_RouteDecodeErrorZ { private: @@ -3626,6 +4087,36 @@ public: const LDKCResult_RouteDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RouteDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_BuiltCommitmentTransactionDecodeErrorZ { +private: + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ self; +public: + CResult_BuiltCommitmentTransactionDecodeErrorZ(const CResult_BuiltCommitmentTransactionDecodeErrorZ&) = delete; + CResult_BuiltCommitmentTransactionDecodeErrorZ(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); } + CResult_BuiltCommitmentTransactionDecodeErrorZ(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); } + operator LDKCResult_BuiltCommitmentTransactionDecodeErrorZ() && { LDKCResult_BuiltCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); return res; } + ~CResult_BuiltCommitmentTransactionDecodeErrorZ() { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); } + CResult_BuiltCommitmentTransactionDecodeErrorZ& operator=(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); return *this; } + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() { return &self; } + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +private: + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ self; +public: + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ(const CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&) = delete; + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); } + operator LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ() && { LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); return res; } + ~CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ() { CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(self); } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ& operator=(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ&& o) { CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ)); return *this; } + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator &() { return &self; } + LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_UpdateFailHTLCZ { private: LDKCVec_UpdateFailHTLCZ self; diff --git a/lightning-c-bindings/include/rust_types.h b/lightning-c-bindings/include/rust_types.h index 12dbd36..105348a 100644 --- a/lightning-c-bindings/include/rust_types.h +++ b/lightning-c-bindings/include/rust_types.h @@ -40,6 +40,32 @@ struct nativeCommitmentTransactionOpaque; typedef struct nativeCommitmentTransactionOpaque LDKnativeCommitmentTransaction; struct nativeTrustedCommitmentTransactionOpaque; typedef struct nativeTrustedCommitmentTransactionOpaque LDKnativeTrustedCommitmentTransaction; +struct nativeInvoiceOpaque; +typedef struct nativeInvoiceOpaque LDKnativeInvoice; +struct nativeSignedRawInvoiceOpaque; +typedef struct nativeSignedRawInvoiceOpaque LDKnativeSignedRawInvoice; +struct nativeRawInvoiceOpaque; +typedef struct nativeRawInvoiceOpaque LDKnativeRawInvoice; +struct nativeRawDataPartOpaque; +typedef struct nativeRawDataPartOpaque LDKnativeRawDataPart; +struct nativePositiveTimestampOpaque; +typedef struct nativePositiveTimestampOpaque LDKnativePositiveTimestamp; +struct nativeSha256Opaque; +typedef struct nativeSha256Opaque LDKnativeSha256; +struct nativeDescriptionOpaque; +typedef struct nativeDescriptionOpaque LDKnativeDescription; +struct nativePayeePubKeyOpaque; +typedef struct nativePayeePubKeyOpaque LDKnativePayeePubKey; +struct nativePaymentSecretOpaque; +typedef struct nativePaymentSecretOpaque LDKnativePaymentSecret; +struct nativeExpiryTimeOpaque; +typedef struct nativeExpiryTimeOpaque LDKnativeExpiryTime; +struct nativeMinFinalCltvExpiryOpaque; +typedef struct nativeMinFinalCltvExpiryOpaque LDKnativeMinFinalCltvExpiry; +struct nativeInvoiceSignatureOpaque; +typedef struct nativeInvoiceSignatureOpaque LDKnativeInvoiceSignature; +struct nativeRouteHintOpaque; +typedef struct nativeRouteHintOpaque LDKnativeRouteHint; struct nativeChannelMonitorUpdateOpaque; typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate; struct nativeMonitorUpdateErrorOpaque; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index f875efb..37270e3 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -1368,6 +1368,919 @@ impl Clone for CResult_CVec_SignatureZNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { orig.clone() } #[repr(C)] +/// A dynamically-allocated array of crate::lightning_invoice::RawTaggedFields of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RawTaggedFieldZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_invoice::RawTaggedField, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_RawTaggedFieldZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::RawTaggedField] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_RawTaggedFieldZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RawTaggedFieldZ_free(_res: CVec_RawTaggedFieldZ) { } +impl Drop for CVec_RawTaggedFieldZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_RawTaggedFieldZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::u5s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_u5Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::u5, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_u5Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::u5] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_u5Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_u5Z_free(_res: CVec_u5Z) { } +impl Drop for CVec_u5Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_u5Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of u8s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_u8Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut u8, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_u8Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_u8Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } +impl Drop for CVec_u8Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_u8Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_RawInvoice_u832InvoiceSignatureZ { + /// The element at position 0 + pub a: crate::lightning_invoice::RawInvoice, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, + /// The element at position 2 + pub c: crate::lightning_invoice::InvoiceSignature, +} +impl From<(crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature)> for C3Tuple_RawInvoice_u832InvoiceSignatureZ { + fn from (tup: (crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_RawInvoice_u832InvoiceSignatureZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature) { + (self.a, self.b, self.c) + } +} +/// Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a: crate::lightning_invoice::RawInvoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::InvoiceSignature) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { + C3Tuple_RawInvoice_u832InvoiceSignatureZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. +pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res: C3Tuple_RawInvoice_u832InvoiceSignatureZ) { } +#[repr(C)] +/// The contents of CResult_PayeePubKeyErrorZ +pub union CResult_PayeePubKeyErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_invoice::PayeePubKey, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::c_types::Secp256k1Error, +} +#[repr(C)] +/// A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PayeePubKeyErrorZ { + /// The contents of this CResult_PayeePubKeyErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PayeePubKeyErrorZPtr, + /// Whether this CResult_PayeePubKeyErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PayeePubKeyErrorZ in the success state. +pub extern "C" fn CResult_PayeePubKeyErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeyErrorZ { + CResult_PayeePubKeyErrorZ { + contents: CResult_PayeePubKeyErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PayeePubKeyErrorZ in the error state. +pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeyErrorZ { + CResult_PayeePubKeyErrorZ { + contents: CResult_PayeePubKeyErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_PayeePubKeyErrorZ. +pub extern "C" fn CResult_PayeePubKeyErrorZ_free(_res: CResult_PayeePubKeyErrorZ) { } +impl Drop for CResult_PayeePubKeyErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PayeePubKeyErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_PayeePubKeyErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_PayeePubKeyErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning_invoice::RouteHints of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RouteHintZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_invoice::RouteHint, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_RouteHintZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::RouteHint] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_RouteHintZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } +impl Drop for CVec_RouteHintZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_RouteHintZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a u64 or not +pub enum COption_u64Z { + /// When we're in this state, this COption_u64Z contains a u64 + Some(u64), + /// When we're in this state, this COption_u64Z contains nothing + None +} +impl COption_u64Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::Some(_) = self { true } else { false } + } + #[allow(unused)] pub(crate) fn take(mut self) -> u64 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_u64Z containing a u64 +pub extern "C" fn COption_u64Z_some(o: u64) -> COption_u64Z { + COption_u64Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u64Z containing nothing +pub extern "C" fn COption_u64Z_none() -> COption_u64Z { + COption_u64Z::None +} +#[no_mangle] +/// Frees any resources associated with the u64, if we are in the Some state +pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } +#[no_mangle] +/// Creates a new COption_u64Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { orig.clone() } +#[repr(C)] +/// The contents of CResult_PositiveTimestampCreationErrorZ +pub union CResult_PositiveTimestampCreationErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_invoice::PositiveTimestamp, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::CreationError, +} +#[repr(C)] +/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PositiveTimestampCreationErrorZ { + /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PositiveTimestampCreationErrorZPtr, + /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } +impl Drop for CResult_PositiveTimestampCreationErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PositiveTimestampCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_PositiveTimestampCreationErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_PositiveTimestampCreationErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PositiveTimestampCreationErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_NoneSemanticErrorZ +pub union CResult_NoneSemanticErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut std::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::SemanticError, +} +#[repr(C)] +/// A CResult_NoneSemanticErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning_invoice::SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NoneSemanticErrorZ { + /// The contents of this CResult_NoneSemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneSemanticErrorZPtr, + /// Whether this CResult_NoneSemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NoneSemanticErrorZ in the success state. +pub extern "C" fn CResult_NoneSemanticErrorZ_ok() -> CResult_NoneSemanticErrorZ { + CResult_NoneSemanticErrorZ { + contents: CResult_NoneSemanticErrorZPtr { + result: std::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NoneSemanticErrorZ in the error state. +pub extern "C" fn CResult_NoneSemanticErrorZ_err(e: crate::lightning_invoice::SemanticError) -> CResult_NoneSemanticErrorZ { + CResult_NoneSemanticErrorZ { + contents: CResult_NoneSemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_NoneSemanticErrorZ. +pub extern "C" fn CResult_NoneSemanticErrorZ_free(_res: CResult_NoneSemanticErrorZ) { } +impl Drop for CResult_NoneSemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NoneSemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = std::ptr::null_mut(); + CResult_NoneSemanticErrorZPtr { result: std::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_NoneSemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneSemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneSemanticErrorZPtr { + result: std::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneSemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneSemanticErrorZ_clone(orig: &CResult_NoneSemanticErrorZ) -> CResult_NoneSemanticErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_InvoiceSemanticErrorZ +pub union CResult_InvoiceSemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_invoice::Invoice, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::SemanticError, +} +#[repr(C)] +/// A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceSemanticErrorZ { + /// The contents of this CResult_InvoiceSemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceSemanticErrorZPtr, + /// Whether this CResult_InvoiceSemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InvoiceSemanticErrorZ in the success state. +pub extern "C" fn CResult_InvoiceSemanticErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceSemanticErrorZ { + CResult_InvoiceSemanticErrorZ { + contents: CResult_InvoiceSemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceSemanticErrorZ in the error state. +pub extern "C" fn CResult_InvoiceSemanticErrorZ_err(e: crate::lightning_invoice::SemanticError) -> CResult_InvoiceSemanticErrorZ { + CResult_InvoiceSemanticErrorZ { + contents: CResult_InvoiceSemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_InvoiceSemanticErrorZ. +pub extern "C" fn CResult_InvoiceSemanticErrorZ_free(_res: CResult_InvoiceSemanticErrorZ) { } +impl Drop for CResult_InvoiceSemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InvoiceSemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_InvoiceSemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_InvoiceSemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InvoiceSemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_InvoiceSemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InvoiceSemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InvoiceSemanticErrorZ_clone(orig: &CResult_InvoiceSemanticErrorZ) -> CResult_InvoiceSemanticErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_DescriptionCreationErrorZ +pub union CResult_DescriptionCreationErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_invoice::Description, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::CreationError, +} +#[repr(C)] +/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_DescriptionCreationErrorZ { + /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_DescriptionCreationErrorZPtr, + /// Whether this CResult_DescriptionCreationErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_DescriptionCreationErrorZ in the success state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_DescriptionCreationErrorZ in the error state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_DescriptionCreationErrorZ. +pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } +impl Drop for CResult_DescriptionCreationErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_DescriptionCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_DescriptionCreationErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_DescriptionCreationErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_DescriptionCreationErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { orig.clone() } +#[repr(C)] +/// The contents of CResult_ExpiryTimeCreationErrorZ +pub union CResult_ExpiryTimeCreationErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_invoice::ExpiryTime, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::CreationError, +} +#[repr(C)] +/// A CResult_ExpiryTimeCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::ExpiryTime on success and a crate::lightning_invoice::CreationError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ExpiryTimeCreationErrorZ { + /// The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ExpiryTimeCreationErrorZPtr, + /// Whether this CResult_ExpiryTimeCreationErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ExpiryTimeCreationErrorZ in the success state. +pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_ok(o: crate::lightning_invoice::ExpiryTime) -> CResult_ExpiryTimeCreationErrorZ { + CResult_ExpiryTimeCreationErrorZ { + contents: CResult_ExpiryTimeCreationErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ExpiryTimeCreationErrorZ in the error state. +pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_ExpiryTimeCreationErrorZ { + CResult_ExpiryTimeCreationErrorZ { + contents: CResult_ExpiryTimeCreationErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_ExpiryTimeCreationErrorZ. +pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_free(_res: CResult_ExpiryTimeCreationErrorZ) { } +impl Drop for CResult_ExpiryTimeCreationErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ExpiryTimeCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_ExpiryTimeCreationErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_ExpiryTimeCreationErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ExpiryTimeCreationErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ExpiryTimeCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ExpiryTimeCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ExpiryTimeCreationErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_clone(orig: &CResult_ExpiryTimeCreationErrorZ) -> CResult_ExpiryTimeCreationErrorZ { orig.clone() } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RouteHintHopZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::routing::router::RouteHintHop, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_RouteHintHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_RouteHintHopZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHintHopZ_free(_res: CVec_RouteHintHopZ) { } +impl Drop for CVec_RouteHintHopZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_RouteHintHopZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_RouteHintCreationErrorZ +pub union CResult_RouteHintCreationErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_invoice::RouteHint, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::CreationError, +} +#[repr(C)] +/// A CResult_RouteHintCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::RouteHint on success and a crate::lightning_invoice::CreationError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RouteHintCreationErrorZ { + /// The contents of this CResult_RouteHintCreationErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RouteHintCreationErrorZPtr, + /// Whether this CResult_RouteHintCreationErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RouteHintCreationErrorZ in the success state. +pub extern "C" fn CResult_RouteHintCreationErrorZ_ok(o: crate::lightning_invoice::RouteHint) -> CResult_RouteHintCreationErrorZ { + CResult_RouteHintCreationErrorZ { + contents: CResult_RouteHintCreationErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RouteHintCreationErrorZ in the error state. +pub extern "C" fn CResult_RouteHintCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_RouteHintCreationErrorZ { + CResult_RouteHintCreationErrorZ { + contents: CResult_RouteHintCreationErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_RouteHintCreationErrorZ. +pub extern "C" fn CResult_RouteHintCreationErrorZ_free(_res: CResult_RouteHintCreationErrorZ) { } +impl Drop for CResult_RouteHintCreationErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RouteHintCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_RouteHintCreationErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_RouteHintCreationErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RouteHintCreationErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RouteHintCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RouteHintCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RouteHintCreationErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RouteHintCreationErrorZ_clone(orig: &CResult_RouteHintCreationErrorZ) -> CResult_RouteHintCreationErrorZ { orig.clone() } +#[repr(C)] /// The contents of CResult_StringErrorZ pub union CResult_StringErrorZPtr { /// A pointer to the contents in the success state. @@ -1731,6 +2644,18 @@ impl C2Tuple_OutPointScriptZ { (self.a, self.b) } } +impl Clone for C2Tuple_OutPointScriptZ { + fn clone(&self) -> Self { + Self { + a: self.a.clone(), + b: self.b.clone(), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { orig.clone() } /// Creates a new C2Tuple_OutPointScriptZ from the contained elements. #[no_mangle] pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ { @@ -1761,6 +2686,18 @@ impl C2Tuple_u32ScriptZ { (self.a, self.b) } } +impl Clone for C2Tuple_u32ScriptZ { + fn clone(&self) -> Self { + Self { + a: self.a.clone(), + b: self.b.clone(), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { orig.clone() } /// Creates a new C2Tuple_u32ScriptZ from the contained elements. #[no_mangle] pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { @@ -1808,6 +2745,14 @@ impl Drop for CVec_C2Tuple_u32ScriptZZ { unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } +impl Clone for CVec_C2Tuple_u32ScriptZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { @@ -2643,40 +3588,6 @@ impl Clone for CResult_RouteDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { orig.clone() } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a u64 or not -pub enum COption_u64Z { - /// When we're in this state, this COption_u64Z contains a u64 - Some(u64), - /// When we're in this state, this COption_u64Z contains nothing - None -} -impl COption_u64Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::Some(_) = self { true } else { false } - } - #[allow(unused)] pub(crate) fn take(mut self) -> u64 { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_u64Z containing a u64 -pub extern "C" fn COption_u64Z_some(o: u64) -> COption_u64Z { - COption_u64Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_u64Z containing nothing -pub extern "C" fn COption_u64Z_none() -> COption_u64Z { - COption_u64Z::None -} -#[no_mangle] -/// Frees any resources associated with the u64, if we are in the Some state -pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } -#[no_mangle] -/// Creates a new COption_u64Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { orig.clone() } -#[repr(C)] /// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_ChannelDetailsZ { @@ -2723,52 +3634,6 @@ impl Clone for CVec_ChannelDetailsZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHintHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHintHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHintHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHintHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintHopZ_free(_res: CVec_RouteHintHopZ) { } -impl Drop for CVec_RouteHintHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHintHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] /// The contents of CResult_RouteLightningErrorZ pub union CResult_RouteLightningErrorZPtr { /// A pointer to the contents in the success state. @@ -3260,52 +4125,6 @@ impl Drop for CVec_PublicKeyZ { } } #[repr(C)] -/// A dynamically-allocated array of u8s of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_u8Z { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u8, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_u8Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = std::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { - unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_u8Z { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } -impl Drop for CVec_u8Z { - fn drop(&mut self) { - if self.datalen == 0 { return; } - unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_u8Z { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] /// The contents of CResult_CVec_u8ZPeerHandleErrorZ pub union CResult_CVec_u8ZPeerHandleErrorZPtr { /// A pointer to the contents in the success state. @@ -9048,6 +9867,110 @@ impl Clone for CResult_NonePaymentSendFailureZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { orig.clone() } #[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PaymentHashPaymentSecretZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentSecretZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PaymentHashPaymentSecretZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentSecretZ { + C2Tuple_PaymentHashPaymentSecretZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_free(_res: C2Tuple_PaymentHashPaymentSecretZ) { } +#[repr(C)] +/// The contents of CResult_PaymentSecretAPIErrorZ +pub union CResult_PaymentSecretAPIErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::util::errors::APIError, +} +#[repr(C)] +/// A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentSecretAPIErrorZ { + /// The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentSecretAPIErrorZPtr, + /// Whether this CResult_PaymentSecretAPIErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PaymentSecretAPIErrorZ in the success state. +pub extern "C" fn CResult_PaymentSecretAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretAPIErrorZ { + CResult_PaymentSecretAPIErrorZ { + contents: CResult_PaymentSecretAPIErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PaymentSecretAPIErrorZ in the error state. +pub extern "C" fn CResult_PaymentSecretAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentSecretAPIErrorZ { + CResult_PaymentSecretAPIErrorZ { + contents: CResult_PaymentSecretAPIErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_PaymentSecretAPIErrorZ. +pub extern "C" fn CResult_PaymentSecretAPIErrorZ_free(_res: CResult_PaymentSecretAPIErrorZ) { } +impl Drop for CResult_PaymentSecretAPIErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PaymentSecretAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = std::ptr::null_mut() }; + CResult_PaymentSecretAPIErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_PaymentSecretAPIErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] /// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_ChannelMonitorZ { diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index 823f021..3485c46 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -16,8 +16,8 @@ #![allow(unused_parens)] #![allow(unused_unsafe)] #![allow(unused_braces)] -#![deny(missing_docs)] pub mod c_types; pub mod bitcoin; pub mod lightning; pub mod lightning_persister; +pub mod lightning_invoice; diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index 5450998..99e3956 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -12,6 +12,7 @@ //! Includes traits for monitoring and receiving notifications of new blocks and block //! disconnections, transaction broadcasting, and feerate information requests. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index c66edd7..9832df4 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -22,6 +22,7 @@ //! events. The remote server would make use of [`ChainMonitor`] for block processing and for //! servicing [`ChannelMonitor`] updates from the client. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -94,6 +95,76 @@ pub extern "C" fn ChainMonitor_new(chain_source: *mut crate::lightning::chain::F ChainMonitor { inner: Box::into_raw(Box::new(ret)), is_owned: true } } +impl From for crate::lightning::chain::Listen { + fn from(obj: nativeChainMonitor) -> Self { + let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChainMonitor_as_Listen(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChainMonitor_free_void); + ret + } +} +/// Constructs a new Listen which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChainMonitor_as_Listen(this_arg: &ChainMonitor) -> crate::lightning::chain::Listen { + crate::lightning::chain::Listen { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + block_connected: ChainMonitor_Listen_block_connected, + block_disconnected: ChainMonitor_Listen_block_disconnected, + } +} + +extern "C" fn ChainMonitor_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) { + >::block_connected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) +} +extern "C" fn ChainMonitor_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { + >::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} + +impl From for crate::lightning::chain::Confirm { + fn from(obj: nativeChainMonitor) -> Self { + let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChainMonitor_as_Confirm(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChainMonitor_free_void); + ret + } +} +/// Constructs a new Confirm which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChainMonitor_as_Confirm(this_arg: &ChainMonitor) -> crate::lightning::chain::Confirm { + crate::lightning::chain::Confirm { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + transactions_confirmed: ChainMonitor_Confirm_transactions_confirmed, + transaction_unconfirmed: ChainMonitor_Confirm_transaction_unconfirmed, + best_block_updated: ChainMonitor_Confirm_best_block_updated, + get_relevant_txids: ChainMonitor_Confirm_get_relevant_txids, + } +} + +extern "C" fn ChainMonitor_Confirm_transactions_confirmed(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + >::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) +} +extern "C" fn ChainMonitor_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) { + >::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) +} +extern "C" fn ChainMonitor_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { + >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} +#[must_use] +extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_TxidZ { + let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; + local_ret.into() +} + impl From for crate::lightning::chain::Watch { fn from(obj: nativeChainMonitor) -> Self { let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index e145f3d..2338270 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -19,6 +19,7 @@ //! security-domain-separated system design, you should consider having multiple paths for //! ChannelMonitors to get out of the HSM and onto monitoring devices. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs index 09c70f4..140461f 100644 --- a/lightning-c-bindings/src/lightning/chain/keysinterface.rs +++ b/lightning-c-bindings/src/lightning/chain/keysinterface.rs @@ -10,6 +10,7 @@ //! spendable on-chain outputs which the user owns and is responsible for using just as any other //! on-chain output which is theirs. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index 64f548d..18b3fdb 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -8,6 +8,7 @@ //! Structs and traits which allow other parts of rust-lightning to interact with the blockchain. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -210,7 +211,7 @@ pub struct Confirm { /// in the event of a chain reorganization, it must not be called with a `header` that is no /// longer in the chain as of the last call to [`best_block_updated`]. /// - /// [chain order]: Self#order + /// [chain order]: Confirm#Order /// [`best_block_updated`]: Self::best_block_updated pub transactions_confirmed: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, height: u32), /// Processes a transaction that is no longer confirmed as result of a chain reorganization. diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs index b4ea08c..05667fd 100644 --- a/lightning-c-bindings/src/lightning/chain/transaction.rs +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -8,6 +8,7 @@ //! Types describing on-chain transactions. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index 6752123..aadf315 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -9,6 +9,7 @@ //! Various utilities for building scripts and deriving keys related to channels. These are //! largely of interest for those implementing chain::keysinterface::Sign message signing by hand. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 90952e7..be2a55e 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -17,6 +17,7 @@ //! imply it needs to fail HTLCs/payments/channels it manages). //! +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -299,6 +300,12 @@ pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIM #[no_mangle] pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA; +/// Minimum CLTV difference between the current block height and received inbound payments. +/// Invoices generated for payment to us must set their `min_final_cltv_expiry` field to at least +/// this value. + +#[no_mangle] +pub static MIN_FINAL_CLTV_EXPIRY: u32 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY; use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport; type nativeChannelDetails = nativeChannelDetailsImport; @@ -883,9 +890,8 @@ pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &ChannelManager) /// HTLC backwards has been started. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32], mut payment_secret: crate::c_types::ThirtyTwoBytes) -> bool { - let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) }; - let mut ret = unsafe { &*this_arg.inner }.fail_htlc_backwards(&::lightning::ln::channelmanager::PaymentHash(unsafe { *payment_hash }), &local_payment_secret); +pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32]) -> bool { + let mut ret = unsafe { &*this_arg.inner }.fail_htlc_backwards(&::lightning::ln::channelmanager::PaymentHash(unsafe { *payment_hash })); ret } @@ -893,22 +899,19 @@ pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, /// generating message events for the net layer to claim the payment, if possible. Thus, you /// should probably kick the net layer to go send messages if this returns true! /// -/// You must specify the expected amounts for this HTLC, and we will only claim HTLCs -/// available within a few percent of the expected amount. This is critical for several -/// reasons : a) it avoids providing senders with `proof-of-payment` (in the form of the -/// payment_preimage without having provided the full value and b) it avoids certain -/// privacy-breaking recipient-probing attacks which may reveal payment activity to -/// motivated attackers. -/// -/// Note that the privacy concerns in (b) are not relevant in payments with a payment_secret -/// set. Thus, for such payments we will claim any payments which do not under-pay. +/// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or +/// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived` +/// event matches your expectation. If you fail to do so and call this method, you may provide +/// the sender \"proof-of-payment\" when they did not fulfill the full expected payment. /// /// May panic if called except in response to a PaymentReceived event. +/// +/// [`create_inbound_payment`]: Self::create_inbound_payment +/// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut expected_amount: u64) -> bool { - let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) }; - let mut ret = unsafe { &*this_arg.inner }.claim_funds(::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data), &local_payment_secret, expected_amount); +pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) -> bool { + let mut ret = unsafe { &*this_arg.inner }.claim_funds(::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data)); ret } @@ -945,6 +948,81 @@ pub extern "C" fn ChannelManager_channel_monitor_updated(this_arg: &ChannelManag unsafe { &*this_arg.inner }.channel_monitor_updated(unsafe { &*funding_txo.inner }, highest_applied_update_id) } +/// Gets a payment secret and payment hash for use in an invoice given to a third party wishing +/// to pay us. +/// +/// This differs from [`create_inbound_payment_for_hash`] only in that it generates the +/// [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second. +/// +/// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which +/// will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be +/// passed directly to [`claim_funds`]. +/// +/// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. +/// +/// [`claim_funds`]: Self::claim_funds +/// [`PaymentReceived`]: events::Event::PaymentReceived +/// [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage +/// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &ChannelManager, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, mut user_payment_id: u64) -> crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ { + let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; + let mut ret = unsafe { &*this_arg.inner }.create_inbound_payment(local_min_value_msat, invoice_expiry_delta_secs, user_payment_id); + let (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1.0 }).into(); + local_ret +} + +/// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is +/// stored external to LDK. +/// +/// A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a +/// payment secret fetched via this method or [`create_inbound_payment`], and which is at least +/// the `min_value_msat` provided here, if one is provided. +/// +/// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This +/// method may return an Err if another payment with the same payment_hash is still pending. +/// +/// `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to +/// allow tracking of which events correspond with which calls to this and +/// [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply +/// copied to events and otherwise ignored. It may be used to correlate PaymentReceived events +/// with invoice metadata stored elsewhere. +/// +/// `min_value_msat` should be set if the invoice being generated contains a value. Any payment +/// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` +/// before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the +/// sender \"proof-of-payment\" unless they have paid the required amount. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. This should roughly match the expiry time set in the invoice. +/// After this many seconds, we will remove the inbound payment, resulting in any attempts to +/// pay the invoice failing. The BOLT spec suggests 7,200 secs as a default validity time for +/// invoices when no timeout is set. +/// +/// Note that we use block header time to time-out pending inbound payments (with some margin +/// to compensate for the inaccuracy of block header timestamps). Thus, in practice we will +/// accept a payment and generate a [`PaymentReceived`] event for some time after the expiry. +/// If you need exact expiry semantics, you should enforce them upon receipt of +/// [`PaymentReceived`]. +/// +/// May panic if `invoice_expiry_delta_secs` is greater than one year. +/// +/// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry` +/// set to at least [`MIN_FINAL_CLTV_EXPIRY`]. +/// +/// [`create_inbound_payment`]: Self::create_inbound_payment +/// [`PaymentReceived`]: events::Event::PaymentReceived +/// [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, mut user_payment_id: u64) -> crate::c_types::derived::CResult_PaymentSecretAPIErrorZ { + let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; + let mut ret = unsafe { &*this_arg.inner }.create_inbound_payment_for_hash(::lightning::ln::channelmanager::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs, user_payment_id); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + impl From for crate::lightning::util::events::MessageSendEventsProvider { fn from(obj: nativeChannelManager) -> Self { let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index e12ee03..52e06db 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -21,10 +21,19 @@ //! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md //! [messages]: crate::ln::msgs +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; +mod sealed { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} impl Clone for InitFeatures { fn clone(&self) -> Self { Self { diff --git a/lightning-c-bindings/src/lightning/ln/mod.rs b/lightning-c-bindings/src/lightning/ln/mod.rs index d6ca8b3..1061f9b 100644 --- a/lightning-c-bindings/src/lightning/ln/mod.rs +++ b/lightning-c-bindings/src/lightning/ln/mod.rs @@ -17,6 +17,7 @@ //! you want to learn things about the network topology (eg get a route for sending a payment), //! call into your NetGraphMsgHandler. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -26,3 +27,43 @@ pub mod msgs; pub mod peer_handler; pub mod chan_utils; pub mod features; +mod onchaintx { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod peer_channel_encryptor { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod channel { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod onion_utils { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod wire { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 97c516a..9812571 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -23,6 +23,7 @@ //! raw socket events into your non-internet-facing system and then send routing events back to //! track the network on the less-secure system. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -4759,6 +4760,14 @@ impl Drop for RoutingMessageHandler { f(self.this_arg); } } +} +mod fuzzy_internal_msgs { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + } #[no_mangle] /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 6cc942d..42be858 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -14,6 +14,7 @@ //! call into the provided message handlers (probably a ChannelManager and NetGraphmsgHandler) with messages //! they should handle, and encoding/sending response messages. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index 6244aff..e473d63 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -6,6 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. +//!lightning //! Rust-Lightning, not Rusty's Lightning! //! //! A full-featured but also flexible lightning implementation, in library form. This allows the @@ -15,6 +16,7 @@ //! generated/etc. This makes it a good candidate for tight integration into an existing wallet //! instead of having a rather-separate lightning appendage to a wallet. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/routing/mod.rs b/lightning-c-bindings/src/lightning/routing/mod.rs index a06e1d0..9cc0eb4 100644 --- a/lightning-c-bindings/src/lightning/routing/mod.rs +++ b/lightning-c-bindings/src/lightning/routing/mod.rs @@ -8,6 +8,7 @@ //! Structs and impls for receiving messages about the network and storing the topology live here. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/routing/network_graph.rs b/lightning-c-bindings/src/lightning/routing/network_graph.rs index 27e71ed..9f35e43 100644 --- a/lightning-c-bindings/src/lightning/routing/network_graph.rs +++ b/lightning-c-bindings/src/lightning/routing/network_graph.rs @@ -8,6 +8,7 @@ //! The top-level network map tracking logic lives here. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index 5a060c1..9479bc9 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -11,6 +11,7 @@ //! You probably want to create a NetGraphMsgHandler and use that as your RoutingMessageHandler and then //! interrogate it to get routes for your own payments. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index a5d0391..cc58f69 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -9,6 +9,7 @@ //! Various user-configurable channel limits and settings which ChannelManager //! applies for you. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/util/errors.rs b/lightning-c-bindings/src/lightning/util/errors.rs index 5261382..ce9fc14 100644 --- a/lightning-c-bindings/src/lightning/util/errors.rs +++ b/lightning-c-bindings/src/lightning/util/errors.rs @@ -8,6 +8,7 @@ //! Error types live here. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/util/events.rs index 4e4e385..4dcbd81 100644 --- a/lightning-c-bindings/src/lightning/util/events.rs +++ b/lightning-c-bindings/src/lightning/util/events.rs @@ -13,6 +13,7 @@ //! future, as well as generate and broadcast funding transactions handle payment preimages and a //! few other things. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -55,20 +56,37 @@ pub enum Event { PaymentReceived { /// The hash for which the preimage should be handed to the ChannelManager. payment_hash: crate::c_types::ThirtyTwoBytes, + /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via + /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to + /// [`ChannelManager::claim_funds`]. + /// + /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + payment_preimage: crate::c_types::ThirtyTwoBytes, /// The \"payment secret\". This authenticates the sender to the recipient, preventing a /// number of deanonymization attacks during the routing process. - /// As nodes upgrade, the invoices you provide should likely migrate to setting the - /// payment_secret feature to required, at which point you should fail_backwards any HTLCs - /// which have a None here. - /// Until then, however, values of None should be ignored, and only incorrect Some values - /// should result in an HTLC fail_backwards. - /// Note that, in any case, this value must be passed as-is to any fail or claim calls as - /// the HTLC index includes this value. + /// It is provided here for your reference, however its accuracy is enforced directly by + /// [`ChannelManager`] using the values you previously provided to + /// [`ChannelManager::create_inbound_payment`] or + /// [`ChannelManager::create_inbound_payment_for_hash`]. + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash payment_secret: crate::c_types::ThirtyTwoBytes, /// The value, in thousandths of a satoshi, that this payment is for. Note that you must /// compare this to the expected value before accepting the payment (as otherwise you are /// providing proof-of-payment for less than the value you expected!). amt: u64, + /// This is the `user_payment_id` which was provided to + /// [`ChannelManager::create_inbound_payment_for_hash`] or + /// [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is + /// simply copied here. It may be used to correlate PaymentReceived events with invoice + /// metadata stored elsewhere. + /// + /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + user_payment_id: u64, }, /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target /// and we got back the payment preimage for it). @@ -127,15 +145,19 @@ impl Event { user_channel_id: user_channel_id_nonref, } }, - Event::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => { + Event::PaymentReceived {ref payment_hash, ref payment_preimage, ref payment_secret, ref amt, ref user_payment_id, } => { let mut payment_hash_nonref = (*payment_hash).clone(); + let mut payment_preimage_nonref = (*payment_preimage).clone(); + let mut local_payment_preimage_nonref = if payment_preimage_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_nonref.data) }) }; let mut payment_secret_nonref = (*payment_secret).clone(); - let mut local_payment_secret_nonref = if payment_secret_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret_nonref.data) }) }; let mut amt_nonref = (*amt).clone(); + let mut user_payment_id_nonref = (*user_payment_id).clone(); nativeEvent::PaymentReceived { payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_nonref.data), - payment_secret: local_payment_secret_nonref, + payment_preimage: local_payment_preimage_nonref, + payment_secret: ::lightning::ln::channelmanager::PaymentSecret(payment_secret_nonref.data), amt: amt_nonref, + user_payment_id: user_payment_id_nonref, } }, Event::PaymentSent {ref payment_preimage, } => { @@ -178,12 +200,14 @@ impl Event { user_channel_id: user_channel_id, } }, - Event::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => { - let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) }; + Event::PaymentReceived {mut payment_hash, mut payment_preimage, mut payment_secret, mut amt, mut user_payment_id, } => { + let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data) }) }; nativeEvent::PaymentReceived { payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash.data), - payment_secret: local_payment_secret, + payment_preimage: local_payment_preimage, + payment_secret: ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data), amt: amt, + user_payment_id: user_payment_id, } }, Event::PaymentSent {mut payment_preimage, } => { @@ -225,15 +249,19 @@ impl Event { user_channel_id: user_channel_id_nonref, } }, - nativeEvent::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => { + nativeEvent::PaymentReceived {ref payment_hash, ref payment_preimage, ref payment_secret, ref amt, ref user_payment_id, } => { let mut payment_hash_nonref = (*payment_hash).clone(); + let mut payment_preimage_nonref = (*payment_preimage).clone(); + let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage_nonref.unwrap()).0 } } }; let mut payment_secret_nonref = (*payment_secret).clone(); - let mut local_payment_secret_nonref = if payment_secret_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_secret_nonref.unwrap()).0 } } }; let mut amt_nonref = (*amt).clone(); + let mut user_payment_id_nonref = (*user_payment_id).clone(); Event::PaymentReceived { payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - payment_secret: local_payment_secret_nonref, + payment_preimage: local_payment_preimage_nonref, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, amt: amt_nonref, + user_payment_id: user_payment_id_nonref, } }, nativeEvent::PaymentSent {ref payment_preimage, } => { @@ -276,12 +304,14 @@ impl Event { user_channel_id: user_channel_id, } }, - nativeEvent::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => { - let mut local_payment_secret = if payment_secret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_secret.unwrap()).0 } } }; + nativeEvent::PaymentReceived {mut payment_hash, mut payment_preimage, mut payment_secret, mut amt, mut user_payment_id, } => { + let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage.unwrap()).0 } } }; Event::PaymentReceived { payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - payment_secret: local_payment_secret, + payment_preimage: local_payment_preimage, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, amt: amt, + user_payment_id: user_payment_id, } }, nativeEvent::PaymentSent {mut payment_preimage, } => { diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs index 3cfcf6d..b38fac0 100644 --- a/lightning-c-bindings/src/lightning/util/logger.rs +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -13,6 +13,7 @@ //! The second one, client-side by implementing check against Record Level field. //! Each module may have its own Logger or share one. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/util/message_signing.rs b/lightning-c-bindings/src/lightning/util/message_signing.rs index ca1d0b9..1c48e36 100644 --- a/lightning-c-bindings/src/lightning/util/message_signing.rs +++ b/lightning-c-bindings/src/lightning/util/message_signing.rs @@ -22,6 +22,7 @@ //! https://lightning.readthedocs.io/lightning-signmessage.7.html //! https://api.lightning.community/#signmessage +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning/util/mod.rs b/lightning-c-bindings/src/lightning/util/mod.rs index 56b9c75..eb3f2a2 100644 --- a/lightning-c-bindings/src/lightning/util/mod.rs +++ b/lightning-c-bindings/src/lightning/util/mod.rs @@ -8,6 +8,7 @@ //! Some utility modules live here. See individual sub-modules for more info. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -18,3 +19,99 @@ pub mod ser; pub mod message_signing; pub mod logger; pub mod config; +mod fuzz_wrappers { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod byte_utils { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod chacha20 { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +mod real_chacha { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +} +mod zbase32 { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod poly1305 { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod chacha20poly1305rfc { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +mod real_chachapoly { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +} +mod transaction_utils { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod scid_utils { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod ser_macros { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod macro_logger { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index e0c561f..7fde9a6 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -9,6 +9,7 @@ //! A very simple serialization framework which is used to serialize/deserialize messages as well //! as ChannelsManagers and ChannelMonitors. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; diff --git a/lightning-c-bindings/src/lightning_invoice/constants.rs b/lightning-c-bindings/src/lightning_invoice/constants.rs new file mode 100644 index 0000000..d4e2e85 --- /dev/null +++ b/lightning-c-bindings/src/lightning_invoice/constants.rs @@ -0,0 +1,45 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +/// Tag constants as specified in BOLT11 + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + + +#[no_mangle] +pub static TAG_PAYMENT_HASH: u8 = lightning_invoice::constants::TAG_PAYMENT_HASH; + +#[no_mangle] +pub static TAG_DESCRIPTION: u8 = lightning_invoice::constants::TAG_DESCRIPTION; + +#[no_mangle] +pub static TAG_PAYEE_PUB_KEY: u8 = lightning_invoice::constants::TAG_PAYEE_PUB_KEY; + +#[no_mangle] +pub static TAG_DESCRIPTION_HASH: u8 = lightning_invoice::constants::TAG_DESCRIPTION_HASH; + +#[no_mangle] +pub static TAG_EXPIRY_TIME: u8 = lightning_invoice::constants::TAG_EXPIRY_TIME; + +#[no_mangle] +pub static TAG_MIN_FINAL_CLTV_EXPIRY: u8 = lightning_invoice::constants::TAG_MIN_FINAL_CLTV_EXPIRY; + +#[no_mangle] +pub static TAG_FALLBACK: u8 = lightning_invoice::constants::TAG_FALLBACK; + +#[no_mangle] +pub static TAG_ROUTE: u8 = lightning_invoice::constants::TAG_ROUTE; + +#[no_mangle] +pub static TAG_PAYMENT_SECRET: u8 = lightning_invoice::constants::TAG_PAYMENT_SECRET; + +#[no_mangle] +pub static TAG_FEATURES: u8 = lightning_invoice::constants::TAG_FEATURES; diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs new file mode 100644 index 0000000..a12e906 --- /dev/null +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -0,0 +1,2119 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! This crate provides data structures to represent +//! [lightning BOLT11](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md) +//! invoices and functions to create, encode and decode these. If you just want to use the standard +//! en-/decoding functionality this should get you started: +//! +//! * For parsing use `str::parse::(&self)` (see the docs of `impl FromStr for Invoice`) +//! * For constructing invoices use the `InvoiceBuilder` +//! * For serializing invoices use the `Display`/`ToString` traits + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +pub mod constants; +mod de { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +mod hrp_sm { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +} +mod ser { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +mod tb { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} +/// **Call this function on startup to ensure that all assumptions about the platform are valid.** +/// +/// Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on +/// your platform which we can't fully verify at compile time and which isn't part of it's contract. +/// To our best knowledge our assumptions hold for all platforms officially supported by rust, but +/// since this check is fast we recommend to do it anyway. +/// +/// If this function fails this is considered a bug. Please open an issue describing your +/// platform and stating your current system time. +/// +/// # Panics +/// If the check fails this function panics. By calling this function on startup you ensure that +/// this wont happen at an arbitrary later point in time. +#[no_mangle] +pub extern "C" fn check_platform() { + lightning_invoice::check_platform() +} + + +use lightning_invoice::Invoice as nativeInvoiceImport; +type nativeInvoice = nativeInvoiceImport; + +/// Represents a syntactically and semantically correct lightning BOLT11 invoice. +/// +/// There are three ways to construct an `Invoice`: +/// 1. using `InvoiceBuilder` +/// 2. using `Invoice::from_signed(SignedRawInvoice)` +/// 3. using `str::parse::(&str)` +#[must_use] +#[repr(C)] +pub struct Invoice { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoice, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Invoice { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoice>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Invoice_free(this_obj: Invoice) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn Invoice_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoice); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl Invoice { + pub(crate) fn take_inner(mut self) -> *mut nativeInvoice { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for Invoice { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoice>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoice)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Invoice +pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice { + orig.clone() +} + +use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport; +type nativeSignedRawInvoice = nativeSignedRawInvoiceImport; + +/// Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be +/// invalid. +/// +/// # Invariants +/// The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`. +#[must_use] +#[repr(C)] +pub struct SignedRawInvoice { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeSignedRawInvoice, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for SignedRawInvoice { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeSignedRawInvoice>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn SignedRawInvoice_free(this_obj: SignedRawInvoice) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn SignedRawInvoice_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSignedRawInvoice); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl SignedRawInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawInvoice { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for SignedRawInvoice { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeSignedRawInvoice>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn SignedRawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSignedRawInvoice)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the SignedRawInvoice +pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice { + orig.clone() +} + +use lightning_invoice::RawInvoice as nativeRawInvoiceImport; +type nativeRawInvoice = nativeRawInvoiceImport; + +/// Represents an syntactically correct Invoice for a payment on the lightning network, +/// but without the signature information. +/// De- and encoding should not lead to information loss but may lead to different hashes. +/// +/// For methods without docs see the corresponding methods in `Invoice`. +#[must_use] +#[repr(C)] +pub struct RawInvoice { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRawInvoice, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RawInvoice { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRawInvoice>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RawInvoice_free(this_obj: RawInvoice) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn RawInvoice_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRawInvoice); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl RawInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeRawInvoice { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// data part +#[no_mangle] +pub extern "C" fn RawInvoice_get_data(this_ptr: &RawInvoice) -> crate::lightning_invoice::RawDataPart { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data; + crate::lightning_invoice::RawDataPart { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } +} +/// data part +#[no_mangle] +pub extern "C" fn RawInvoice_set_data(this_ptr: &mut RawInvoice, mut val: crate::lightning_invoice::RawDataPart) { + unsafe { &mut *this_ptr.inner }.data = *unsafe { Box::from_raw(val.take_inner()) }; +} +impl Clone for RawInvoice { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRawInvoice>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawInvoice)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RawInvoice +pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice { + orig.clone() +} + +use lightning_invoice::RawDataPart as nativeRawDataPartImport; +type nativeRawDataPart = nativeRawDataPartImport; + +/// Data of the `RawInvoice` that is encoded in the data part +#[must_use] +#[repr(C)] +pub struct RawDataPart { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRawDataPart, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RawDataPart { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRawDataPart>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RawDataPart_free(this_obj: RawDataPart) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn RawDataPart_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRawDataPart); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl RawDataPart { + pub(crate) fn take_inner(mut self) -> *mut nativeRawDataPart { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// generation time of the invoice +#[no_mangle] +pub extern "C" fn RawDataPart_get_timestamp(this_ptr: &RawDataPart) -> crate::lightning_invoice::PositiveTimestamp { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp; + crate::lightning_invoice::PositiveTimestamp { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } +} +/// generation time of the invoice +#[no_mangle] +pub extern "C" fn RawDataPart_set_timestamp(this_ptr: &mut RawDataPart, mut val: crate::lightning_invoice::PositiveTimestamp) { + unsafe { &mut *this_ptr.inner }.timestamp = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// tagged fields of the payment request +#[no_mangle] +pub extern "C" fn RawDataPart_set_tagged_fields(this_ptr: &mut RawDataPart, mut val: crate::c_types::derived::CVec_RawTaggedFieldZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); }; + unsafe { &mut *this_ptr.inner }.tagged_fields = local_val; +} +/// Constructs a new RawDataPart given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RawDataPart_new(mut timestamp_arg: crate::lightning_invoice::PositiveTimestamp, mut tagged_fields_arg: crate::c_types::derived::CVec_RawTaggedFieldZ) -> RawDataPart { + let mut local_tagged_fields_arg = Vec::new(); for mut item in tagged_fields_arg.into_rust().drain(..) { local_tagged_fields_arg.push( { item.into_native() }); }; + RawDataPart { inner: Box::into_raw(Box::new(nativeRawDataPart { + timestamp: *unsafe { Box::from_raw(timestamp_arg.take_inner()) }, + tagged_fields: local_tagged_fields_arg, + })), is_owned: true } +} +impl Clone for RawDataPart { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRawDataPart>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RawDataPart_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawDataPart)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RawDataPart +pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart { + orig.clone() +} + +use lightning_invoice::PositiveTimestamp as nativePositiveTimestampImport; +type nativePositiveTimestamp = nativePositiveTimestampImport; + +/// A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX +/// timestamp is positive. +/// +/// # Invariants +/// The UNIX timestamp representing the stored time has to be positive and small enough so that +/// a `EpiryTime` can be added to it without an overflow. +#[must_use] +#[repr(C)] +pub struct PositiveTimestamp { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePositiveTimestamp, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PositiveTimestamp { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePositiveTimestamp>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PositiveTimestamp_free(this_obj: PositiveTimestamp) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn PositiveTimestamp_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativePositiveTimestamp); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl PositiveTimestamp { + pub(crate) fn take_inner(mut self) -> *mut nativePositiveTimestamp { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for PositiveTimestamp { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePositiveTimestamp>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PositiveTimestamp_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePositiveTimestamp)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the PositiveTimestamp +pub extern "C" fn PositiveTimestamp_clone(orig: &PositiveTimestamp) -> PositiveTimestamp { + orig.clone() +} +/// SI prefixes for the human readable part +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum SiPrefix { + /// 10^-3 + Milli, + /// 10^-6 + Micro, + /// 10^-9 + Nano, + /// 10^-12 + Pico, +} +use lightning_invoice::SiPrefix as nativeSiPrefix; +impl SiPrefix { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeSiPrefix { + match self { + SiPrefix::Milli => nativeSiPrefix::Milli, + SiPrefix::Micro => nativeSiPrefix::Micro, + SiPrefix::Nano => nativeSiPrefix::Nano, + SiPrefix::Pico => nativeSiPrefix::Pico, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeSiPrefix { + match self { + SiPrefix::Milli => nativeSiPrefix::Milli, + SiPrefix::Micro => nativeSiPrefix::Micro, + SiPrefix::Nano => nativeSiPrefix::Nano, + SiPrefix::Pico => nativeSiPrefix::Pico, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeSiPrefix) -> Self { + match native { + nativeSiPrefix::Milli => SiPrefix::Milli, + nativeSiPrefix::Micro => SiPrefix::Micro, + nativeSiPrefix::Nano => SiPrefix::Nano, + nativeSiPrefix::Pico => SiPrefix::Pico, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeSiPrefix) -> Self { + match native { + nativeSiPrefix::Milli => SiPrefix::Milli, + nativeSiPrefix::Micro => SiPrefix::Micro, + nativeSiPrefix::Nano => SiPrefix::Nano, + nativeSiPrefix::Pico => SiPrefix::Pico, + } + } +} +/// Creates a copy of the SiPrefix +#[no_mangle] +pub extern "C" fn SiPrefix_clone(orig: &SiPrefix) -> SiPrefix { + orig.clone() +} +/// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix. +/// This is effectively 10^12 * the prefix multiplier +#[must_use] +#[no_mangle] +pub extern "C" fn SiPrefix_multiplier(this_arg: &SiPrefix) -> u64 { + let mut ret = this_arg.to_native().multiplier(); + ret +} + +/// Enum representing the crypto currencies (or networks) supported by this library +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum Currency { + /// Bitcoin mainnet + Bitcoin, + /// Bitcoin testnet + BitcoinTestnet, + /// Bitcoin regtest + Regtest, + /// Bitcoin simnet/signet + Simnet, +} +use lightning_invoice::Currency as nativeCurrency; +impl Currency { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeCurrency { + match self { + Currency::Bitcoin => nativeCurrency::Bitcoin, + Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet, + Currency::Regtest => nativeCurrency::Regtest, + Currency::Simnet => nativeCurrency::Simnet, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeCurrency { + match self { + Currency::Bitcoin => nativeCurrency::Bitcoin, + Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet, + Currency::Regtest => nativeCurrency::Regtest, + Currency::Simnet => nativeCurrency::Simnet, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeCurrency) -> Self { + match native { + nativeCurrency::Bitcoin => Currency::Bitcoin, + nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet, + nativeCurrency::Regtest => Currency::Regtest, + nativeCurrency::Simnet => Currency::Simnet, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeCurrency) -> Self { + match native { + nativeCurrency::Bitcoin => Currency::Bitcoin, + nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet, + nativeCurrency::Regtest => Currency::Regtest, + nativeCurrency::Simnet => Currency::Simnet, + } + } +} +/// Creates a copy of the Currency +#[no_mangle] +pub extern "C" fn Currency_clone(orig: &Currency) -> Currency { + orig.clone() +} +/// Tagged field which may have an unknown tag +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum RawTaggedField { + /// Parsed tagged field with known tag + KnownSemantics(crate::lightning_invoice::TaggedField), + /// tagged field which was not parsed due to an unknown tag or undefined field semantics + UnknownSemantics(crate::c_types::derived::CVec_u5Z), +} +use lightning_invoice::RawTaggedField as nativeRawTaggedField; +impl RawTaggedField { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeRawTaggedField { + match self { + RawTaggedField::KnownSemantics (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeRawTaggedField::KnownSemantics ( + a_nonref.into_native(), + ) + }, + RawTaggedField::UnknownSemantics (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into() }); }; + nativeRawTaggedField::UnknownSemantics ( + local_a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeRawTaggedField { + match self { + RawTaggedField::KnownSemantics (mut a, ) => { + nativeRawTaggedField::KnownSemantics ( + a.into_native(), + ) + }, + RawTaggedField::UnknownSemantics (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into() }); }; + nativeRawTaggedField::UnknownSemantics ( + local_a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeRawTaggedField) -> Self { + match native { + nativeRawTaggedField::KnownSemantics (ref a, ) => { + let mut a_nonref = (*a).clone(); + RawTaggedField::KnownSemantics ( + crate::lightning_invoice::TaggedField::native_into(a_nonref), + ) + }, + nativeRawTaggedField::UnknownSemantics (ref a, ) => { + let mut a_nonref = (*a).clone(); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { item.into() }); }; + RawTaggedField::UnknownSemantics ( + local_a_nonref.into(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeRawTaggedField) -> Self { + match native { + nativeRawTaggedField::KnownSemantics (mut a, ) => { + RawTaggedField::KnownSemantics ( + crate::lightning_invoice::TaggedField::native_into(a), + ) + }, + nativeRawTaggedField::UnknownSemantics (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { item.into() }); }; + RawTaggedField::UnknownSemantics ( + local_a.into(), + ) + }, + } + } +} +/// Frees any resources used by the RawTaggedField +#[no_mangle] +pub extern "C" fn RawTaggedField_free(this_ptr: RawTaggedField) { } +/// Creates a copy of the RawTaggedField +#[no_mangle] +pub extern "C" fn RawTaggedField_clone(orig: &RawTaggedField) -> RawTaggedField { + orig.clone() +} +/// Tagged field with known tag +/// +/// For descriptions of the enum values please refer to the enclosed type's docs. +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum TaggedField { + PaymentHash(crate::lightning_invoice::Sha256), + Description(crate::lightning_invoice::Description), + PayeePubKey(crate::lightning_invoice::PayeePubKey), + DescriptionHash(crate::lightning_invoice::Sha256), + ExpiryTime(crate::lightning_invoice::ExpiryTime), + MinFinalCltvExpiry(crate::lightning_invoice::MinFinalCltvExpiry), + Fallback(crate::lightning_invoice::Fallback), + Route(crate::lightning_invoice::RouteHint), + PaymentSecret(crate::lightning_invoice::PaymentSecret), + Features(crate::lightning::ln::features::InvoiceFeatures), +} +use lightning_invoice::TaggedField as nativeTaggedField; +impl TaggedField { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeTaggedField { + match self { + TaggedField::PaymentHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::PaymentHash ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::Description (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::Description ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::PayeePubKey (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::PayeePubKey ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::DescriptionHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::DescriptionHash ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::ExpiryTime (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::ExpiryTime ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::MinFinalCltvExpiry (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::MinFinalCltvExpiry ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::Fallback (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::Fallback ( + a_nonref.into_native(), + ) + }, + TaggedField::Route (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::Route ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::PaymentSecret (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::PaymentSecret ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + TaggedField::Features (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeTaggedField::Features ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeTaggedField { + match self { + TaggedField::PaymentHash (mut a, ) => { + nativeTaggedField::PaymentHash ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::Description (mut a, ) => { + nativeTaggedField::Description ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::PayeePubKey (mut a, ) => { + nativeTaggedField::PayeePubKey ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::DescriptionHash (mut a, ) => { + nativeTaggedField::DescriptionHash ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::ExpiryTime (mut a, ) => { + nativeTaggedField::ExpiryTime ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::MinFinalCltvExpiry (mut a, ) => { + nativeTaggedField::MinFinalCltvExpiry ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::Fallback (mut a, ) => { + nativeTaggedField::Fallback ( + a.into_native(), + ) + }, + TaggedField::Route (mut a, ) => { + nativeTaggedField::Route ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::PaymentSecret (mut a, ) => { + nativeTaggedField::PaymentSecret ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + TaggedField::Features (mut a, ) => { + nativeTaggedField::Features ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeTaggedField) -> Self { + match native { + nativeTaggedField::PaymentHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::PaymentHash ( + crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::Description (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::Description ( + crate::lightning_invoice::Description { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::PayeePubKey (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::PayeePubKey ( + crate::lightning_invoice::PayeePubKey { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::DescriptionHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::DescriptionHash ( + crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::ExpiryTime (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::ExpiryTime ( + crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::MinFinalCltvExpiry (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::MinFinalCltvExpiry ( + crate::lightning_invoice::MinFinalCltvExpiry { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::Fallback (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::Fallback ( + crate::lightning_invoice::Fallback::native_into(a_nonref), + ) + }, + nativeTaggedField::Route (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::Route ( + crate::lightning_invoice::RouteHint { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::PaymentSecret (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::PaymentSecret ( + crate::lightning_invoice::PaymentSecret { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeTaggedField::Features (ref a, ) => { + let mut a_nonref = (*a).clone(); + TaggedField::Features ( + crate::lightning::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeTaggedField) -> Self { + match native { + nativeTaggedField::PaymentHash (mut a, ) => { + TaggedField::PaymentHash ( + crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::Description (mut a, ) => { + TaggedField::Description ( + crate::lightning_invoice::Description { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::PayeePubKey (mut a, ) => { + TaggedField::PayeePubKey ( + crate::lightning_invoice::PayeePubKey { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::DescriptionHash (mut a, ) => { + TaggedField::DescriptionHash ( + crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::ExpiryTime (mut a, ) => { + TaggedField::ExpiryTime ( + crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::MinFinalCltvExpiry (mut a, ) => { + TaggedField::MinFinalCltvExpiry ( + crate::lightning_invoice::MinFinalCltvExpiry { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::Fallback (mut a, ) => { + TaggedField::Fallback ( + crate::lightning_invoice::Fallback::native_into(a), + ) + }, + nativeTaggedField::Route (mut a, ) => { + TaggedField::Route ( + crate::lightning_invoice::RouteHint { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::PaymentSecret (mut a, ) => { + TaggedField::PaymentSecret ( + crate::lightning_invoice::PaymentSecret { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeTaggedField::Features (mut a, ) => { + TaggedField::Features ( + crate::lightning::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the TaggedField +#[no_mangle] +pub extern "C" fn TaggedField_free(this_ptr: TaggedField) { } +/// Creates a copy of the TaggedField +#[no_mangle] +pub extern "C" fn TaggedField_clone(orig: &TaggedField) -> TaggedField { + orig.clone() +} + +use lightning_invoice::Sha256 as nativeSha256Import; +type nativeSha256 = nativeSha256Import; + +/// SHA-256 hash +#[must_use] +#[repr(C)] +pub struct Sha256 { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeSha256, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Sha256 { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeSha256>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Sha256_free(this_obj: Sha256) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn Sha256_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSha256); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl Sha256 { + pub(crate) fn take_inner(mut self) -> *mut nativeSha256 { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for Sha256 { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeSha256>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Sha256_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSha256)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Sha256 +pub extern "C" fn Sha256_clone(orig: &Sha256) -> Sha256 { + orig.clone() +} + +use lightning_invoice::Description as nativeDescriptionImport; +type nativeDescription = nativeDescriptionImport; + +/// Description string +/// +/// # Invariants +/// The description can be at most 639 __bytes__ long +#[must_use] +#[repr(C)] +pub struct Description { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeDescription, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Description { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDescription>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the Description, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Description_free(this_obj: Description) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn Description_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDescription); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl Description { + pub(crate) fn take_inner(mut self) -> *mut nativeDescription { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for Description { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDescription>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Description_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDescription)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Description +pub extern "C" fn Description_clone(orig: &Description) -> Description { + orig.clone() +} + +use lightning_invoice::PayeePubKey as nativePayeePubKeyImport; +type nativePayeePubKey = nativePayeePubKeyImport; + +/// Payee public key +#[must_use] +#[repr(C)] +pub struct PayeePubKey { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePayeePubKey, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PayeePubKey { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePayeePubKey>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PayeePubKey_free(this_obj: PayeePubKey) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn PayeePubKey_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativePayeePubKey); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl PayeePubKey { + pub(crate) fn take_inner(mut self) -> *mut nativePayeePubKey { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for PayeePubKey { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePayeePubKey>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PayeePubKey_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePayeePubKey)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the PayeePubKey +pub extern "C" fn PayeePubKey_clone(orig: &PayeePubKey) -> PayeePubKey { + orig.clone() +} + +use lightning_invoice::PaymentSecret as nativePaymentSecretImport; +type nativePaymentSecret = nativePaymentSecretImport; + +/// 256-bit payment secret +#[must_use] +#[repr(C)] +pub struct PaymentSecret { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePaymentSecret, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PaymentSecret { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePaymentSecret>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the PaymentSecret, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PaymentSecret_free(this_obj: PaymentSecret) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn PaymentSecret_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativePaymentSecret); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl PaymentSecret { + pub(crate) fn take_inner(mut self) -> *mut nativePaymentSecret { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for PaymentSecret { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePaymentSecret>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PaymentSecret_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePaymentSecret)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the PaymentSecret +pub extern "C" fn PaymentSecret_clone(orig: &PaymentSecret) -> PaymentSecret { + orig.clone() +} + +use lightning_invoice::ExpiryTime as nativeExpiryTimeImport; +type nativeExpiryTime = nativeExpiryTimeImport; + +/// Positive duration that defines when (relatively to the timestamp) in the future the invoice +/// expires +/// +/// # Invariants +/// The number of seconds this expiry time represents has to be in the range +/// `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a +/// timestamp +#[must_use] +#[repr(C)] +pub struct ExpiryTime { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeExpiryTime, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ExpiryTime { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeExpiryTime>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ExpiryTime_free(this_obj: ExpiryTime) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ExpiryTime_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeExpiryTime); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ExpiryTime { + pub(crate) fn take_inner(mut self) -> *mut nativeExpiryTime { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for ExpiryTime { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeExpiryTime>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ExpiryTime_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeExpiryTime)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ExpiryTime +pub extern "C" fn ExpiryTime_clone(orig: &ExpiryTime) -> ExpiryTime { + orig.clone() +} + +use lightning_invoice::MinFinalCltvExpiry as nativeMinFinalCltvExpiryImport; +type nativeMinFinalCltvExpiry = nativeMinFinalCltvExpiryImport; + +/// `min_final_cltv_expiry` to use for the last HTLC in the route +#[must_use] +#[repr(C)] +pub struct MinFinalCltvExpiry { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeMinFinalCltvExpiry, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for MinFinalCltvExpiry { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeMinFinalCltvExpiry>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the MinFinalCltvExpiry, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn MinFinalCltvExpiry_free(this_obj: MinFinalCltvExpiry) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn MinFinalCltvExpiry_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMinFinalCltvExpiry); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl MinFinalCltvExpiry { + pub(crate) fn take_inner(mut self) -> *mut nativeMinFinalCltvExpiry { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for MinFinalCltvExpiry { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeMinFinalCltvExpiry>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MinFinalCltvExpiry_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMinFinalCltvExpiry)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the MinFinalCltvExpiry +pub extern "C" fn MinFinalCltvExpiry_clone(orig: &MinFinalCltvExpiry) -> MinFinalCltvExpiry { + orig.clone() +} +/// Fallback address in case no LN payment is possible +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum Fallback { + SegWitProgram { + version: crate::c_types::u5, + program: crate::c_types::derived::CVec_u8Z, + }, + PubKeyHash(crate::c_types::TwentyBytes), + ScriptHash(crate::c_types::TwentyBytes), +} +use lightning_invoice::Fallback as nativeFallback; +impl Fallback { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeFallback { + match self { + Fallback::SegWitProgram {ref version, ref program, } => { + let mut version_nonref = (*version).clone(); + let mut program_nonref = (*program).clone(); + let mut local_program_nonref = Vec::new(); for mut item in program_nonref.into_rust().drain(..) { local_program_nonref.push( { item }); }; + nativeFallback::SegWitProgram { + version: version_nonref.into(), + program: local_program_nonref, + } + }, + Fallback::PubKeyHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeFallback::PubKeyHash ( + a_nonref.data, + ) + }, + Fallback::ScriptHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeFallback::ScriptHash ( + a_nonref.data, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeFallback { + match self { + Fallback::SegWitProgram {mut version, mut program, } => { + let mut local_program = Vec::new(); for mut item in program.into_rust().drain(..) { local_program.push( { item }); }; + nativeFallback::SegWitProgram { + version: version.into(), + program: local_program, + } + }, + Fallback::PubKeyHash (mut a, ) => { + nativeFallback::PubKeyHash ( + a.data, + ) + }, + Fallback::ScriptHash (mut a, ) => { + nativeFallback::ScriptHash ( + a.data, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeFallback) -> Self { + match native { + nativeFallback::SegWitProgram {ref version, ref program, } => { + let mut version_nonref = (*version).clone(); + let mut program_nonref = (*program).clone(); + let mut local_program_nonref = Vec::new(); for mut item in program_nonref.drain(..) { local_program_nonref.push( { item }); }; + Fallback::SegWitProgram { + version: version_nonref.into(), + program: local_program_nonref.into(), + } + }, + nativeFallback::PubKeyHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + Fallback::PubKeyHash ( + crate::c_types::TwentyBytes { data: a_nonref }, + ) + }, + nativeFallback::ScriptHash (ref a, ) => { + let mut a_nonref = (*a).clone(); + Fallback::ScriptHash ( + crate::c_types::TwentyBytes { data: a_nonref }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeFallback) -> Self { + match native { + nativeFallback::SegWitProgram {mut version, mut program, } => { + let mut local_program = Vec::new(); for mut item in program.drain(..) { local_program.push( { item }); }; + Fallback::SegWitProgram { + version: version.into(), + program: local_program.into(), + } + }, + nativeFallback::PubKeyHash (mut a, ) => { + Fallback::PubKeyHash ( + crate::c_types::TwentyBytes { data: a }, + ) + }, + nativeFallback::ScriptHash (mut a, ) => { + Fallback::ScriptHash ( + crate::c_types::TwentyBytes { data: a }, + ) + }, + } + } +} +/// Frees any resources used by the Fallback +#[no_mangle] +pub extern "C" fn Fallback_free(this_ptr: Fallback) { } +/// Creates a copy of the Fallback +#[no_mangle] +pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback { + orig.clone() +} + +use lightning_invoice::InvoiceSignature as nativeInvoiceSignatureImport; +type nativeInvoiceSignature = nativeInvoiceSignatureImport; + +/// Recoverable signature +#[must_use] +#[repr(C)] +pub struct InvoiceSignature { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceSignature, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for InvoiceSignature { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceSignature>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceSignature_free(this_obj: InvoiceSignature) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn InvoiceSignature_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceSignature); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl InvoiceSignature { + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceSignature { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for InvoiceSignature { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceSignature)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceSignature +pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature { + orig.clone() +} + +use lightning_invoice::RouteHint as nativeRouteHintImport; +type nativeRouteHint = nativeRouteHintImport; + +/// Private routing information +/// +/// # Invariants +/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) +/// +#[must_use] +#[repr(C)] +pub struct RouteHint { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRouteHint, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for RouteHint { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHint_free(this_obj: RouteHint) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHint); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl RouteHint { + pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for RouteHint { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHint>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHint)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RouteHint +pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { + orig.clone() +} +/// Disassembles the `SignedRawInvoice` into its three parts: +/// 1. raw invoice +/// 2. hash of the raw invoice +/// 3. signature +#[must_use] +#[no_mangle] +pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts(); + let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawInvoice { inner: Box::into_raw(Box::new(orig_ret_0)), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::InvoiceSignature { inner: Box::into_raw(Box::new(orig_ret_2)), is_owned: true }).into(); + local_ret +} + +/// The `RawInvoice` which was signed. +#[must_use] +#[no_mangle] +pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::RawInvoice { + let mut ret = unsafe { &*this_arg.inner }.raw_invoice(); + crate::lightning_invoice::RawInvoice { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// The hash of the `RawInvoice` that was signed. +#[must_use] +#[no_mangle] +pub extern "C" fn SignedRawInvoice_hash(this_arg: &SignedRawInvoice) -> *const [u8; 32] { + let mut ret = unsafe { &*this_arg.inner }.hash(); + ret +} + +/// InvoiceSignature for the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn SignedRawInvoice_signature(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature { + let mut ret = unsafe { &*this_arg.inner }.signature(); + crate::lightning_invoice::InvoiceSignature { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Recovers the public key used for signing the invoice from the recoverable signature. +#[must_use] +#[no_mangle] +pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ { + let mut ret = unsafe { &*this_arg.inner }.recover_payee_pub_key(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PayeePubKey { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + local_ret +} + +/// Checks if the signature is valid for the included payee public key or if none exists if it's +/// valid for the recovered signature (which should always be true?). +#[must_use] +#[no_mangle] +pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &SignedRawInvoice) -> bool { + let mut ret = unsafe { &*this_arg.inner }.check_signature(); + ret +} + +/// Calculate the hash of the encoded `RawInvoice` +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_hash(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*this_arg.inner }.hash(); + crate::c_types::ThirtyTwoBytes { data: ret } +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 { + let mut ret = unsafe { &*this_arg.inner }.payment_hash(); + let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightning_invoice::Description { + let mut ret = unsafe { &*this_arg.inner }.description(); + let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::lightning_invoice::PayeePubKey { + let mut ret = unsafe { &*this_arg.inner }.payee_pub_key(); + let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 { + let mut ret = unsafe { &*this_arg.inner }.description_hash(); + let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightning_invoice::ExpiryTime { + let mut ret = unsafe { &*this_arg.inner }.expiry_time(); + let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry { + let mut ret = unsafe { &*this_arg.inner }.min_final_cltv_expiry(); + let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiry { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_payment_secret(this_arg: &RawInvoice) -> crate::lightning_invoice::PaymentSecret { + let mut ret = unsafe { &*this_arg.inner }.payment_secret(); + let mut local_ret = crate::lightning_invoice::PaymentSecret { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_features(this_arg: &RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures { + let mut ret = unsafe { &*this_arg.inner }.features(); + let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_routes(this_arg: &RawInvoice) -> crate::c_types::derived::CVec_RouteHintZ { + let mut ret = unsafe { &*this_arg.inner }.routes(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::RouteHint { inner: unsafe { ( (&(**item) as *const _) as *mut _) }, is_owned: false } }); }; + local_ret.into() +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &RawInvoice) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*this_arg.inner }.amount_pico_btc(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(ret.unwrap()) } }; + local_ret +} + +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_currency(this_arg: &RawInvoice) -> crate::lightning_invoice::Currency { + let mut ret = unsafe { &*this_arg.inner }.currency(); + crate::lightning_invoice::Currency::native_into(ret) +} + +/// Create a new `PositiveTimestamp` from a unix timestamp in the Range +/// `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a +/// `CreationError::TimestampOutOfBounds`. +#[must_use] +#[no_mangle] +pub extern "C" fn PositiveTimestamp_from_unix_timestamp(mut unix_seconds: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ { + let mut ret = lightning_invoice::PositiveTimestamp::from_unix_timestamp(unix_seconds); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in +/// the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a +/// `CreationError::TimestampOutOfBounds`. +#[must_use] +#[no_mangle] +pub extern "C" fn PositiveTimestamp_from_system_time(mut time: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ { + let mut ret = lightning_invoice::PositiveTimestamp::from_system_time((::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(time))); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Returns the UNIX timestamp representing the stored time +#[must_use] +#[no_mangle] +pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &PositiveTimestamp) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.as_unix_timestamp(); + ret +} + +/// Returns a reference to the internal `SystemTime` time representation +#[must_use] +#[no_mangle] +pub extern "C" fn PositiveTimestamp_as_time(this_arg: &PositiveTimestamp) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.as_time(); + ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() +} + +/// Transform the `Invoice` into it's unchecked version +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_into_signed_raw(mut this_arg: Invoice) -> crate::lightning_invoice::SignedRawInvoice { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw(); + crate::lightning_invoice::SignedRawInvoice { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Check that the invoice is signed correctly and that key recovery works +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_check_signature(this_arg: &Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ { + let mut ret = unsafe { &*this_arg.inner }.check_signature(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Constructs an `Invoice` from a `SignedInvoice` by checking all its invariants. +/// ``` +/// use lightning_invoice::*; +/// +/// let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\ +/// \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\ +/// \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\ +/// \tky03ylcqca784w\"; +/// +/// let signed = invoice.parse::().unwrap(); +/// +/// assert!(Invoice::from_signed(signed).is_ok()); +/// ``` +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_InvoiceSemanticErrorZ { + let mut ret = lightning_invoice::Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Returns the `Invoice`'s timestamp (should equal it's creation time) +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_timestamp(this_arg: &Invoice) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.timestamp(); + ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() +} + +/// Returns the hash to which we will receive the preimage on completion of the payment +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_payment_hash(this_arg: &Invoice) -> *const [u8; 32] { + let mut ret = unsafe { &*this_arg.inner }.payment_hash(); + ret.as_inner() +} + +/// Get the payee's public key if one was included in the invoice +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*this_arg.inner }.payee_pub_key(); + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret +} + +/// Get the payment secret if one was included in the invoice +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_payment_secret(this_arg: &Invoice) -> crate::lightning_invoice::PaymentSecret { + let mut ret = unsafe { &*this_arg.inner }.payment_secret(); + let mut local_ret = crate::lightning_invoice::PaymentSecret { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +/// Get the invoice features if they were included in the invoice +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_features(this_arg: &Invoice) -> crate::lightning::ln::features::InvoiceFeatures { + let mut ret = unsafe { &*this_arg.inner }.features(); + let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { { (ret.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_ret +} + +/// Recover the payee's public key (only to be used if none was included in the invoice) +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*this_arg.inner }.recover_payee_pub_key(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// Returns the invoice's expiry time if present +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_expiry_time(this_arg: &Invoice) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.expiry_time(); + ret.as_secs() +} + +/// Returns the invoice's `min_cltv_expiry` time if present +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_min_final_cltv_expiry(this_arg: &Invoice) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*this_arg.inner }.min_final_cltv_expiry(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(ret.unwrap()) } }; + local_ret +} + +/// Returns a list of all routes included in the invoice +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_routes(this_arg: &Invoice) -> crate::c_types::derived::CVec_RouteHintZ { + let mut ret = unsafe { &*this_arg.inner }.routes(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::RouteHint { inner: unsafe { ( (&(**item) as *const _) as *mut _) }, is_owned: false } }); }; + local_ret.into() +} + +/// Returns the currency for which the invoice was issued +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_currency(this_arg: &Invoice) -> crate::lightning_invoice::Currency { + let mut ret = unsafe { &*this_arg.inner }.currency(); + crate::lightning_invoice::Currency::native_into(ret) +} + +/// Returns the amount if specified in the invoice as pico . +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_amount_pico_btc(this_arg: &Invoice) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*this_arg.inner }.amount_pico_btc(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { { crate::c_types::derived::COption_u64Z::Some(ret.unwrap()) } }; + local_ret +} + +/// Numeric representation of the field's tag +#[must_use] +#[no_mangle] +pub extern "C" fn TaggedField_tag(this_arg: &TaggedField) -> crate::c_types::u5 { + let mut ret = this_arg.to_native().tag(); + ret.into() +} + +/// Creates a new `Description` if `description` is at most 1023 __bytes__ long, +/// returns `CreationError::DescriptionTooLong` otherwise +/// +/// Please note that single characters may use more than one byte due to UTF8 encoding. +#[must_use] +#[no_mangle] +pub extern "C" fn Description_new(mut description: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_DescriptionCreationErrorZ { + let mut ret = lightning_invoice::Description::new(String::from_utf8(description.into_rust()).unwrap()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Description { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Returns the underlying description `String` +#[must_use] +#[no_mangle] +pub extern "C" fn Description_into_inner(mut this_arg: Description) -> crate::c_types::derived::CVec_u8Z { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner(); + ret.into_bytes().into() +} + +/// Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would +/// overflow on adding the `EpiryTime` to it then this function will return a +/// `CreationError::ExpiryTimeOutOfBounds`. +#[must_use] +#[no_mangle] +pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ { + let mut ret = lightning_invoice::ExpiryTime::from_seconds(seconds); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which +/// would overflow on adding the `EpiryTime` to it then this function will return a +/// `CreationError::ExpiryTimeOutOfBounds`. +#[must_use] +#[no_mangle] +pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ { + let mut ret = lightning_invoice::ExpiryTime::from_duration(std::time::Duration::from_secs(duration)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Returns the expiry time in seconds +#[must_use] +#[no_mangle] +pub extern "C" fn ExpiryTime_as_seconds(this_arg: &ExpiryTime) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.as_seconds(); + ret +} + +/// Returns a reference to the underlying `Duration` (=expiry time) +#[must_use] +#[no_mangle] +pub extern "C" fn ExpiryTime_as_duration(this_arg: &ExpiryTime) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.as_duration(); + ret.as_secs() +} + +/// Create a new (partial) route from a list of hops +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHint_new(mut hops: crate::c_types::derived::CVec_RouteHintHopZ) -> crate::c_types::derived::CResult_RouteHintCreationErrorZ { + let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = lightning_invoice::RouteHint::new(local_hops); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::RouteHint { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Returrn the underlying vector of hops +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHint_into_inner(mut this_arg: RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::router::RouteHintHop { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; + local_ret.into() +} + +/// Errors that may occur when constructing a new `RawInvoice` or `Invoice` +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum CreationError { + /// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new)) + DescriptionTooLong, + /// The specified route has too many hops and can't be encoded + RouteTooLong, + /// The unix timestamp of the supplied date is <0 or can't be represented as `SystemTime` + TimestampOutOfBounds, + /// The supplied expiry time could cause an overflow if added to a `PositiveTimestamp` + ExpiryTimeOutOfBounds, +} +use lightning_invoice::CreationError as nativeCreationError; +impl CreationError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeCreationError { + match self { + CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong, + CreationError::RouteTooLong => nativeCreationError::RouteTooLong, + CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds, + CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeCreationError { + match self { + CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong, + CreationError::RouteTooLong => nativeCreationError::RouteTooLong, + CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds, + CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeCreationError) -> Self { + match native { + nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong, + nativeCreationError::RouteTooLong => CreationError::RouteTooLong, + nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds, + nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeCreationError) -> Self { + match native { + nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong, + nativeCreationError::RouteTooLong => CreationError::RouteTooLong, + nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds, + nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds, + } + } +} +/// Creates a copy of the CreationError +#[no_mangle] +pub extern "C" fn CreationError_clone(orig: &CreationError) -> CreationError { + orig.clone() +} +#[no_mangle] +/// Get the string representation of a CreationError object +pub extern "C" fn CreationError_to_str(o: &lightning_invoice::CreationError) -> Str { + format!("{}", o).into() +} +/// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the +/// requirements sections in BOLT #11 +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum SemanticError { + /// The invoice is missing the mandatory payment hash + NoPaymentHash, + /// The invoice has multiple payment hashes which isn't allowed + MultiplePaymentHashes, + /// No description or description hash are part of the invoice + NoDescription, + /// The invoice contains multiple descriptions and/or description hashes which isn't allowed + MultipleDescriptions, + /// The recovery id doesn't fit the signature/pub key + InvalidRecoveryId, + /// The invoice's signature is invalid + InvalidSignature, +} +use lightning_invoice::SemanticError as nativeSemanticError; +impl SemanticError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeSemanticError { + match self { + SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash, + SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes, + SemanticError::NoDescription => nativeSemanticError::NoDescription, + SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions, + SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId, + SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeSemanticError { + match self { + SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash, + SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes, + SemanticError::NoDescription => nativeSemanticError::NoDescription, + SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions, + SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId, + SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeSemanticError) -> Self { + match native { + nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash, + nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes, + nativeSemanticError::NoDescription => SemanticError::NoDescription, + nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions, + nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId, + nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeSemanticError) -> Self { + match native { + nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash, + nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes, + nativeSemanticError::NoDescription => SemanticError::NoDescription, + nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions, + nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId, + nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature, + } + } +} +/// Creates a copy of the SemanticError +#[no_mangle] +pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError { + orig.clone() +} +#[no_mangle] +/// Get the string representation of a SemanticError object +pub extern "C" fn SemanticError_to_str(o: &lightning_invoice::SemanticError) -> Str { + format!("{}", o).into() +} diff --git a/lightning-c-bindings/src/lightning_persister.rs b/lightning-c-bindings/src/lightning_persister.rs index c550638..1976839 100644 --- a/lightning-c-bindings/src/lightning_persister.rs +++ b/lightning-c-bindings/src/lightning_persister.rs @@ -8,10 +8,19 @@ //! Utilities that handle persisting Rust-Lightning data to disk via standard filesystem APIs. +use std::str::FromStr; use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; +mod util { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + +} use lightning_persister::FilesystemPersister as nativeFilesystemPersisterImport; type nativeFilesystemPersister = nativeFilesystemPersisterImport;