From: Matt Corallo Date: Fri, 19 Feb 2021 21:08:04 +0000 (-0500) Subject: Update auto-generated bindings X-Git-Tag: v0.0.13~23^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=aa3f84123db64445057634bb551c1fab0775d1aa;p=rust-lightning Update auto-generated bindings --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index fb39ee623..01a252ee3 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -1679,14 +1679,14 @@ typedef enum LDKSpendableOutputDescriptor_Tag { * * To derive the delayed_payment key which is used to sign for this input, you must pass the * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in - * ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to + * 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 - * ChannelKeys::pubkeys(). + * 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 ChannelKeys::ready_channel) and the provided per_commitment point + * 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 @@ -1697,7 +1697,7 @@ typedef enum LDKSpendableOutputDescriptor_Tag { LDKSpendableOutputDescriptor_DelayedPaymentOutput, /** * An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which - * corresponds to the public key in ChannelKeys::pubkeys().payment_point). + * corresponds to the public key in Sign::pubkeys().payment_point). * The witness in the spending input, is, thus, simply: * * @@ -2006,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 @@ -2024,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 @@ -2052,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); /** @@ -2152,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; @@ -2476,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; @@ -2518,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 @@ -2533,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; @@ -2674,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; @@ -4340,13 +4340,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); @@ -4358,13 +4358,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); @@ -5410,14 +5410,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); @@ -5455,14 +5455,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); @@ -5489,92 +5489,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 @@ -5582,7 +5582,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 @@ -5590,19 +5590,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 @@ -5610,7 +5610,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 @@ -5619,7 +5619,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 @@ -5629,13 +5629,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); @@ -5663,13 +5663,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 + * Derive an old set of Sign for 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 @@ -5682,7 +5682,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); @@ -6038,6 +6038,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); diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 81370fd12..bd499ce6e 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -881,20 +881,20 @@ public: const LDKSpendableOutputDescriptor* operator &() const { return &self; } const LDKSpendableOutputDescriptor* operator ->() const { return &self; } }; -class ChannelKeys { +class Sign { private: - LDKChannelKeys self; + LDKSign self; public: - ChannelKeys(const ChannelKeys&) = delete; - ChannelKeys(ChannelKeys&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelKeys)); } - ChannelKeys(LDKChannelKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelKeys)); } - operator LDKChannelKeys() && { LDKChannelKeys res = self; memset(&self, 0, sizeof(LDKChannelKeys)); return res; } - ~ChannelKeys() { ChannelKeys_free(self); } - ChannelKeys& operator=(ChannelKeys&& o) { ChannelKeys_free(self); self = o.self; memset(&o, 0, sizeof(ChannelKeys)); return *this; } - LDKChannelKeys* operator &() { return &self; } - LDKChannelKeys* operator ->() { return &self; } - const LDKChannelKeys* operator &() const { return &self; } - const LDKChannelKeys* operator ->() const { return &self; } + Sign(const Sign&) = delete; + Sign(Sign&& o) : self(o.self) { memset(&o, 0, sizeof(Sign)); } + Sign(LDKSign&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSign)); } + operator LDKSign() && { LDKSign res = self; memset(&self, 0, sizeof(LDKSign)); return res; } + ~Sign() { Sign_free(self); } + Sign& operator=(Sign&& o) { Sign_free(self); self = o.self; memset(&o, 0, sizeof(Sign)); return *this; } + LDKSign* operator &() { return &self; } + LDKSign* operator ->() { return &self; } + const LDKSign* operator &() const { return &self; } + const LDKSign* operator ->() const { return &self; } }; class KeysInterface { private: @@ -911,20 +911,20 @@ public: const LDKKeysInterface* operator &() const { return &self; } const LDKKeysInterface* operator ->() const { return &self; } }; -class InMemoryChannelKeys { +class InMemorySigner { private: - LDKInMemoryChannelKeys self; + LDKInMemorySigner self; public: - InMemoryChannelKeys(const InMemoryChannelKeys&) = delete; - InMemoryChannelKeys(InMemoryChannelKeys&& o) : self(o.self) { memset(&o, 0, sizeof(InMemoryChannelKeys)); } - InMemoryChannelKeys(LDKInMemoryChannelKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemoryChannelKeys)); } - operator LDKInMemoryChannelKeys() && { LDKInMemoryChannelKeys res = self; memset(&self, 0, sizeof(LDKInMemoryChannelKeys)); return res; } - ~InMemoryChannelKeys() { InMemoryChannelKeys_free(self); } - InMemoryChannelKeys& operator=(InMemoryChannelKeys&& o) { InMemoryChannelKeys_free(self); self = o.self; memset(&o, 0, sizeof(InMemoryChannelKeys)); return *this; } - LDKInMemoryChannelKeys* operator &() { return &self; } - LDKInMemoryChannelKeys* operator ->() { return &self; } - const LDKInMemoryChannelKeys* operator &() const { return &self; } - const LDKInMemoryChannelKeys* operator ->() const { return &self; } + InMemorySigner(const InMemorySigner&) = delete; + InMemorySigner(InMemorySigner&& o) : self(o.self) { memset(&o, 0, sizeof(InMemorySigner)); } + InMemorySigner(LDKInMemorySigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemorySigner)); } + operator LDKInMemorySigner() && { LDKInMemorySigner res = self; memset(&self, 0, sizeof(LDKInMemorySigner)); return res; } + ~InMemorySigner() { InMemorySigner_free(self); } + InMemorySigner& operator=(InMemorySigner&& o) { InMemorySigner_free(self); self = o.self; memset(&o, 0, sizeof(InMemorySigner)); return *this; } + LDKInMemorySigner* operator &() { return &self; } + LDKInMemorySigner* operator ->() { return &self; } + const LDKInMemorySigner* operator &() const { return &self; } + const LDKInMemorySigner* operator ->() const { return &self; } }; class KeysManager { private: @@ -2411,6 +2411,21 @@ 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; @@ -2456,21 +2471,6 @@ public: const LDKC2Tuple_OutPointScriptZ* operator &() const { return &self; } const LDKC2Tuple_OutPointScriptZ* operator ->() const { return &self; } }; -class CResult_InMemoryChannelKeysDecodeErrorZ { -private: - LDKCResult_InMemoryChannelKeysDecodeErrorZ self; -public: - CResult_InMemoryChannelKeysDecodeErrorZ(const CResult_InMemoryChannelKeysDecodeErrorZ&) = delete; - CResult_InMemoryChannelKeysDecodeErrorZ(CResult_InMemoryChannelKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InMemoryChannelKeysDecodeErrorZ)); } - CResult_InMemoryChannelKeysDecodeErrorZ(LDKCResult_InMemoryChannelKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ)); } - operator LDKCResult_InMemoryChannelKeysDecodeErrorZ() && { LDKCResult_InMemoryChannelKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ)); return res; } - ~CResult_InMemoryChannelKeysDecodeErrorZ() { CResult_InMemoryChannelKeysDecodeErrorZ_free(self); } - CResult_InMemoryChannelKeysDecodeErrorZ& operator=(CResult_InMemoryChannelKeysDecodeErrorZ&& o) { CResult_InMemoryChannelKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InMemoryChannelKeysDecodeErrorZ)); return *this; } - LDKCResult_InMemoryChannelKeysDecodeErrorZ* operator &() { return &self; } - LDKCResult_InMemoryChannelKeysDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InMemoryChannelKeysDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InMemoryChannelKeysDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_UpdateFailMalformedHTLCDecodeErrorZ { private: LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ self; @@ -3176,21 +3176,6 @@ public: const LDKCResult_UpdateFulfillHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFulfillHTLCDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ChannelKeysDecodeErrorZ { -private: - LDKCResult_ChannelKeysDecodeErrorZ self; -public: - CResult_ChannelKeysDecodeErrorZ(const CResult_ChannelKeysDecodeErrorZ&) = delete; - CResult_ChannelKeysDecodeErrorZ(CResult_ChannelKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelKeysDecodeErrorZ)); } - CResult_ChannelKeysDecodeErrorZ(LDKCResult_ChannelKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelKeysDecodeErrorZ)); } - operator LDKCResult_ChannelKeysDecodeErrorZ() && { LDKCResult_ChannelKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelKeysDecodeErrorZ)); return res; } - ~CResult_ChannelKeysDecodeErrorZ() { CResult_ChannelKeysDecodeErrorZ_free(self); } - CResult_ChannelKeysDecodeErrorZ& operator=(CResult_ChannelKeysDecodeErrorZ&& o) { CResult_ChannelKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelKeysDecodeErrorZ)); return *this; } - LDKCResult_ChannelKeysDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelKeysDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelKeysDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelKeysDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_NodeFeaturesDecodeErrorZ { private: LDKCResult_NodeFeaturesDecodeErrorZ self; @@ -3206,6 +3191,21 @@ public: const LDKCResult_NodeFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeFeaturesDecodeErrorZ* 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 CResult_ReplyShortChannelIdsEndDecodeErrorZ { private: LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ self; diff --git a/lightning-c-bindings/include/rust_types.h b/lightning-c-bindings/include/rust_types.h index d76b09afe..d998eb04c 100644 --- a/lightning-c-bindings/include/rust_types.h +++ b/lightning-c-bindings/include/rust_types.h @@ -89,10 +89,10 @@ struct nativeDelayedPaymentOutputDescriptorOpaque; typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor; struct nativeStaticPaymentOutputDescriptorOpaque; typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor; -struct LDKChannelKeys; -typedef struct LDKChannelKeys LDKChannelKeys; -struct nativeInMemoryChannelKeysOpaque; -typedef struct nativeInMemoryChannelKeysOpaque LDKnativeInMemoryChannelKeys; +struct LDKSign; +typedef struct LDKSign LDKSign; +struct nativeInMemorySignerOpaque; +typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner; struct nativeKeysManagerOpaque; typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; struct nativeRouteHopOpaque; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index 2ea8d6ff9..d58c56b45 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -3852,36 +3852,36 @@ impl Clone for CResult_SignatureNoneZ { #[no_mangle] pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { orig.clone() } #[repr(C)] -pub union CResult_ChannelKeysDecodeErrorZPtr { - pub result: *mut crate::chain::keysinterface::ChannelKeys, +pub union CResult_SignDecodeErrorZPtr { + pub result: *mut crate::chain::keysinterface::Sign, pub err: *mut crate::ln::msgs::DecodeError, } #[repr(C)] -pub struct CResult_ChannelKeysDecodeErrorZ { - pub contents: CResult_ChannelKeysDecodeErrorZPtr, +pub struct CResult_SignDecodeErrorZ { + pub contents: CResult_SignDecodeErrorZPtr, pub result_ok: bool, } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_ok(o: crate::chain::keysinterface::ChannelKeys) -> CResult_ChannelKeysDecodeErrorZ { - CResult_ChannelKeysDecodeErrorZ { - contents: CResult_ChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_SignDecodeErrorZ_ok(o: crate::chain::keysinterface::Sign) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelKeysDecodeErrorZ { - CResult_ChannelKeysDecodeErrorZ { - contents: CResult_ChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_SignDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_free(_res: CResult_ChannelKeysDecodeErrorZ) { } -impl Drop for CResult_ChannelKeysDecodeErrorZ { +pub extern "C" fn CResult_SignDecodeErrorZ_free(_res: CResult_SignDecodeErrorZ) { } +impl Drop for CResult_SignDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3894,16 +3894,16 @@ impl Drop for CResult_ChannelKeysDecodeErrorZ { } } } -impl From> for CResult_ChannelKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignDecodeErrorZ { + 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_ChannelKeysDecodeErrorZPtr { result } + CResult_SignDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelKeysDecodeErrorZPtr { err } + CResult_SignDecodeErrorZPtr { err } }; Self { contents, @@ -3911,21 +3911,21 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_SignDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_clone(orig: &CResult_ChannelKeysDecodeErrorZ) -> CResult_ChannelKeysDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { orig.clone() } #[repr(C)] pub struct CVec_CVec_u8ZZ { pub data: *mut crate::c_types::derived::CVec_u8Z, @@ -4040,36 +4040,36 @@ impl Clone for CResult_CVec_CVec_u8ZZNoneZ { #[no_mangle] pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { orig.clone() } #[repr(C)] -pub union CResult_InMemoryChannelKeysDecodeErrorZPtr { - pub result: *mut crate::chain::keysinterface::InMemoryChannelKeys, +pub union CResult_InMemorySignerDecodeErrorZPtr { + pub result: *mut crate::chain::keysinterface::InMemorySigner, pub err: *mut crate::ln::msgs::DecodeError, } #[repr(C)] -pub struct CResult_InMemoryChannelKeysDecodeErrorZ { - pub contents: CResult_InMemoryChannelKeysDecodeErrorZPtr, +pub struct CResult_InMemorySignerDecodeErrorZ { + pub contents: CResult_InMemorySignerDecodeErrorZPtr, pub result_ok: bool, } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_ok(o: crate::chain::keysinterface::InMemoryChannelKeys) -> CResult_InMemoryChannelKeysDecodeErrorZ { - CResult_InMemoryChannelKeysDecodeErrorZ { - contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::chain::keysinterface::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InMemoryChannelKeysDecodeErrorZ { - CResult_InMemoryChannelKeysDecodeErrorZ { - contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_free(_res: CResult_InMemoryChannelKeysDecodeErrorZ) { } -impl Drop for CResult_InMemoryChannelKeysDecodeErrorZ { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } +impl Drop for CResult_InMemorySignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4082,16 +4082,16 @@ impl Drop for CResult_InMemoryChannelKeysDecodeErrorZ { } } } -impl From> for CResult_InMemoryChannelKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InMemorySignerDecodeErrorZ { + 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_InMemoryChannelKeysDecodeErrorZPtr { result } + CResult_InMemorySignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_InMemoryChannelKeysDecodeErrorZPtr { err } + CResult_InMemorySignerDecodeErrorZPtr { err } }; Self { contents, @@ -4099,21 +4099,21 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_clone(orig: &CResult_InMemoryChannelKeysDecodeErrorZ) -> CResult_InMemoryChannelKeysDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { orig.clone() } #[repr(C)] pub struct CVec_TxOutZ { pub data: *mut crate::c_types::TxOut, diff --git a/lightning-c-bindings/src/chain/chainmonitor.rs b/lightning-c-bindings/src/chain/chainmonitor.rs index f4d5262dd..3b306635d 100644 --- a/lightning-c-bindings/src/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/chain/chainmonitor.rs @@ -26,7 +26,7 @@ use crate::c_types::*; use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport; -type nativeChainMonitor = nativeChainMonitorImport; +type nativeChainMonitor = nativeChainMonitorImport; /// An implementation of [`chain::Watch`] for monitoring channels. /// diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs index f1f39e6d0..efab4b165 100644 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/chain/channelmonitor.rs @@ -442,7 +442,7 @@ pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_type } use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; -type nativeChannelMonitor = nativeChannelMonitorImport; +type nativeChannelMonitor = nativeChannelMonitorImport; /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates /// on-chain transactions to ensure no loss of funds occurs. @@ -663,13 +663,13 @@ unsafe impl Send for Persist {} unsafe impl Sync for Persist {} use lightning::chain::channelmonitor::Persist as rustPersist; -impl rustPersist for Persist { - fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { +impl rustPersist for Persist { + fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.persist_new_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } - fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.update_persisted_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (update as *const _) as *mut _ }, is_owned: false }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret @@ -697,7 +697,7 @@ impl Drop for Persist { #[no_mangle] pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg: &crate::chain::keysinterface::KeysInterface) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { let arg_conv = arg; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res } diff --git a/lightning-c-bindings/src/chain/keysinterface.rs b/lightning-c-bindings/src/chain/keysinterface.rs index 7642138ed..3cb70e7d8 100644 --- a/lightning-c-bindings/src/chain/keysinterface.rs +++ b/lightning-c-bindings/src/chain/keysinterface.rs @@ -99,7 +99,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: unsafe { &mut *this_ptr.inner }.revocation_pubkey = val.into_rust(); } /// 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. #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { @@ -107,7 +107,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: & &(*inner_val) } /// 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. #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { @@ -211,7 +211,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut Static unsafe { &mut *this_ptr.inner }.output = val.into_rust(); } /// 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. #[no_mangle] pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { @@ -219,7 +219,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &S &(*inner_val) } /// 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. #[no_mangle] pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { @@ -296,14 +296,14 @@ pub enum SpendableOutputDescriptor { /// /// To derive the delayed_payment key which is used to sign for this input, you must pass the /// holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in - /// ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to + /// 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 - /// ChannelKeys::pubkeys(). + /// 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 ChannelKeys::ready_channel) and the provided per_commitment point + /// 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 @@ -312,7 +312,7 @@ pub enum SpendableOutputDescriptor { /// chan_utils::get_revokeable_redeemscript. DelayedPaymentOutput(crate::chain::keysinterface::DelayedPaymentOutputDescriptor), /// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which - /// corresponds to the public key in ChannelKeys::pubkeys().payment_point). + /// corresponds to the public key in Sign::pubkeys().payment_point). /// The witness in the spending input, is, thus, simply: /// /// @@ -431,10 +431,10 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res } -/// 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 @@ -449,7 +449,7 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - /// to act, as liveness and breach reply correctness are always going to be hard requirements /// of LN security model, orthogonal of key management issues. #[repr(C)] -pub struct ChannelKeys { +pub struct Sign { pub this_arg: *mut c_void, /// Gets the per-commitment point for a specific commitment number /// @@ -471,10 +471,10 @@ pub struct ChannelKeys { /// 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. - pub set_pubkeys: Option, + pub set_pubkeys: Option, /// 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. #[must_use] pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. @@ -563,10 +563,10 @@ pub struct ChannelKeys { pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, pub free: Option, } -unsafe impl Send for ChannelKeys {} +unsafe impl Send for Sign {} #[no_mangle] -pub extern "C" fn ChannelKeys_clone(orig: &ChannelKeys) -> ChannelKeys { - ChannelKeys { +pub extern "C" fn Sign_clone(orig: &Sign) -> Sign { + Sign { this_arg: if let Some(f) = orig.clone { (f)(orig.this_arg) } else { orig.this_arg }, get_per_commitment_point: orig.get_per_commitment_point.clone(), release_commitment_secret: orig.release_commitment_secret.clone(), @@ -585,20 +585,20 @@ pub extern "C" fn ChannelKeys_clone(orig: &ChannelKeys) -> ChannelKeys { free: orig.free.clone(), } } -impl Clone for ChannelKeys { +impl Clone for Sign { fn clone(&self) -> Self { - ChannelKeys_clone(self) + Sign_clone(self) } } -impl lightning::util::ser::Writeable for ChannelKeys { +impl lightning::util::ser::Writeable for Sign { fn write(&self, w: &mut W) -> Result<(), ::std::io::Error> { let vec = (self.write)(self.this_arg); w.write_all(vec.as_slice()) } } -use lightning::chain::keysinterface::ChannelKeys as rustChannelKeys; -impl rustChannelKeys for ChannelKeys { +use lightning::chain::keysinterface::Sign as rustSign; +impl rustSign for Sign { fn get_per_commitment_point(&self, idx: u64, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::key::PublicKey { let mut ret = (self.get_per_commitment_point)(self.this_arg, idx); ret.into_rust() @@ -658,7 +658,7 @@ impl rustChannelKeys for ChannelKeys { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: -impl std::ops::Deref for ChannelKeys { +impl std::ops::Deref for Sign { type Target = Self; fn deref(&self) -> &Self { self @@ -666,8 +666,8 @@ impl std::ops::Deref for ChannelKeys { } /// Calls the free function if one is set #[no_mangle] -pub extern "C" fn ChannelKeys_free(this_ptr: ChannelKeys) { } -impl Drop for ChannelKeys { +pub extern "C" fn Sign_free(this_ptr: Sign) { } +impl Drop for Sign { fn drop(&mut self) { if let Some(f) = self.free { f(self.this_arg); @@ -696,12 +696,12 @@ pub struct KeysInterface { /// on-chain funds across channels as controlled to the same user. #[must_use] pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey, - /// 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. #[must_use] - pub get_channel_keys: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys, + pub get_channel_signer: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::Sign, /// 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. @@ -709,14 +709,14 @@ pub struct KeysInterface { /// This method must return a different value each time it is called. #[must_use] pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// 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. #[must_use] - pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelKeysDecodeErrorZ, + pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ, pub free: Option, } unsafe impl Send for KeysInterface {} @@ -724,7 +724,7 @@ unsafe impl Sync for KeysInterface {} use lightning::chain::keysinterface::KeysInterface as rustKeysInterface; impl rustKeysInterface for KeysInterface { - type ChanKeySigner = crate::chain::keysinterface::ChannelKeys; + type Signer = crate::chain::keysinterface::Sign; fn get_node_secret(&self) -> bitcoin::secp256k1::key::SecretKey { let mut ret = (self.get_node_secret)(self.this_arg); ret.into_rust() @@ -737,15 +737,15 @@ impl rustKeysInterface for KeysInterface { let mut ret = (self.get_shutdown_pubkey)(self.this_arg); ret.into_rust() } - fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys { - let mut ret = (self.get_channel_keys)(self.this_arg, inbound, channel_value_satoshis); + fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::Sign { + let mut ret = (self.get_channel_signer)(self.this_arg, inbound, channel_value_satoshis); ret } fn get_secure_random_bytes(&self) -> [u8; 32] { let mut ret = (self.get_secure_random_bytes)(self.this_arg); ret.data } - fn read_chan_signer(&self, reader: &[u8]) -> Result { + fn read_chan_signer(&self, reader: &[u8]) -> Result { let mut local_reader = crate::c_types::u8slice::from_slice(reader); let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; @@ -772,23 +772,23 @@ impl Drop for KeysInterface { } } -use lightning::chain::keysinterface::InMemoryChannelKeys as nativeInMemoryChannelKeysImport; -type nativeInMemoryChannelKeys = nativeInMemoryChannelKeysImport; +use lightning::chain::keysinterface::InMemorySigner as nativeInMemorySignerImport; +type nativeInMemorySigner = nativeInMemorySignerImport; -/// 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. #[must_use] #[repr(C)] -pub struct InMemoryChannelKeys { +pub struct InMemorySigner { /// Nearly everywhere, 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 nativeInMemoryChannelKeys, + pub inner: *mut nativeInMemorySigner, pub is_owned: bool, } -impl Drop for InMemoryChannelKeys { +impl Drop for InMemorySigner { fn drop(&mut self) { if self.is_owned && !self.inner.is_null() { let _ = unsafe { Box::from_raw(self.inner) }; @@ -796,16 +796,16 @@ impl Drop for InMemoryChannelKeys { } } #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_free(this_ptr: InMemoryChannelKeys) { } +pub extern "C" fn InMemorySigner_free(this_ptr: InMemorySigner) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InMemoryChannelKeys_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInMemoryChannelKeys); } +extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInMemorySigner); } } #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl InMemoryChannelKeys { - pub(crate) fn take_inner(mut self) -> *mut nativeInMemoryChannelKeys { +impl InMemorySigner { + pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -814,71 +814,71 @@ impl InMemoryChannelKeys { } /// Private key of anchor tx #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_funding_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { +pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_key; (*inner_val).as_ref() } /// Private key of anchor tx #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_set_funding_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) { +pub extern "C" fn InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust(); } /// Holder secret key for blinded revocation pubkey #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_revocation_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { +pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key; (*inner_val).as_ref() } /// Holder secret key for blinded revocation pubkey #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_set_revocation_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) { +pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust(); } /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_payment_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { +pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key; (*inner_val).as_ref() } /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_set_payment_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) { +pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust(); } /// Holder secret key used in HTLC tx #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { +pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key; (*inner_val).as_ref() } /// Holder secret key used in HTLC tx #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) { +pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust(); } /// Holder htlc secret key used in commitment tx htlc outputs #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_htlc_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { +pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key; (*inner_val).as_ref() } /// Holder htlc secret key used in commitment tx htlc outputs #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_set_htlc_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) { +pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { unsafe { &mut *this_ptr.inner }.htlc_base_key = val.into_rust(); } /// Commitment seed #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_commitment_seed(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { +pub extern "C" fn InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_seed; &(*inner_val) } /// Commitment seed #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_set_commitment_seed(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::ThirtyTwoBytes) { +pub extern "C" fn InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) { unsafe { &mut *this_ptr.inner }.commitment_seed = val.data; } -impl Clone for InMemoryChannelKeys { +impl Clone for InMemorySigner { fn clone(&self) -> Self { Self { inner: if self.inner.is_null() { std::ptr::null_mut() } else { @@ -889,26 +889,26 @@ impl Clone for InMemoryChannelKeys { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InMemoryChannelKeys_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemoryChannelKeys)).clone() })) as *mut c_void +pub(crate) extern "C" fn InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void } #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_clone(orig: &InMemoryChannelKeys) -> InMemoryChannelKeys { +pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner { orig.clone() } -/// Create a new InMemoryChannelKeys +/// Create a new InMemorySigner #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::chain::keysinterface::InMemoryChannelKeys { - let mut ret = lightning::chain::keysinterface::InMemoryChannelKeys::new(&bitcoin::secp256k1::Secp256k1::new(), funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data); - crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true } +pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::chain::keysinterface::InMemorySigner { + let mut ret = lightning::chain::keysinterface::InMemorySigner::new(&bitcoin::secp256k1::Secp256k1::new(), funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data); + crate::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(ret)), is_owned: true } } /// Counterparty pubkeys. /// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelPublicKeys { +pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &InMemorySigner) -> crate::ln::chan_utils::ChannelPublicKeys { let mut ret = unsafe { &*this_arg.inner }.counterparty_pubkeys(); crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } @@ -919,7 +919,7 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryCh /// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 { +pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &InMemorySigner) -> u16 { let mut ret = unsafe { &*this_arg.inner }.counterparty_selected_contest_delay(); ret } @@ -930,7 +930,7 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_a /// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_holder_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 { +pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &InMemorySigner) -> u16 { let mut ret = unsafe { &*this_arg.inner }.holder_selected_contest_delay(); ret } @@ -939,7 +939,7 @@ pub extern "C" fn InMemoryChannelKeys_holder_selected_contest_delay(this_arg: &I /// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_is_outbound(this_arg: &InMemoryChannelKeys) -> bool { +pub extern "C" fn InMemorySigner_is_outbound(this_arg: &InMemorySigner) -> bool { let mut ret = unsafe { &*this_arg.inner }.is_outbound(); ret } @@ -948,7 +948,7 @@ pub extern "C" fn InMemoryChannelKeys_is_outbound(this_arg: &InMemoryChannelKeys /// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_funding_outpoint(this_arg: &InMemoryChannelKeys) -> crate::chain::transaction::OutPoint { +pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &InMemorySigner) -> crate::chain::transaction::OutPoint { let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } @@ -959,7 +959,7 @@ pub extern "C" fn InMemoryChannelKeys_funding_outpoint(this_arg: &InMemoryChanne /// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_get_channel_parameters(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelTransactionParameters { +pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &InMemorySigner) -> crate::ln::chan_utils::ChannelTransactionParameters { let mut ret = unsafe { &*this_arg.inner }.get_channel_parameters(); crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } @@ -971,7 +971,7 @@ pub extern "C" fn InMemoryChannelKeys_get_channel_parameters(this_arg: &InMemory /// or is not spending the outpoint described by `descriptor.outpoint`. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_sign_counterparty_payment_input(this_arg: &InMemoryChannelKeys, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { +pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { let mut ret = unsafe { &*this_arg.inner }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret @@ -985,125 +985,125 @@ pub extern "C" fn InMemoryChannelKeys_sign_counterparty_payment_input(this_arg: /// sequence set to `descriptor.to_self_delay`. #[must_use] #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_sign_dynamic_p2wsh_input(this_arg: &InMemoryChannelKeys, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { +pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { let mut ret = unsafe { &*this_arg.inner }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } -impl From for crate::chain::keysinterface::ChannelKeys { - fn from(obj: nativeInMemoryChannelKeys) -> Self { - let mut rust_obj = InMemoryChannelKeys { inner: Box::into_raw(Box::new(obj)), is_owned: true }; - let mut ret = InMemoryChannelKeys_as_ChannelKeys(&rust_obj); +impl From for crate::chain::keysinterface::Sign { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = InMemorySigner_as_Sign(&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(InMemoryChannelKeys_free_void); + ret.free = Some(InMemorySigner_free_void); ret } } #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_as_ChannelKeys(this_arg: &InMemoryChannelKeys) -> crate::chain::keysinterface::ChannelKeys { - crate::chain::keysinterface::ChannelKeys { +pub extern "C" fn InMemorySigner_as_Sign(this_arg: &InMemorySigner) -> crate::chain::keysinterface::Sign { + crate::chain::keysinterface::Sign { this_arg: unsafe { (*this_arg).inner as *mut c_void }, free: None, - get_per_commitment_point: InMemoryChannelKeys_ChannelKeys_get_per_commitment_point, - release_commitment_secret: InMemoryChannelKeys_ChannelKeys_release_commitment_secret, + get_per_commitment_point: InMemorySigner_Sign_get_per_commitment_point, + release_commitment_secret: InMemorySigner_Sign_release_commitment_secret, pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true }, - set_pubkeys: Some(InMemoryChannelKeys_ChannelKeys_set_pubkeys), - channel_keys_id: InMemoryChannelKeys_ChannelKeys_channel_keys_id, - sign_counterparty_commitment: InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment, - sign_holder_commitment_and_htlcs: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs, - sign_justice_transaction: InMemoryChannelKeys_ChannelKeys_sign_justice_transaction, - sign_counterparty_htlc_transaction: InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemoryChannelKeys_ChannelKeys_sign_closing_transaction, - sign_channel_announcement: InMemoryChannelKeys_ChannelKeys_sign_channel_announcement, - ready_channel: InMemoryChannelKeys_ChannelKeys_ready_channel, - clone: Some(InMemoryChannelKeys_clone_void), - write: InMemoryChannelKeys_write_void, + set_pubkeys: Some(InMemorySigner_Sign_set_pubkeys), + channel_keys_id: InMemorySigner_Sign_channel_keys_id, + sign_counterparty_commitment: InMemorySigner_Sign_sign_counterparty_commitment, + sign_holder_commitment_and_htlcs: InMemorySigner_Sign_sign_holder_commitment_and_htlcs, + sign_justice_transaction: InMemorySigner_Sign_sign_justice_transaction, + sign_counterparty_htlc_transaction: InMemorySigner_Sign_sign_counterparty_htlc_transaction, + sign_closing_transaction: InMemorySigner_Sign_sign_closing_transaction, + sign_channel_announcement: InMemorySigner_Sign_sign_channel_announcement, + ready_channel: InMemorySigner_Sign_ready_channel, + clone: Some(InMemorySigner_clone_void), + write: InMemorySigner_write_void, } } -use lightning::chain::keysinterface::ChannelKeys as ChannelKeysTraitImport; +use lightning::chain::keysinterface::Sign as SignTraitImport; #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.get_per_commitment_point(idx, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemorySigner_Sign_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.get_per_commitment_point(idx, &bitcoin::secp256k1::Secp256k1::new()); crate::c_types::PublicKey::from_rust(&ret) } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.release_commitment_secret(idx); +extern "C" fn InMemorySigner_Sign_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.release_commitment_secret(idx); crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_pubkeys(this_arg: *const c_void) -> crate::ln::chan_utils::ChannelPublicKeys { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.pubkeys(); +extern "C" fn InMemorySigner_Sign_pubkeys(this_arg: *const c_void) -> crate::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.pubkeys(); crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } -extern "C" fn InMemoryChannelKeys_ChannelKeys_set_pubkeys(trait_self_arg: &ChannelKeys) { +extern "C" fn InMemorySigner_Sign_set_pubkeys(trait_self_arg: &Sign) { // This is a bit race-y in the general case, but for our specific use-cases today, we're safe // Specifically, we must ensure that the first time we're called it can never be in parallel if trait_self_arg.pubkeys.inner.is_null() { - unsafe { &mut *(trait_self_arg as *const ChannelKeys as *mut ChannelKeys) }.pubkeys = InMemoryChannelKeys_ChannelKeys_pubkeys(trait_self_arg.this_arg); + unsafe { &mut *(trait_self_arg as *const Sign as *mut Sign) }.pubkeys = InMemorySigner_Sign_pubkeys(trait_self_arg.this_arg); } } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.channel_keys_id(); +extern "C" fn InMemorySigner_Sign_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.channel_keys_id(); crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemorySigner_Sign_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.sign_counterparty_commitment(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_and_htlcs(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemorySigner_Sign_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.sign_holder_commitment_and_htlcs(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_justice_transaction(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { +extern "C" fn InMemorySigner_Sign_sign_justice_transaction(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { let mut local_htlc = if htlc.inner.is_null() { None } else { Some((* { unsafe { &*htlc.inner } }).clone()) }; - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_justice_transaction(&justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, &bitcoin::secp256k1::Secp256k1::new()); + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.sign_justice_transaction(&justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemorySigner_Sign_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.sign_counterparty_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_closing_transaction(&closing_tx.into_bitcoin(), &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemorySigner_Sign_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.sign_closing_transaction(&closing_tx.into_bitcoin(), &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_channel_announcement(unsafe { &*msg.inner }, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemorySigner_Sign_sign_channel_announcement(this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.sign_channel_announcement(unsafe { &*msg.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } -extern "C" fn InMemoryChannelKeys_ChannelKeys_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters) { - unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.ready_channel(unsafe { &*channel_parameters.inner }) +extern "C" fn InMemorySigner_Sign_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters) { + unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }.ready_channel(unsafe { &*channel_parameters.inner }) } #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_write(obj: &InMemoryChannelKeys) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn InMemorySigner_write(obj: &InMemorySigner) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) } #[no_mangle] -pub(crate) extern "C" fn InMemoryChannelKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemoryChannelKeys) }) +pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) } #[no_mangle] -pub extern "C" fn InMemoryChannelKeys_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemoryChannelKeysDecodeErrorZ { +pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res } @@ -1176,16 +1176,16 @@ pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: KeysManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } } -/// Derive an old set of ChannelKeys for per-channel secrets based on a key derivation +/// Derive an old set of Sign for 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] #[no_mangle] -pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::chain::keysinterface::InMemoryChannelKeys { +pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::chain::keysinterface::InMemorySigner { let mut ret = unsafe { &*this_arg.inner }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); - crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true } + crate::chain::keysinterface::InMemorySigner { inner: Box::into_raw(Box::new(ret)), is_owned: true } } /// Creates a Transaction which spends the given descriptors to the given outputs, plus an @@ -1198,7 +1198,7 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut ch /// 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] #[no_mangle] pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { @@ -1227,7 +1227,7 @@ pub extern "C" fn KeysManager_as_KeysInterface(this_arg: &KeysManager) -> crate: get_node_secret: KeysManager_KeysInterface_get_node_secret, get_destination_script: KeysManager_KeysInterface_get_destination_script, get_shutdown_pubkey: KeysManager_KeysInterface_get_shutdown_pubkey, - get_channel_keys: KeysManager_KeysInterface_get_channel_keys, + get_channel_signer: KeysManager_KeysInterface_get_channel_signer, get_secure_random_bytes: KeysManager_KeysInterface_get_secure_random_bytes, read_chan_signer: KeysManager_KeysInterface_read_chan_signer, } @@ -1249,8 +1249,8 @@ extern "C" fn KeysManager_KeysInterface_get_shutdown_pubkey(this_arg: *const c_v crate::c_types::PublicKey::from_rust(&ret) } #[must_use] -extern "C" fn KeysManager_KeysInterface_get_channel_keys(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys { - let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_channel_keys(_inbound, channel_value_satoshis); +extern "C" fn KeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::chain::keysinterface::Sign { + let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_channel_signer(_inbound, channel_value_satoshis); ret.into() } #[must_use] @@ -1259,7 +1259,7 @@ extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelKeysDecodeErrorZ { +extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ { let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.read_chan_signer(reader.to_slice()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_ret diff --git a/lightning-c-bindings/src/chain/mod.rs b/lightning-c-bindings/src/chain/mod.rs index b7c6bd78e..ad02608bc 100644 --- a/lightning-c-bindings/src/chain/mod.rs +++ b/lightning-c-bindings/src/chain/mod.rs @@ -154,9 +154,8 @@ unsafe impl Send for Watch {} unsafe impl Sync for Watch {} use lightning::chain::Watch as rustWatch; -impl rustWatch for Watch { - type Keys = crate::chain::keysinterface::ChannelKeys; - fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { +impl rustWatch for Watch { + fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.watch_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs index 785a159ed..4a73e5d01 100644 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ b/lightning-c-bindings/src/ln/chan_utils.rs @@ -1,6 +1,5 @@ //! Various utilities for building scripts and deriving keys related to channels. These are -//! largely of interest for those implementing chain::keysinterface::ChannelKeys message signing -//! by hand. +//! largely of interest for those implementing chain::keysinterface::Sign message signing by hand. use std::ffi::c_void; use bitcoin::hashes::Hash; diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index 5fa3e1a9c..1aa7282ac 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -15,7 +15,7 @@ use crate::c_types::*; use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport; -type nativeChannelManager = nativeChannelManagerImport; +type nativeChannelManager = nativeChannelManagerImport; /// 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. @@ -754,6 +754,13 @@ pub extern "C" fn ChannelManager_block_disconnected(this_arg: &ChannelManager, h unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap()) } +/// Blocks until ChannelManager needs to be persisted. Only one listener on `wait` is +/// guaranteed to be woken up. +#[no_mangle] +pub extern "C" fn ChannelManager_wait(this_arg: &ChannelManager) { + unsafe { &*this_arg.inner }.wait() +} + impl From for crate::ln::msgs::ChannelMessageHandler { fn from(obj: nativeChannelManager) -> Self { let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; @@ -871,7 +878,7 @@ pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate: } use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; -type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::ChannelKeys, crate::chain::Watch, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>; +type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::Sign, crate::chain::Watch, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>; /// Arguments for the creation of a ChannelManager that are not deserialized. /// @@ -1024,7 +1031,7 @@ pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::chain::key #[no_mangle] pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) }; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::ln::channelmanager::ChannelManager { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res } diff --git a/lightning-c-bindings/src/util/macro_logger.rs b/lightning-c-bindings/src/util/macro_logger.rs new file mode 100644 index 000000000..79c1ea1bb --- /dev/null +++ b/lightning-c-bindings/src/util/macro_logger.rs @@ -0,0 +1,6 @@ +/// Logging macro utilities. + +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + diff --git a/lightning-c-bindings/src/util/mod.rs b/lightning-c-bindings/src/util/mod.rs index c35bf641a..8e5bf04b8 100644 --- a/lightning-c-bindings/src/util/mod.rs +++ b/lightning-c-bindings/src/util/mod.rs @@ -7,5 +7,6 @@ use crate::c_types::*; pub mod events; pub mod errors; pub mod ser; +pub mod macro_logger; pub mod logger; pub mod config;