X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Finclude%2Flightning.h;h=8076e251b85ed9039859d20a1df09320007a610e;hb=4894d52d30399c21b7994952a8de0d1d7848c58d;hp=131e05d933a577705c273531bc8ca54b78eae2e8;hpb=02c21842fdf0c1918c9589dfc0039aa64f7dd249;p=rust-lightning diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 131e05d9..8076e251 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -7,7 +7,7 @@ #include #include #include -#include + /** * An error when accessing the chain via [`Access`]. @@ -174,8 +174,8 @@ typedef enum LDKSecp256k1Error { LDKSecp256k1Error_InvalidSecretKey, LDKSecp256k1Error_InvalidRecoveryId, LDKSecp256k1Error_InvalidTweak, + LDKSecp256k1Error_TweakCheckFailed, LDKSecp256k1Error_NotEnoughMemory, - LDKSecp256k1Error_CallbackPanicked, /** * Must be last for serialization purposes */ @@ -1551,21 +1551,20 @@ typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ { /** - * An event to be processed by the ChannelManager. + * 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. + * + * [`chain::Watch`]: ../trait.Watch.html */ -typedef struct MUST_USE_STRUCT LDKMonitorEvent { +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { /** * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMonitorEvent *inner; + LDKnativeHTLCUpdate *inner; bool is_owned; -} LDKMonitorEvent; - -typedef struct LDKCVec_MonitorEventZ { - struct LDKMonitorEvent *data; - uintptr_t datalen; -} LDKCVec_MonitorEventZ; +} LDKHTLCUpdate; @@ -1584,8 +1583,71 @@ typedef struct MUST_USE_STRUCT LDKOutPoint { bool is_owned; } LDKOutPoint; +/** + * An event to be processed by the ChannelManager. + */ +typedef enum LDKMonitorEvent_Tag { + /** + * A monitor event containing an HTLCUpdate. + */ + LDKMonitorEvent_HTLCEvent, + /** + * A monitor event that the Channel's commitment transaction was broadcasted. + */ + LDKMonitorEvent_CommitmentTxBroadcasted, + /** + * Must be last for serialization purposes + */ + LDKMonitorEvent_Sentinel, +} LDKMonitorEvent_Tag; + +typedef struct MUST_USE_STRUCT LDKMonitorEvent { + LDKMonitorEvent_Tag tag; + union { + struct { + struct LDKHTLCUpdate htlc_event; + }; + struct { + struct LDKOutPoint commitment_tx_broadcasted; + }; + }; +} LDKMonitorEvent; + +typedef struct LDKCVec_MonitorEventZ { + struct LDKMonitorEvent *data; + uintptr_t datalen; +} LDKCVec_MonitorEventZ; + + + +/** + * Information about a spendable output to a P2WSH script. See + * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. + */ +typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { + /** + * Nearly everywhere, 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; + bool is_owned; +} LDKDelayedPaymentOutputDescriptor; + +/** + * Information about a spendable output to our \"payment key\". See + * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. + */ +typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { + /** + * Nearly everywhere, 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; + bool is_owned; +} LDKStaticPaymentOutputDescriptor; + /** * 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 @@ -1593,13 +1655,78 @@ typedef struct MUST_USE_STRUCT LDKOutPoint { * 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 MUST_USE_STRUCT LDKSpendableOutputDescriptor { +typedef enum LDKSpendableOutputDescriptor_Tag { /** - * Nearly everywhere, 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 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. */ - LDKnativeSpendableOutputDescriptor *inner; - bool is_owned; + LDKSpendableOutputDescriptor_StaticOutput, + /** + * 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. + */ + LDKSpendableOutputDescriptor_DelayedPaymentOutput, + /** + * 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. + */ + LDKSpendableOutputDescriptor_StaticPaymentOutput, + /** + * Must be last for serialization purposes + */ + LDKSpendableOutputDescriptor_Sentinel, +} LDKSpendableOutputDescriptor_Tag; + +typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { + struct LDKOutPoint 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; typedef struct LDKCVec_SpendableOutputDescriptorZ { @@ -1762,24 +1889,6 @@ typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { bool result_ok; } LDKCResult_ChannelMonitorUpdateDecodeErrorZ; - - -/** - * 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. - * - * [`chain::Watch`]: ../trait.Watch.html - */ -typedef struct MUST_USE_STRUCT LDKHTLCUpdate { - /** - * Nearly everywhere, 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; - bool is_owned; -} LDKHTLCUpdate; - typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { struct LDKHTLCUpdate *result; struct LDKDecodeError *err; @@ -1897,10 +2006,10 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { } LDKUnsignedChannelAnnouncement; /** - * Set of lightning keys needed to operate a channel as described in BOLT 3. + * 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 ChannelKeys would be a front-end on top of a communication + * 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 @@ -1915,7 +2024,7 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { * 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 struct LDKChannelKeys { +typedef struct LDKSign { void *this_arg; /** * Gets the per-commitment point for a specific commitment number @@ -1943,11 +2052,11 @@ typedef struct LDKChannelKeys { * Note that this takes a pointer to this object, not the this_ptr like other methods do * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. */ - void (*set_pubkeys)(const struct LDKChannelKeys*NONNULL_PTR ); + void (*set_pubkeys)(const struct LDKSign*NONNULL_PTR ); /** * 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 - * ChannelKeys object uniquely and lookup or re-derive its keys. + * Sign object uniquely and lookup or re-derive its keys. */ struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); /** @@ -2043,7 +2152,7 @@ typedef struct LDKChannelKeys { void *(*clone)(const void *this_arg); struct LDKCVec_u8Z (*write)(const void *this_arg); void (*free)(void *this_arg); -} LDKChannelKeys; +} LDKSign; @@ -2186,6 +2295,16 @@ typedef struct LDKCResult_NoneAPIErrorZ { bool result_ok; } LDKCResult_NoneAPIErrorZ; +typedef struct LDKCVec_CResult_NoneAPIErrorZZ { + struct LDKCResult_NoneAPIErrorZ *data; + uintptr_t datalen; +} LDKCVec_CResult_NoneAPIErrorZZ; + +typedef struct LDKCVec_APIErrorZ { + struct LDKAPIError *data; + uintptr_t datalen; +} LDKCVec_APIErrorZ; + /** @@ -2205,20 +2324,71 @@ typedef struct LDKCVec_ChannelDetailsZ { uintptr_t datalen; } LDKCVec_ChannelDetailsZ; - - /** * If a payment fails to send, it can be in one of several states. This enum is returned as the * Err() type describing which state the payment is in, see the description of individual enum * states for more. */ -typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { +typedef enum LDKPaymentSendFailure_Tag { /** - * Nearly everywhere, 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 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. */ - LDKnativePaymentSendFailure *inner; - bool is_owned; + LDKPaymentSendFailure_ParameterError, + /** + * A parameter in a single path which was passed to send_payment was invalid, preventing us + * from attempting to send the payment at all. No channel state has been changed or messages + * sent to peers, and once you've changed the parameter at error, you can freely retry the + * payment in full. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment. + */ + LDKPaymentSendFailure_PathParameterError, + /** + * All paths which were attempted failed to send, with no channel state change taking place. + * You can freely retry the payment in full (though you probably want to do so over different + * paths than the ones selected). + */ + LDKPaymentSendFailure_AllFailedRetrySafe, + /** + * Some paths which were attempted failed to send, though possibly not all. At least some + * paths have irrevocably committed to the HTLC and retrying the payment in full would result + * in over-/re-payment. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely + * retried (though there is currently no API with which to do so). + * + * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried + * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the + * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel + * with the latest update_id. + */ + LDKPaymentSendFailure_PartialFailure, + /** + * Must be last for serialization purposes + */ + LDKPaymentSendFailure_Sentinel, +} LDKPaymentSendFailure_Tag; + +typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { + LDKPaymentSendFailure_Tag tag; + union { + struct { + struct LDKAPIError parameter_error; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; + }; + struct { + struct LDKCVec_APIErrorZ all_failed_retry_safe; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ partial_failure; + }; + }; } LDKPaymentSendFailure; typedef union LDKCResult_NonePaymentSendFailureZPtr { @@ -2306,15 +2476,15 @@ typedef struct LDKBroadcasterInterface { void (*free)(void *this_arg); } LDKBroadcasterInterface; -typedef union LDKCResult_ChannelKeysDecodeErrorZPtr { - struct LDKChannelKeys *result; +typedef union LDKCResult_SignDecodeErrorZPtr { + struct LDKSign *result; struct LDKDecodeError *err; -} LDKCResult_ChannelKeysDecodeErrorZPtr; +} LDKCResult_SignDecodeErrorZPtr; -typedef struct LDKCResult_ChannelKeysDecodeErrorZ { - union LDKCResult_ChannelKeysDecodeErrorZPtr contents; +typedef struct LDKCResult_SignDecodeErrorZ { + union LDKCResult_SignDecodeErrorZPtr contents; bool result_ok; -} LDKCResult_ChannelKeysDecodeErrorZ; +} LDKCResult_SignDecodeErrorZ; typedef struct LDKu8slice { const uint8_t *data; @@ -2348,12 +2518,12 @@ typedef struct LDKKeysInterface { */ struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); /** - * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you + * 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 LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); + 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 @@ -2363,14 +2533,14 @@ typedef struct LDKKeysInterface { */ struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); /** - * Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream. + * Reads a `Signer` for this `KeysInterface` from the given input stream. * This is only called during deserialization of other objects which contain - * `ChannelKeys`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). - * The bytes are exactly those which `::write()` writes, and + * `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_ChannelKeysDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); void (*free)(void *this_arg); } LDKKeysInterface; @@ -2504,29 +2674,29 @@ typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { /** - * A simple implementation of ChannelKeys that just keeps the private keys in memory. + * A simple implementation of Sign that just keeps the private keys in memory. * * This implementation performs no policy checks and is insufficient by itself as * a secure external signer. */ -typedef struct MUST_USE_STRUCT LDKInMemoryChannelKeys { +typedef struct MUST_USE_STRUCT LDKInMemorySigner { /** * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInMemoryChannelKeys *inner; + LDKnativeInMemorySigner *inner; bool is_owned; -} LDKInMemoryChannelKeys; +} LDKInMemorySigner; -typedef union LDKCResult_InMemoryChannelKeysDecodeErrorZPtr { - struct LDKInMemoryChannelKeys *result; +typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { + struct LDKInMemorySigner *result; struct LDKDecodeError *err; -} LDKCResult_InMemoryChannelKeysDecodeErrorZPtr; +} LDKCResult_InMemorySignerDecodeErrorZPtr; -typedef struct LDKCResult_InMemoryChannelKeysDecodeErrorZ { - union LDKCResult_InMemoryChannelKeysDecodeErrorZPtr contents; +typedef struct LDKCResult_InMemorySignerDecodeErrorZ { + union LDKCResult_InMemorySignerDecodeErrorZPtr contents; bool result_ok; -} LDKCResult_InMemoryChannelKeysDecodeErrorZ; +} LDKCResult_InMemorySignerDecodeErrorZ; typedef struct LDKCVec_TxOutZ { struct LDKTxOut *data; @@ -3281,6 +3451,25 @@ typedef struct LDKAccess { void (*free)(void *this_arg); } LDKAccess; +/** + * The `Listen` trait is used to be notified of when blocks have been connected or disconnected + * from the chain. + * + * Useful when needing to replay chain data upon startup or as new chain events occur. + */ +typedef struct LDKListen { + 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); + void (*free)(void *this_arg); +} LDKListen; + /** * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to * channels. @@ -3406,36 +3595,6 @@ typedef struct MUST_USE_STRUCT LDKChainMonitor { -/** - * Information about a spendable output to a P2WSH script. See - * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this. - */ -typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { - /** - * Nearly everywhere, 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; - bool is_owned; -} LDKDelayedPaymentOutputDescriptor; - - - -/** - * Information about a spendable output to our \"payment key\". See - * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this. - */ -typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { - /** - * Nearly everywhere, 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; - bool is_owned; -} LDKStaticPaymentOutputDescriptor; - - - /** * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key * and derives keys from that. @@ -3489,7 +3648,7 @@ typedef struct LDKChannelMessageHandler { /** * Handle an incoming shutdown message from the given peer. */ - void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKShutdown *NONNULL_PTR msg); + 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. */ @@ -4010,6 +4169,8 @@ struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(st void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); + struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); @@ -4044,6 +4205,8 @@ struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err( void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); + struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); @@ -4144,6 +4307,10 @@ void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); +void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); + +void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); + void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); @@ -4196,13 +4363,13 @@ void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); -struct LDKCResult_ChannelKeysDecodeErrorZ CResult_ChannelKeysDecodeErrorZ_ok(struct LDKChannelKeys o); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o); -struct LDKCResult_ChannelKeysDecodeErrorZ CResult_ChannelKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); -void CResult_ChannelKeysDecodeErrorZ_free(struct LDKCResult_ChannelKeysDecodeErrorZ _res); +void CResult_SignDecodeErrorZ_free(struct LDKCResult_SignDecodeErrorZ _res); -struct LDKCResult_ChannelKeysDecodeErrorZ CResult_ChannelKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR orig); void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); @@ -4214,13 +4381,13 @@ void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); -struct LDKCResult_InMemoryChannelKeysDecodeErrorZ CResult_InMemoryChannelKeysDecodeErrorZ_ok(struct LDKInMemoryChannelKeys o); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); -struct LDKCResult_InMemoryChannelKeysDecodeErrorZ CResult_InMemoryChannelKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); -void CResult_InMemoryChannelKeysDecodeErrorZ_free(struct LDKCResult_InMemoryChannelKeysDecodeErrorZ _res); +void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); -struct LDKCResult_InMemoryChannelKeysDecodeErrorZ CResult_InMemoryChannelKeysDecodeErrorZ_clone(const struct LDKCResult_InMemoryChannelKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); @@ -4969,6 +5136,11 @@ enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR ori */ void Access_free(struct LDKAccess this_ptr); +/** + * Calls the free function if one is set + */ +void Listen_free(struct LDKListen this_ptr); + /** * Calls the free function if one is set */ @@ -5266,14 +5438,14 @@ void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPayme /** * Arbitrary identification information returned by a call to - * `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in * the channel to spend the output. */ const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** * Arbitrary identification information returned by a call to - * `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in * the channel to spend the output. */ void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); @@ -5311,14 +5483,14 @@ void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescr /** * Arbitrary identification information returned by a call to - * `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in * the channel to spend the output. */ const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** * Arbitrary identification information returned by a call to - * `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in + * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in * the channel to spend the output. */ void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); @@ -5345,92 +5517,92 @@ struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutp struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); -struct LDKChannelKeys ChannelKeys_clone(const struct LDKChannelKeys *NONNULL_PTR orig); +struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); /** * Calls the free function if one is set */ -void ChannelKeys_free(struct LDKChannelKeys this_ptr); +void Sign_free(struct LDKSign this_ptr); /** * Calls the free function if one is set */ void KeysInterface_free(struct LDKKeysInterface this_ptr); -void InMemoryChannelKeys_free(struct LDKInMemoryChannelKeys this_ptr); +void InMemorySigner_free(struct LDKInMemorySigner this_ptr); /** * Private key of anchor tx */ -const uint8_t (*InMemoryChannelKeys_get_funding_key(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr))[32]; +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** * Private key of anchor tx */ -void InMemoryChannelKeys_set_funding_key(struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** * Holder secret key for blinded revocation pubkey */ -const uint8_t (*InMemoryChannelKeys_get_revocation_base_key(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr))[32]; +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** * Holder secret key for blinded revocation pubkey */ -void InMemoryChannelKeys_set_revocation_base_key(struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -const uint8_t (*InMemoryChannelKeys_get_payment_key(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr))[32]; +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -void InMemoryChannelKeys_set_payment_key(struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** * Holder secret key used in HTLC tx */ -const uint8_t (*InMemoryChannelKeys_get_delayed_payment_base_key(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr))[32]; +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** * Holder secret key used in HTLC tx */ -void InMemoryChannelKeys_set_delayed_payment_base_key(struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** * Holder htlc secret key used in commitment tx htlc outputs */ -const uint8_t (*InMemoryChannelKeys_get_htlc_base_key(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr))[32]; +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** * Holder htlc secret key used in commitment tx htlc outputs */ -void InMemoryChannelKeys_set_htlc_base_key(struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** * Commitment seed */ -const uint8_t (*InMemoryChannelKeys_get_commitment_seed(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr))[32]; +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** * Commitment seed */ -void InMemoryChannelKeys_set_commitment_seed(struct LDKInMemoryChannelKeys *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); -struct LDKInMemoryChannelKeys InMemoryChannelKeys_clone(const struct LDKInMemoryChannelKeys *NONNULL_PTR orig); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * Create a new InMemoryChannelKeys + * Create a new InMemorySigner */ -MUST_USE_RES struct LDKInMemoryChannelKeys InMemoryChannelKeys_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); +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); /** * Counterparty pubkeys. * Will panic if ready_channel wasn't called. */ -MUST_USE_RES struct LDKChannelPublicKeys InMemoryChannelKeys_counterparty_pubkeys(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** * The contest_delay value specified by our counterparty and applied on holder-broadcastable @@ -5438,7 +5610,7 @@ MUST_USE_RES struct LDKChannelPublicKeys InMemoryChannelKeys_counterparty_pubkey * broadcast a transaction. * Will panic if ready_channel wasn't called. */ -MUST_USE_RES uint16_t InMemoryChannelKeys_counterparty_selected_contest_delay(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** * The contest_delay value specified by us and applied on transactions broadcastable @@ -5446,19 +5618,19 @@ MUST_USE_RES uint16_t InMemoryChannelKeys_counterparty_selected_contest_delay(co * if they broadcast a transaction. * Will panic if ready_channel wasn't called. */ -MUST_USE_RES uint16_t InMemoryChannelKeys_holder_selected_contest_delay(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** * Whether the holder is the initiator * Will panic if ready_channel wasn't called. */ -MUST_USE_RES bool InMemoryChannelKeys_is_outbound(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** * Funding outpoint * Will panic if ready_channel wasn't called. */ -MUST_USE_RES struct LDKOutPoint InMemoryChannelKeys_funding_outpoint(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or @@ -5466,7 +5638,7 @@ MUST_USE_RES struct LDKOutPoint InMemoryChannelKeys_funding_outpoint(const struc * * Will panic if ready_channel wasn't called. */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemoryChannelKeys_get_channel_parameters(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** * Sign the single input of spend_tx at index `input_idx` which spends the output @@ -5475,7 +5647,7 @@ MUST_USE_RES struct LDKChannelTransactionParameters InMemoryChannelKeys_get_chan * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, * or is not spending the outpoint described by `descriptor.outpoint`. */ -MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemoryChannelKeys_sign_counterparty_payment_input(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); +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); /** * Sign the single input of spend_tx at index `input_idx` which spends the output @@ -5485,13 +5657,13 @@ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemoryChannelKeys_sign_coun * 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_CVec_CVec_u8ZZNoneZ InMemoryChannelKeys_sign_dynamic_p2wsh_input(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +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); -struct LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg); +struct LDKSign InMemorySigner_as_Sign(const struct LDKInMemorySigner *NONNULL_PTR this_arg); -struct LDKCVec_u8Z InMemoryChannelKeys_write(const struct LDKInMemoryChannelKeys *NONNULL_PTR obj); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); -struct LDKCResult_InMemoryChannelKeysDecodeErrorZ InMemoryChannelKeys_read(struct LDKu8slice ser); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser); void KeysManager_free(struct LDKKeysManager this_ptr); @@ -5519,13 +5691,13 @@ void KeysManager_free(struct LDKKeysManager this_ptr); MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * Derive an old set of ChannelKeys for per-channel secrets based on a key derivation - * parameters. + * Derive an old Sign containing per-channel secrets based on a key derivation parameters. + * * Key derivation parameters are accessible through a per-channel secrets - * ChannelKeys::channel_keys_id and is provided inside DynamicOuputP2WSH in case of + * 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 LDKInMemoryChannelKeys KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +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]); /** * Creates a Transaction which spends the given descriptors to the given outputs, plus an @@ -5538,7 +5710,7 @@ MUST_USE_RES struct LDKInMemoryChannelKeys KeysManager_derive_channel_keys(const * 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 `InMemoryChannelKeys` created by this KeysManager. + * 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); @@ -5881,6 +6053,8 @@ struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider( struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); + /** * Updates channel state based on transactions seen in a connected block. */ @@ -5894,6 +6068,12 @@ void ChannelManager_block_connected(const struct LDKChannelManager *NONNULL_PTR */ void ChannelManager_block_disconnected(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*header)[80]); +/** + * Blocks until ChannelManager needs to be persisted. Only one listener on `wait` is + * guaranteed to be woken up. + */ +void ChannelManager_wait(const struct LDKChannelManager *NONNULL_PTR this_arg); + struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); @@ -5999,6 +6179,18 @@ struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR void Init_free(struct LDKInit this_ptr); +/** + * The relevant features which the sender supports + */ +struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * The relevant features which the sender supports + */ +void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg); + struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); void ErrorMessage_free(struct LDKErrorMessage this_ptr); @@ -8622,6 +8814,8 @@ struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id void NetworkGraph_free(struct LDKNetworkGraph this_ptr); +struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); + void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_ptr); void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_ptr); @@ -8802,6 +8996,8 @@ struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct */ void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); + struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser);