From 518f52363785cda5833b6a33a802b143854a569c Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 14 Sep 2020 15:52:02 -0400 Subject: [PATCH 1/4] Clarify docs on payment_point slightly --- lightning/src/ln/chan_utils.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index 89f39ed8ff8..8133c1a59ca 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -349,9 +349,9 @@ pub struct ChannelPublicKeys { /// counterparty to create a secret which the counterparty can reveal to revoke previous /// states. pub revocation_basepoint: PublicKey, - /// The public key which receives an immediately spendable primary channel balance in - /// a broadcaster's commitment transactions. This key is static across every commitment - /// transaction. + /// The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + /// spendable primary channel balance on the broadcaster's commitment transaction. This key is + /// static across every commitment transaction. pub payment_point: PublicKey, /// The base point which is used (with derive_public_key) to derive a per-commitment payment /// public key which receives non-HTLC-encumbered funds which are only available for spending From 49e0a8ce7b2f8482ceca97049cf0f1471b7aa524 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 14 Sep 2020 15:52:33 -0400 Subject: [PATCH 2/4] Update bindings after merge of #633, #679, #683. --- lightning-c-bindings/include/lightning.h | 558 +++++++--- lightning-c-bindings/include/lightningpp.hpp | 998 ++++++++++-------- lightning-c-bindings/include/rust_types.h | 14 +- lightning-c-bindings/src/c_types/derived.rs | 10 +- .../src/chain/keysinterface.rs | 66 +- lightning-c-bindings/src/ln/chan_utils.rs | 82 +- lightning-c-bindings/src/ln/channelmanager.rs | 76 +- lightning-c-bindings/src/ln/channelmonitor.rs | 35 +- lightning-c-bindings/src/ln/msgs.rs | 542 ++++++++++ 9 files changed, 1668 insertions(+), 713 deletions(-) diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 23efa9db6a5..7c4be60daa8 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -40,7 +40,7 @@ typedef enum LDKChannelMonitorUpdateErr { * our state failed, but is expected to succeed at some point in the future). * * Such a failure will \"freeze\" a channel, preventing us from revoking old states or - * submitting new commitment transactions to the remote party. Once the update(s) which failed + * submitting new commitment transactions to the counterparty. Once the update(s) which failed * have been successfully applied, ChannelManager::channel_monitor_updated can be used to * restore the channel to an operational state. * @@ -75,11 +75,19 @@ typedef enum LDKChannelMonitorUpdateErr { /** * Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a * different watchtower and cannot update with all watchtowers that were previously informed - * of this channel). This will force-close the channel in question (which will generate one - * final ChannelMonitorUpdate which must be delivered to at least one ChannelMonitor copy). + * of this channel). * - * Should also be used to indicate a failure to update the local persisted copy of the channel - * monitor. + * At reception of this error, ChannelManager will force-close the channel and return at + * least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at + * least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel + * update must be rejected. + * + * This failure may also signal a failure to update the local persisted copy of one of + * the channel monitor instance. + * + * Note that even when you fail a holder commitment transaction update, you must store the + * update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor + * broadcasts it (e.g distributed channel-monitor deployment) */ LDKChannelMonitorUpdateErr_PermanentFailure, /** @@ -571,14 +579,14 @@ typedef enum LDKSpendableOutputDescriptor_Tag { * it is an output from an old state which we broadcast (which should never happen). * * To derive the delayed_payment key which is used to sign for this input, you must pass the - * local delayed_payment_base_key (ie the private key which corresponds to the pubkey in + * holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in * ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to * chan_utils::derive_private_key. The public key can be generated without the secret key * using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in * ChannelKeys::pubkeys(). * - * To derive the remote_revocation_pubkey provided here (which is used in the witness - * script generation), you must pass the remote revocation_basepoint (which appears in the + * 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::on_accept) and the provided per_commitment point * to chan_utils::derive_public_revocation_key. * @@ -597,7 +605,7 @@ typedef enum LDKSpendableOutputDescriptor_Tag { * These are generally the result of our counterparty having broadcast the current state, * allowing us to claim the non-HTLC-encumbered outputs immediately. */ - LDKSpendableOutputDescriptor_StaticOutputRemotePayment, + LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment, /** * Must be last for serialization purposes */ @@ -615,21 +623,21 @@ typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body { uint16_t to_self_delay; LDKTxOut output; LDKC2Tuple_u64u64Z key_derivation_params; - LDKPublicKey remote_revocation_pubkey; + LDKPublicKey revocation_pubkey; } LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body; -typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputRemotePayment_Body { +typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body { LDKOutPoint outpoint; LDKTxOut output; LDKC2Tuple_u64u64Z key_derivation_params; -} LDKSpendableOutputDescriptor_LDKStaticOutputRemotePayment_Body; +} LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body; typedef struct LDKSpendableOutputDescriptor { LDKSpendableOutputDescriptor_Tag tag; union { LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh; - LDKSpendableOutputDescriptor_LDKStaticOutputRemotePayment_Body static_output_remote_payment; + LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body static_output_counterparty_payment; }; } LDKSpendableOutputDescriptor; @@ -1582,18 +1590,18 @@ typedef LDKCVecTempl_HTLCOutputInCommitment LDKCVec_HTLCOutputInCommitmentZ; /** - * We use this to track local commitment transactions and put off signing them until we are ready + * We use this to track holder commitment transactions and put off signing them until we are ready * to broadcast. This class can be used inside a signer implementation to generate a signature * given the relevant secret key. */ -typedef struct MUST_USE_STRUCT LDKLocalCommitmentTransaction { +typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction { /** * Nearly everyhwere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeLocalCommitmentTransaction *inner; + LDKnativeHolderCommitmentTransaction *inner; bool is_owned; -} LDKLocalCommitmentTransaction; +} LDKHolderCommitmentTransaction; @@ -1654,7 +1662,7 @@ typedef struct LDKChannelKeys { */ LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** - * Gets the local channel public keys and basepoints + * Gets the holder's channel public keys and basepoints */ LDKChannelPublicKeys pubkeys; /** @@ -1670,34 +1678,34 @@ typedef struct LDKChannelKeys { */ LDKC2Tuple_u64u64Z (*key_derivation_params)(const void *this_arg); /** - * Create a signature for a remote commitment transaction and associated HTLC transactions. + * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. * * Note that if signing fails or is rejected, the channel will be force-closed. */ - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_remote_commitment)(const void *this_arg, uint32_t feerate_per_kw, LDKTransaction commitment_tx, const LDKPreCalculatedTxCreationKeys *keys, LDKCVec_HTLCOutputInCommitmentZ htlcs); + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, uint32_t feerate_per_kw, LDKTransaction commitment_tx, const LDKPreCalculatedTxCreationKeys *keys, LDKCVec_HTLCOutputInCommitmentZ htlcs); /** - * Create a signature for a local commitment transaction. This will only ever be called with - * the same local_commitment_tx (or a copy thereof), though there are currently no guarantees + * Create a signature for a holder's commitment transaction. This will only ever be called with + * the same holder_commitment_tx (or a copy thereof), though there are currently no guarantees * that it will not be called multiple times. * An external signer implementation should check that the commitment has not been revoked. */ - LDKCResult_SignatureNoneZ (*sign_local_commitment)(const void *this_arg, const LDKLocalCommitmentTransaction *local_commitment_tx); + LDKCResult_SignatureNoneZ (*sign_holder_commitment)(const void *this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx); /** - * Create a signature for each HTLC transaction spending a local commitment transaction. + * Create a signature for each HTLC transaction spending a holder's commitment transaction. * - * Unlike sign_local_commitment, this may be called multiple times with *different* - * local_commitment_tx values. While this will never be called with a revoked - * local_commitment_tx, it is possible that it is called with the second-latest - * local_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary + * Unlike sign_holder_commitment, this may be called multiple times with *different* + * holder_commitment_tx values. While this will never be called with a revoked + * holder_commitment_tx, it is possible that it is called with the second-latest + * holder_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary * ChannelMonitor decided to broadcast before it had been updated to the latest. * * Either an Err should be returned, or a Vec with one entry for each HTLC which exists in - * local_commitment_tx. For those HTLCs which have transaction_output_index set to None + * holder_commitment_tx. For those HTLCs which have transaction_output_index set to None * (implying they were considered dust at the time the commitment transaction was negotiated), * a corresponding None should be included in the return value. All other positions in the * return value must contain a signature. */ - LDKCResult_CVec_SignatureZNoneZ (*sign_local_commitment_htlc_transactions)(const void *this_arg, const LDKLocalCommitmentTransaction *local_commitment_tx); + LDKCResult_CVec_SignatureZNoneZ (*sign_holder_commitment_htlc_transactions)(const void *this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx); /** * Create a signature for the given input in a transaction spending an HTLC or commitment * transaction output when our counterparty broadcasts an old state. @@ -1710,8 +1718,8 @@ typedef struct LDKChannelKeys { * Amount is value of the output spent by this input, committed to in the BIP 143 signature. * * per_commitment_key is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _local_ secret key and does - * not allow the spending of any funds by itself (you need our local revocation_secret to do + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder revocation_secret to do * so). * * htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus @@ -1720,7 +1728,7 @@ typedef struct LDKChannelKeys { */ LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const LDKHTLCOutputInCommitment *htlc); /** - * Create a signature for a claiming transaction for a HTLC output on a remote commitment + * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment * transaction, either offered or received. * * Such a transaction may claim multiples offered outputs at same time if we know the @@ -1738,7 +1746,7 @@ typedef struct LDKChannelKeys { * channel state keys, which are then included in the witness script and committed to in the * BIP 143 signature. */ - LDKCResult_SignatureNoneZ (*sign_remote_htlc_transaction)(const void *this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment *htlc); + LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment *htlc); /** * Create a signature for a (proposed) closing transaction. * @@ -1756,14 +1764,14 @@ typedef struct LDKChannelKeys { */ LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const LDKUnsignedChannelAnnouncement *msg); /** - * Set the remote channel basepoints and remote/local to_self_delay. + * Set the counterparty channel basepoints and counterparty_selected/holder_selected_contest_delay. * This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels. * - * We bind local_to_self_delay late here for API convenience. + * We bind holder_selected_contest_delay late here for API convenience. * * Will be called before any signatures are applied. */ - void (*on_accept)(void *this_arg, const LDKChannelPublicKeys *channel_points, uint16_t remote_to_self_delay, uint16_t local_to_self_delay); + void (*on_accept)(void *this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay); void *(*clone)(const void *this_arg); void (*free)(void *this_arg); } LDKChannelKeys; @@ -1950,6 +1958,11 @@ typedef struct LDKManyChannelMonitor { * * Any spends of outputs which should have been registered which aren't passed to * ChannelMonitors via block_connected may result in FUNDS LOSS. + * + * In case of distributed watchtowers deployment, even if an Err is return, the new version + * must be written to disk, as state may have been stored but rejected due to a block forcing + * a commitment broadcast. This storage is used to claim outputs of rejected state confirmed + * onchain by another watchtower, lagging behind on block processing. */ LDKCResult_NoneChannelMonitorUpdateErrZ (*update_monitor)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor); /** @@ -2474,6 +2487,104 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { +/** + * A query_channel_range message is used to query a peer for channel + * UTXOs in a range of blocks. The recipient of a query makes a best + * effort to reply to the query using one or more reply_channel_range + * messages. + */ +typedef struct MUST_USE_STRUCT LDKQueryChannelRange { + /** + * Nearly everyhwere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeQueryChannelRange *inner; + bool is_owned; +} LDKQueryChannelRange; + + + +/** + * A reply_channel_range message is a reply to a query_channel_range + * message. Multiple reply_channel_range messages can be sent in reply + * to a single query_channel_range message. The query recipient makes a + * best effort to respond based on their local network view which may + * not be a perfect view of the network. The short_channel_ids in the + * reply are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. + */ +typedef struct MUST_USE_STRUCT LDKReplyChannelRange { + /** + * Nearly everyhwere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReplyChannelRange *inner; + bool is_owned; +} LDKReplyChannelRange; + +typedef struct LDKCVecTempl_u64 { + uint64_t *data; + uintptr_t datalen; +} LDKCVecTempl_u64; + +typedef LDKCVecTempl_u64 LDKCVec_u64Z; + + + +/** + * A query_short_channel_ids message is used to query a peer for + * routing gossip messages related to one or more short_channel_ids. + * The query recipient will reply with the latest, if available, + * channel_announcement, channel_update and node_announcement messages + * it maintains for the requested short_channel_ids followed by a + * reply_short_channel_ids_end message. The short_channel_ids sent in + * this query are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. + */ +typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { + /** + * Nearly everyhwere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeQueryShortChannelIds *inner; + bool is_owned; +} LDKQueryShortChannelIds; + + + +/** + * A reply_short_channel_ids_end message is sent as a reply to a + * query_short_channel_ids message. The query recipient makes a best + * effort to respond based on their local network view which may not be + * a perfect view of the network. + */ +typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { + /** + * Nearly everyhwere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReplyShortChannelIdsEnd *inner; + bool is_owned; +} LDKReplyShortChannelIdsEnd; + + + +/** + * A gossip_timestamp_filter message is used by a node to request + * gossip relay for messages in the requested time range when the + * gossip_queries feature has been negotiated. + */ +typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { + /** + * Nearly everyhwere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeGossipTimestampFilter *inner; + bool is_owned; +} LDKGossipTimestampFilter; + + + /** * An Err type for failure to process messages. */ @@ -2726,6 +2837,10 @@ typedef LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ * The set of public keys which are used in the creation of one commitment transaction. * These are derived from the channel base keys and per-commitment data. * + * A broadcaster key is provided from potential broadcaster of the computed transaction. + * A countersignatory key is coming from a protocol participant unable to broadcast the + * transaction. + * * These keys are assumed to be good, either because the code derived them from * channel basepoints via the new function, or they were obtained via * PreCalculatedTxCreationKeys.trust_key_derivation because we trusted the source of the @@ -2966,13 +3081,6 @@ typedef struct MUST_USE_STRUCT LDKNodeInfo { bool is_owned; } LDKNodeInfo; -typedef struct LDKCVecTempl_u64 { - uint64_t *data; - uintptr_t datalen; -} LDKCVecTempl_u64; - -typedef LDKCVecTempl_u64 LDKCVec_u64Z; - typedef LDKCVecTempl_RouteHop LDKCVec_RouteHopZ; extern const void (*C2Tuple_HTLCOutputInCommitmentSignatureZ_free)(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ); @@ -3728,42 +3836,42 @@ const uint8_t (*InMemoryChannelKeys_get_funding_key(const LDKInMemoryChannelKeys void InMemoryChannelKeys_set_funding_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); /** - * Local secret key for blinded revocation pubkey + * Holder secret key for blinded revocation pubkey */ const uint8_t (*InMemoryChannelKeys_get_revocation_base_key(const LDKInMemoryChannelKeys *this_ptr))[32]; /** - * Local secret key for blinded revocation pubkey + * Holder secret key for blinded revocation pubkey */ void InMemoryChannelKeys_set_revocation_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); /** - * Local secret key used for our balance in remote-broadcasted commitment transactions + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ const uint8_t (*InMemoryChannelKeys_get_payment_key(const LDKInMemoryChannelKeys *this_ptr))[32]; /** - * Local secret key used for our balance in remote-broadcasted commitment transactions + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ void InMemoryChannelKeys_set_payment_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); /** - * Local secret key used in HTLC tx + * Holder secret key used in HTLC tx */ const uint8_t (*InMemoryChannelKeys_get_delayed_payment_base_key(const LDKInMemoryChannelKeys *this_ptr))[32]; /** - * Local secret key used in HTLC tx + * Holder secret key used in HTLC tx */ void InMemoryChannelKeys_set_delayed_payment_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); /** - * Local htlc secret key used in commitment tx htlc outputs + * Holder htlc secret key used in commitment tx htlc outputs */ const uint8_t (*InMemoryChannelKeys_get_htlc_base_key(const LDKInMemoryChannelKeys *this_ptr))[32]; /** - * Local htlc secret key used in commitment tx htlc outputs + * Holder htlc secret key used in commitment tx htlc outputs */ void InMemoryChannelKeys_set_htlc_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); @@ -3783,27 +3891,27 @@ void InMemoryChannelKeys_set_commitment_seed(LDKInMemoryChannelKeys *this_ptr, L MUST_USE_RES LDKInMemoryChannelKeys InMemoryChannelKeys_new(LDKSecretKey funding_key, LDKSecretKey revocation_base_key, LDKSecretKey payment_key, LDKSecretKey delayed_payment_base_key, LDKSecretKey htlc_base_key, LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, LDKC2Tuple_u64u64Z key_derivation_params); /** - * Remote pubkeys. + * Counterparty pubkeys. * Will panic if on_accept wasn't called. */ -MUST_USE_RES LDKChannelPublicKeys InMemoryChannelKeys_remote_pubkeys(const LDKInMemoryChannelKeys *this_arg); +MUST_USE_RES LDKChannelPublicKeys InMemoryChannelKeys_counterparty_pubkeys(const LDKInMemoryChannelKeys *this_arg); /** - * The to_self_delay value specified by our counterparty and applied on locally-broadcastable + * The contest_delay value specified by our counterparty and applied on holder-broadcastable * transactions, ie the amount of time that we have to wait to recover our funds if we * broadcast a transaction. You'll likely want to pass this to the - * ln::chan_utils::build*_transaction functions when signing local transactions. + * ln::chan_utils::build*_transaction functions when signing holder's transactions. * Will panic if on_accept wasn't called. */ -MUST_USE_RES uint16_t InMemoryChannelKeys_remote_to_self_delay(const LDKInMemoryChannelKeys *this_arg); +MUST_USE_RES uint16_t InMemoryChannelKeys_counterparty_selected_contest_delay(const LDKInMemoryChannelKeys *this_arg); /** - * The to_self_delay value specified by us and applied on transactions broadcastable + * The contest_delay value specified by us and applied on transactions broadcastable * by our counterparty, ie the amount of time that they have to wait to recover their funds * if they broadcast a transaction. * Will panic if on_accept wasn't called. */ -MUST_USE_RES uint16_t InMemoryChannelKeys_local_to_self_delay(const LDKInMemoryChannelKeys *this_arg); +MUST_USE_RES uint16_t InMemoryChannelKeys_holder_selected_contest_delay(const LDKInMemoryChannelKeys *this_arg); LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const LDKInMemoryChannelKeys *this_arg); @@ -4360,17 +4468,17 @@ MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_ MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg); /** - * Used by ChannelManager deserialization to broadcast the latest local state if its copy of - * the Channel was out-of-date. You may use it to get a broadcastable local toxic tx in case of - * fallen-behind, i.e when receiving a channel_reestablish with a proof that our remote side knows - * a higher revocation secret than the local commitment number we are aware of. Broadcasting these - * transactions are UNSAFE, as they allow remote side to punish you. Nevertheless you may want to - * broadcast them if remote don't close channel with his higher commitment transaction after a + * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of + * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of + * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows + * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these + * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to + * broadcast them if counterparty don't close channel with his higher commitment transaction after a * substantial amount of time (a month or even a year) to get back funds. Best may be to contact * out-of-band the other node operator to coordinate with him if option is available to you. * In any-case, choice is up to the user. */ -MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_local_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger); +MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger); void DecodeError_free(LDKDecodeError this_ptr); @@ -5552,6 +5660,170 @@ void ChannelUpdate_set_contents(LDKChannelUpdate *this_ptr, LDKUnsignedChannelUp MUST_USE_RES LDKChannelUpdate ChannelUpdate_new(LDKSignature signature_arg, LDKUnsignedChannelUpdate contents_arg); +void QueryChannelRange_free(LDKQueryChannelRange this_ptr); + +/** + * The genesis hash of the blockchain being queried + */ +const uint8_t (*QueryChannelRange_get_chain_hash(const LDKQueryChannelRange *this_ptr))[32]; + +/** + * The genesis hash of the blockchain being queried + */ +void QueryChannelRange_set_chain_hash(LDKQueryChannelRange *this_ptr, LDKThirtyTwoBytes val); + +/** + * The height of the first block for the channel UTXOs being queried + */ +uint32_t QueryChannelRange_get_first_blocknum(const LDKQueryChannelRange *this_ptr); + +/** + * The height of the first block for the channel UTXOs being queried + */ +void QueryChannelRange_set_first_blocknum(LDKQueryChannelRange *this_ptr, uint32_t val); + +/** + * The number of blocks to include in the query results + */ +uint32_t QueryChannelRange_get_number_of_blocks(const LDKQueryChannelRange *this_ptr); + +/** + * The number of blocks to include in the query results + */ +void QueryChannelRange_set_number_of_blocks(LDKQueryChannelRange *this_ptr, uint32_t val); + +MUST_USE_RES LDKQueryChannelRange QueryChannelRange_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); + +void ReplyChannelRange_free(LDKReplyChannelRange this_ptr); + +/** + * The genesis hash of the blockchain being queried + */ +const uint8_t (*ReplyChannelRange_get_chain_hash(const LDKReplyChannelRange *this_ptr))[32]; + +/** + * The genesis hash of the blockchain being queried + */ +void ReplyChannelRange_set_chain_hash(LDKReplyChannelRange *this_ptr, LDKThirtyTwoBytes val); + +/** + * The height of the first block in the range of the reply + */ +uint32_t ReplyChannelRange_get_first_blocknum(const LDKReplyChannelRange *this_ptr); + +/** + * The height of the first block in the range of the reply + */ +void ReplyChannelRange_set_first_blocknum(LDKReplyChannelRange *this_ptr, uint32_t val); + +/** + * The number of blocks included in the range of the reply + */ +uint32_t ReplyChannelRange_get_number_of_blocks(const LDKReplyChannelRange *this_ptr); + +/** + * The number of blocks included in the range of the reply + */ +void ReplyChannelRange_set_number_of_blocks(LDKReplyChannelRange *this_ptr, uint32_t val); + +/** + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash + */ +bool ReplyChannelRange_get_full_information(const LDKReplyChannelRange *this_ptr); + +/** + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash + */ +void ReplyChannelRange_set_full_information(LDKReplyChannelRange *this_ptr, bool val); + +/** + * The short_channel_ids in the channel range + */ +void ReplyChannelRange_set_short_channel_ids(LDKReplyChannelRange *this_ptr, LDKCVec_u64Z val); + +MUST_USE_RES LDKReplyChannelRange ReplyChannelRange_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool full_information_arg, LDKCVec_u64Z short_channel_ids_arg); + +void QueryShortChannelIds_free(LDKQueryShortChannelIds this_ptr); + +/** + * The genesis hash of the blockchain being queried + */ +const uint8_t (*QueryShortChannelIds_get_chain_hash(const LDKQueryShortChannelIds *this_ptr))[32]; + +/** + * The genesis hash of the blockchain being queried + */ +void QueryShortChannelIds_set_chain_hash(LDKQueryShortChannelIds *this_ptr, LDKThirtyTwoBytes val); + +/** + * The short_channel_ids that are being queried + */ +void QueryShortChannelIds_set_short_channel_ids(LDKQueryShortChannelIds *this_ptr, LDKCVec_u64Z val); + +MUST_USE_RES LDKQueryShortChannelIds QueryShortChannelIds_new(LDKThirtyTwoBytes chain_hash_arg, LDKCVec_u64Z short_channel_ids_arg); + +void ReplyShortChannelIdsEnd_free(LDKReplyShortChannelIdsEnd this_ptr); + +/** + * The genesis hash of the blockchain that was queried + */ +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const LDKReplyShortChannelIdsEnd *this_ptr))[32]; + +/** + * The genesis hash of the blockchain that was queried + */ +void ReplyShortChannelIdsEnd_set_chain_hash(LDKReplyShortChannelIdsEnd *this_ptr, LDKThirtyTwoBytes val); + +/** + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash + */ +bool ReplyShortChannelIdsEnd_get_full_information(const LDKReplyShortChannelIdsEnd *this_ptr); + +/** + * Indicates if the query recipient maintains up-to-date channel + * information for the chain_hash + */ +void ReplyShortChannelIdsEnd_set_full_information(LDKReplyShortChannelIdsEnd *this_ptr, bool val); + +MUST_USE_RES LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); + +void GossipTimestampFilter_free(LDKGossipTimestampFilter this_ptr); + +/** + * The genesis hash of the blockchain for channel and node information + */ +const uint8_t (*GossipTimestampFilter_get_chain_hash(const LDKGossipTimestampFilter *this_ptr))[32]; + +/** + * The genesis hash of the blockchain for channel and node information + */ +void GossipTimestampFilter_set_chain_hash(LDKGossipTimestampFilter *this_ptr, LDKThirtyTwoBytes val); + +/** + * The starting unix timestamp + */ +uint32_t GossipTimestampFilter_get_first_timestamp(const LDKGossipTimestampFilter *this_ptr); + +/** + * The starting unix timestamp + */ +void GossipTimestampFilter_set_first_timestamp(LDKGossipTimestampFilter *this_ptr, uint32_t val); + +/** + * The range of information in seconds + */ +uint32_t GossipTimestampFilter_get_timestamp_range(const LDKGossipTimestampFilter *this_ptr); + +/** + * The range of information in seconds + */ +void GossipTimestampFilter_set_timestamp_range(LDKGossipTimestampFilter *this_ptr, uint32_t val); + +MUST_USE_RES LDKGossipTimestampFilter GossipTimestampFilter_new(LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); + void ErrorAction_free(LDKErrorAction this_ptr); void LightningError_free(LDKLightningError this_ptr); @@ -5738,6 +6010,26 @@ LDKCVec_u8Z NodeAnnouncement_write(const LDKNodeAnnouncement *obj); LDKNodeAnnouncement NodeAnnouncement_read(LDKu8slice ser); +LDKQueryShortChannelIds QueryShortChannelIds_read(LDKu8slice ser); + +LDKCVec_u8Z QueryShortChannelIds_write(const LDKQueryShortChannelIds *obj); + +LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_read(LDKu8slice ser); + +LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const LDKReplyShortChannelIdsEnd *obj); + +LDKQueryChannelRange QueryChannelRange_read(LDKu8slice ser); + +LDKCVec_u8Z QueryChannelRange_write(const LDKQueryChannelRange *obj); + +LDKReplyChannelRange ReplyChannelRange_read(LDKu8slice ser); + +LDKCVec_u8Z ReplyChannelRange_write(const LDKReplyChannelRange *obj); + +LDKGossipTimestampFilter GossipTimestampFilter_read(LDKu8slice ser); + +LDKCVec_u8Z GossipTimestampFilter_write(const LDKGossipTimestampFilter *obj); + void MessageHandler_free(LDKMessageHandler this_ptr); /** @@ -5913,76 +6205,88 @@ LDKCResult_PublicKeySecpErrorZ derive_public_key(LDKPublicKey per_commitment_poi /** * Derives a per-commitment-transaction revocation key from its constituent parts. * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_secret always come from cheater + * and revocation_base_secret always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * * Note that this is infallible iff we trust that at least one of the two input keys are randomly * generated (ie our own). */ -LDKCResult_SecretKeySecpErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*revocation_base_secret)[32]); +LDKCResult_SecretKeySecpErrorZ derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); /** * Derives a per-commitment-transaction revocation public key from its constituent parts. This is * the public equivalend of derive_private_revocation_key - using only public keys to derive a * public key instead of private keys. * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_point always come from cheater + * and revocation_base_point always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * * Note that this is infallible iff we trust that at least one of the two input keys are randomly * generated (ie our own). */ -LDKCResult_PublicKeySecpErrorZ derive_public_revocation_key(LDKPublicKey per_commitment_point, LDKPublicKey revocation_base_point); +LDKCResult_PublicKeySecpErrorZ derive_public_revocation_key(LDKPublicKey per_commitment_point, LDKPublicKey countersignatory_revocation_base_point); void TxCreationKeys_free(LDKTxCreationKeys this_ptr); /** - * The per-commitment public key which was used to derive the other keys. + * The broadcaster's per-commitment public key which was used to derive the other keys. */ LDKPublicKey TxCreationKeys_get_per_commitment_point(const LDKTxCreationKeys *this_ptr); /** - * The per-commitment public key which was used to derive the other keys. + * The broadcaster's per-commitment public key which was used to derive the other keys. */ void TxCreationKeys_set_per_commitment_point(LDKTxCreationKeys *this_ptr, LDKPublicKey val); /** - * The revocation key which is used to allow the owner of the commitment transaction to - * provide their counterparty the ability to punish them if they broadcast an old state. + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ LDKPublicKey TxCreationKeys_get_revocation_key(const LDKTxCreationKeys *this_ptr); /** - * The revocation key which is used to allow the owner of the commitment transaction to - * provide their counterparty the ability to punish them if they broadcast an old state. + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ void TxCreationKeys_set_revocation_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); /** - * A's HTLC Key + * Broadcaster's HTLC Key */ -LDKPublicKey TxCreationKeys_get_a_htlc_key(const LDKTxCreationKeys *this_ptr); +LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const LDKTxCreationKeys *this_ptr); /** - * A's HTLC Key + * Broadcaster's HTLC Key */ -void TxCreationKeys_set_a_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); +void TxCreationKeys_set_broadcaster_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); /** - * B's HTLC Key + * Countersignatory's HTLC Key */ -LDKPublicKey TxCreationKeys_get_b_htlc_key(const LDKTxCreationKeys *this_ptr); +LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const LDKTxCreationKeys *this_ptr); /** - * B's HTLC Key + * Countersignatory's HTLC Key */ -void TxCreationKeys_set_b_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); +void TxCreationKeys_set_countersignatory_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); /** - * A's Payment Key (which isn't allowed to be spent from for some delay) + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -LDKPublicKey TxCreationKeys_get_a_delayed_payment_key(const LDKTxCreationKeys *this_ptr); +LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const LDKTxCreationKeys *this_ptr); /** - * A's Payment Key (which isn't allowed to be spent from for some delay) + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -void TxCreationKeys_set_a_delayed_payment_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); +void TxCreationKeys_set_broadcaster_delayed_payment_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); -MUST_USE_RES LDKTxCreationKeys TxCreationKeys_new(LDKPublicKey per_commitment_point_arg, LDKPublicKey revocation_key_arg, LDKPublicKey a_htlc_key_arg, LDKPublicKey b_htlc_key_arg, LDKPublicKey a_delayed_payment_key_arg); +MUST_USE_RES LDKTxCreationKeys TxCreationKeys_new(LDKPublicKey per_commitment_point_arg, LDKPublicKey revocation_key_arg, LDKPublicKey broadcaster_htlc_key_arg, LDKPublicKey countersignatory_htlc_key_arg, LDKPublicKey broadcaster_delayed_payment_key_arg); LDKCVec_u8Z TxCreationKeys_write(const LDKTxCreationKeys *obj); @@ -6037,16 +6341,16 @@ LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const LDKChannelPublicKe void ChannelPublicKeys_set_revocation_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val); /** - * The public key which receives our immediately spendable primary channel balance in - * remote-broadcasted commitment transactions. This key is static across every commitment - * transaction. + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ LDKPublicKey ChannelPublicKeys_get_payment_point(const LDKChannelPublicKeys *this_ptr); /** - * The public key which receives our immediately spendable primary channel balance in - * remote-broadcasted commitment transactions. This key is static across every commitment - * transaction. + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ void ChannelPublicKeys_set_payment_point(LDKChannelPublicKeys *this_ptr, LDKPublicKey val); @@ -6085,14 +6389,14 @@ LDKChannelPublicKeys ChannelPublicKeys_read(LDKu8slice ser); /** * Create a new TxCreationKeys from channel base points and the per-commitment point */ -MUST_USE_RES LDKCResult_TxCreationKeysSecpErrorZ TxCreationKeys_derive_new(LDKPublicKey per_commitment_point, LDKPublicKey a_delayed_payment_base, LDKPublicKey a_htlc_base, LDKPublicKey b_revocation_base, LDKPublicKey b_htlc_base); +MUST_USE_RES LDKCResult_TxCreationKeysSecpErrorZ TxCreationKeys_derive_new(LDKPublicKey per_commitment_point, LDKPublicKey broadcaster_delayed_payment_base, LDKPublicKey broadcaster_htlc_base, LDKPublicKey countersignatory_revocation_base, LDKPublicKey countersignatory_htlc_base); /** * A script either spendable by the revocation - * key or the delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. - * Encumbering a `to_local` output on a commitment transaction or 2nd-stage HTLC transactions. + * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. + * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -LDKCVec_u8Z get_revokeable_redeemscript(LDKPublicKey revocation_key, uint16_t to_self_delay, LDKPublicKey delayed_payment_key); +LDKCVec_u8Z get_revokeable_redeemscript(LDKPublicKey revocation_key, uint16_t contest_delay, LDKPublicKey broadcaster_delayed_payment_key); void HTLCOutputInCommitment_free(LDKHTLCOutputInCommitment this_ptr); @@ -6100,7 +6404,7 @@ void HTLCOutputInCommitment_free(LDKHTLCOutputInCommitment this_ptr); * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). * Note that this is not the same as whether it is ountbound *from us*. To determine that you * need to compare this value to whether the commitment transaction in question is that of - * the remote party or our own. + * the counterparty or our own. */ bool HTLCOutputInCommitment_get_offered(const LDKHTLCOutputInCommitment *this_ptr); @@ -6108,7 +6412,7 @@ bool HTLCOutputInCommitment_get_offered(const LDKHTLCOutputInCommitment *this_pt * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). * Note that this is not the same as whether it is ountbound *from us*. To determine that you * need to compare this value to whether the commitment transaction in question is that of - * the remote party or our own. + * the counterparty or our own. */ void HTLCOutputInCommitment_set_offered(LDKHTLCOutputInCommitment *this_ptr, bool val); @@ -6149,8 +6453,8 @@ LDKCVec_u8Z HTLCOutputInCommitment_write(const LDKHTLCOutputInCommitment *obj); LDKHTLCOutputInCommitment HTLCOutputInCommitment_read(LDKu8slice ser); /** - * note here that 'a_revocation_key' is generated using b_revocation_basepoint and a's - * commitment secret. 'htlc' does *not* need to have its previous_output_index filled. + * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc + * does not need to have its previous_output_index filled. */ LDKCVec_u8Z get_htlc_redeemscript(const LDKHTLCOutputInCommitment *htlc, const LDKTxCreationKeys *keys); @@ -6158,91 +6462,91 @@ LDKCVec_u8Z get_htlc_redeemscript(const LDKHTLCOutputInCommitment *htlc, const L * Gets the redeemscript for a funding output from the two funding public keys. * Note that the order of funding public keys does not matter. */ -LDKCVec_u8Z make_funding_redeemscript(LDKPublicKey a, LDKPublicKey b); +LDKCVec_u8Z make_funding_redeemscript(LDKPublicKey broadcaster, LDKPublicKey countersignatory); /** * panics if htlc.transaction_output_index.is_none()! */ -LDKCVec_u8Z build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t to_self_delay, const LDKHTLCOutputInCommitment *htlc, LDKPublicKey a_delayed_payment_key, LDKPublicKey revocation_key); +LDKCVec_u8Z build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const LDKHTLCOutputInCommitment *htlc, LDKPublicKey broadcaster_delayed_payment_key, LDKPublicKey revocation_key); -void LocalCommitmentTransaction_free(LDKLocalCommitmentTransaction this_ptr); +void HolderCommitmentTransaction_free(LDKHolderCommitmentTransaction this_ptr); /** * The commitment transaction itself, in unsigned form. */ -LDKCVec_u8Z LocalCommitmentTransaction_get_unsigned_tx(const LDKLocalCommitmentTransaction *this_ptr); +LDKCVec_u8Z HolderCommitmentTransaction_get_unsigned_tx(const LDKHolderCommitmentTransaction *this_ptr); /** * The commitment transaction itself, in unsigned form. */ -void LocalCommitmentTransaction_set_unsigned_tx(LDKLocalCommitmentTransaction *this_ptr, LDKCVec_u8Z val); +void HolderCommitmentTransaction_set_unsigned_tx(LDKHolderCommitmentTransaction *this_ptr, LDKCVec_u8Z val); /** * Our counterparty's signature for the transaction, above. */ -LDKSignature LocalCommitmentTransaction_get_their_sig(const LDKLocalCommitmentTransaction *this_ptr); +LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const LDKHolderCommitmentTransaction *this_ptr); /** * Our counterparty's signature for the transaction, above. */ -void LocalCommitmentTransaction_set_their_sig(LDKLocalCommitmentTransaction *this_ptr, LDKSignature val); +void HolderCommitmentTransaction_set_counterparty_sig(LDKHolderCommitmentTransaction *this_ptr, LDKSignature val); /** * The feerate paid per 1000-weight-unit in this commitment transaction. This value is * controlled by the channel initiator. */ -uint32_t LocalCommitmentTransaction_get_feerate_per_kw(const LDKLocalCommitmentTransaction *this_ptr); +uint32_t HolderCommitmentTransaction_get_feerate_per_kw(const LDKHolderCommitmentTransaction *this_ptr); /** * The feerate paid per 1000-weight-unit in this commitment transaction. This value is * controlled by the channel initiator. */ -void LocalCommitmentTransaction_set_feerate_per_kw(LDKLocalCommitmentTransaction *this_ptr, uint32_t val); +void HolderCommitmentTransaction_set_feerate_per_kw(LDKHolderCommitmentTransaction *this_ptr, uint32_t val); /** - * The HTLCs and remote htlc signatures which were included in this commitment transaction. + * The HTLCs and counterparty htlc signatures which were included in this commitment transaction. * * Note that this includes all HTLCs, including ones which were considered dust and not * actually included in the transaction as it appears on-chain, but who's value is burned as - * fees and not included in the to_local or to_remote outputs. + * fees and not included in the to_holder or to_counterparty outputs. * - * The remote HTLC signatures in the second element will always be set for non-dust HTLCs, ie + * The counterparty HTLC signatures in the second element will always be set for non-dust HTLCs, ie * those for which transaction_output_index.is_some(). */ -void LocalCommitmentTransaction_set_per_htlc(LDKLocalCommitmentTransaction *this_ptr, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val); +void HolderCommitmentTransaction_set_per_htlc(LDKHolderCommitmentTransaction *this_ptr, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val); /** - * Generate a new LocalCommitmentTransaction based on a raw commitment transaction, - * remote signature and both parties keys. + * Generate a new HolderCommitmentTransaction based on a raw commitment transaction, + * counterparty signature and both parties keys. * * The unsigned transaction outputs must be consistent with htlc_data. This function * only checks that the shape and amounts are consistent, but does not check the scriptPubkey. */ -MUST_USE_RES LDKLocalCommitmentTransaction LocalCommitmentTransaction_new_missing_local_sig(LDKCVec_u8Z unsigned_tx, LDKSignature their_sig, LDKPublicKey our_funding_key, LDKPublicKey their_funding_key, LDKTxCreationKeys local_keys, uint32_t feerate_per_kw, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data); +MUST_USE_RES LDKHolderCommitmentTransaction HolderCommitmentTransaction_new_missing_holder_sig(LDKCVec_u8Z unsigned_tx, LDKSignature counterparty_sig, LDKPublicKey holder_funding_key, LDKPublicKey counterparty_funding_key, LDKTxCreationKeys keys, uint32_t feerate_per_kw, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data); /** * The pre-calculated transaction creation public keys. * An external validating signer should not trust these keys. */ -MUST_USE_RES LDKTxCreationKeys LocalCommitmentTransaction_trust_key_derivation(const LDKLocalCommitmentTransaction *this_arg); +MUST_USE_RES LDKTxCreationKeys HolderCommitmentTransaction_trust_key_derivation(const LDKHolderCommitmentTransaction *this_arg); /** - * Get the txid of the local commitment transaction contained in this - * LocalCommitmentTransaction + * Get the txid of the holder commitment transaction contained in this + * HolderCommitmentTransaction */ -MUST_USE_RES LDKThirtyTwoBytes LocalCommitmentTransaction_txid(const LDKLocalCommitmentTransaction *this_arg); +MUST_USE_RES LDKThirtyTwoBytes HolderCommitmentTransaction_txid(const LDKHolderCommitmentTransaction *this_arg); /** - * Gets our signature for the contained commitment transaction given our funding private key. + * Gets holder signature for the contained commitment transaction given holder funding private key. * * Funding key is your key included in the 2-2 funding_outpoint lock. Should be provided * by your ChannelKeys. * Funding redeemscript is script locking funding_outpoint. This is the mutlsig script * between your own funding key and your counterparty's. Currently, this is provided in - * ChannelKeys::sign_local_commitment() calls directly. + * ChannelKeys::sign_holder_commitment() calls directly. * Channel value is amount locked in funding_outpoint. */ -MUST_USE_RES LDKSignature LocalCommitmentTransaction_get_local_sig(const LDKLocalCommitmentTransaction *this_arg, const uint8_t (*funding_key)[32], LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES LDKSignature HolderCommitmentTransaction_get_holder_sig(const LDKHolderCommitmentTransaction *this_arg, const uint8_t (*funding_key)[32], LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** * Get a signature for each HTLC which was included in the commitment transaction (ie for @@ -6252,11 +6556,11 @@ MUST_USE_RES LDKSignature LocalCommitmentTransaction_get_local_sig(const LDKLoca * considered dust and not included, a None entry exists, for all others a signature is * included. */ -MUST_USE_RES LDKCResult_CVec_SignatureZNoneZ LocalCommitmentTransaction_get_htlc_sigs(const LDKLocalCommitmentTransaction *this_arg, const uint8_t (*htlc_base_key)[32], uint16_t local_csv); +MUST_USE_RES LDKCResult_CVec_SignatureZNoneZ HolderCommitmentTransaction_get_htlc_sigs(const LDKHolderCommitmentTransaction *this_arg, const uint8_t (*htlc_base_key)[32], uint16_t counterparty_selected_contest_delay); -LDKCVec_u8Z LocalCommitmentTransaction_write(const LDKLocalCommitmentTransaction *obj); +LDKCVec_u8Z HolderCommitmentTransaction_write(const LDKHolderCommitmentTransaction *obj); -LDKLocalCommitmentTransaction LocalCommitmentTransaction_read(LDKu8slice ser); +LDKHolderCommitmentTransaction HolderCommitmentTransaction_read(LDKu8slice ser); void InitFeatures_free(LDKInitFeatures this_ptr); diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index d494cd40c2a..d14cd5cc40e 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -920,6 +920,76 @@ class ChannelUpdate { const LDKChannelUpdate* operator &() const { return &self; } const LDKChannelUpdate* operator ->() const { return &self; } }; +class QueryChannelRange { +private: + LDKQueryChannelRange self; +public: + QueryChannelRange(const QueryChannelRange&) = delete; + ~QueryChannelRange() { QueryChannelRange_free(self); } + QueryChannelRange(QueryChannelRange&& o) : self(o.self) { memset(&o, 0, sizeof(QueryChannelRange)); } + QueryChannelRange(LDKQueryChannelRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQueryChannelRange)); } + operator LDKQueryChannelRange() { LDKQueryChannelRange res = self; memset(&self, 0, sizeof(LDKQueryChannelRange)); return res; } + LDKQueryChannelRange* operator &() { return &self; } + LDKQueryChannelRange* operator ->() { return &self; } + const LDKQueryChannelRange* operator &() const { return &self; } + const LDKQueryChannelRange* operator ->() const { return &self; } +}; +class ReplyChannelRange { +private: + LDKReplyChannelRange self; +public: + ReplyChannelRange(const ReplyChannelRange&) = delete; + ~ReplyChannelRange() { ReplyChannelRange_free(self); } + ReplyChannelRange(ReplyChannelRange&& o) : self(o.self) { memset(&o, 0, sizeof(ReplyChannelRange)); } + ReplyChannelRange(LDKReplyChannelRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplyChannelRange)); } + operator LDKReplyChannelRange() { LDKReplyChannelRange res = self; memset(&self, 0, sizeof(LDKReplyChannelRange)); return res; } + LDKReplyChannelRange* operator &() { return &self; } + LDKReplyChannelRange* operator ->() { return &self; } + const LDKReplyChannelRange* operator &() const { return &self; } + const LDKReplyChannelRange* operator ->() const { return &self; } +}; +class QueryShortChannelIds { +private: + LDKQueryShortChannelIds self; +public: + QueryShortChannelIds(const QueryShortChannelIds&) = delete; + ~QueryShortChannelIds() { QueryShortChannelIds_free(self); } + QueryShortChannelIds(QueryShortChannelIds&& o) : self(o.self) { memset(&o, 0, sizeof(QueryShortChannelIds)); } + QueryShortChannelIds(LDKQueryShortChannelIds&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQueryShortChannelIds)); } + operator LDKQueryShortChannelIds() { LDKQueryShortChannelIds res = self; memset(&self, 0, sizeof(LDKQueryShortChannelIds)); return res; } + LDKQueryShortChannelIds* operator &() { return &self; } + LDKQueryShortChannelIds* operator ->() { return &self; } + const LDKQueryShortChannelIds* operator &() const { return &self; } + const LDKQueryShortChannelIds* operator ->() const { return &self; } +}; +class ReplyShortChannelIdsEnd { +private: + LDKReplyShortChannelIdsEnd self; +public: + ReplyShortChannelIdsEnd(const ReplyShortChannelIdsEnd&) = delete; + ~ReplyShortChannelIdsEnd() { ReplyShortChannelIdsEnd_free(self); } + ReplyShortChannelIdsEnd(ReplyShortChannelIdsEnd&& o) : self(o.self) { memset(&o, 0, sizeof(ReplyShortChannelIdsEnd)); } + ReplyShortChannelIdsEnd(LDKReplyShortChannelIdsEnd&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplyShortChannelIdsEnd)); } + operator LDKReplyShortChannelIdsEnd() { LDKReplyShortChannelIdsEnd res = self; memset(&self, 0, sizeof(LDKReplyShortChannelIdsEnd)); return res; } + LDKReplyShortChannelIdsEnd* operator &() { return &self; } + LDKReplyShortChannelIdsEnd* operator ->() { return &self; } + const LDKReplyShortChannelIdsEnd* operator &() const { return &self; } + const LDKReplyShortChannelIdsEnd* operator ->() const { return &self; } +}; +class GossipTimestampFilter { +private: + LDKGossipTimestampFilter self; +public: + GossipTimestampFilter(const GossipTimestampFilter&) = delete; + ~GossipTimestampFilter() { GossipTimestampFilter_free(self); } + GossipTimestampFilter(GossipTimestampFilter&& o) : self(o.self) { memset(&o, 0, sizeof(GossipTimestampFilter)); } + GossipTimestampFilter(LDKGossipTimestampFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGossipTimestampFilter)); } + operator LDKGossipTimestampFilter() { LDKGossipTimestampFilter res = self; memset(&self, 0, sizeof(LDKGossipTimestampFilter)); return res; } + LDKGossipTimestampFilter* operator &() { return &self; } + LDKGossipTimestampFilter* operator ->() { return &self; } + const LDKGossipTimestampFilter* operator &() const { return &self; } + const LDKGossipTimestampFilter* operator ->() const { return &self; } +}; class ErrorAction { private: LDKErrorAction self; @@ -1116,19 +1186,19 @@ class HTLCOutputInCommitment { const LDKHTLCOutputInCommitment* operator &() const { return &self; } const LDKHTLCOutputInCommitment* operator ->() const { return &self; } }; -class LocalCommitmentTransaction { +class HolderCommitmentTransaction { private: - LDKLocalCommitmentTransaction self; + LDKHolderCommitmentTransaction self; public: - LocalCommitmentTransaction(const LocalCommitmentTransaction&) = delete; - ~LocalCommitmentTransaction() { LocalCommitmentTransaction_free(self); } - LocalCommitmentTransaction(LocalCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(LocalCommitmentTransaction)); } - LocalCommitmentTransaction(LDKLocalCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLocalCommitmentTransaction)); } - operator LDKLocalCommitmentTransaction() { LDKLocalCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKLocalCommitmentTransaction)); return res; } - LDKLocalCommitmentTransaction* operator &() { return &self; } - LDKLocalCommitmentTransaction* operator ->() { return &self; } - const LDKLocalCommitmentTransaction* operator &() const { return &self; } - const LDKLocalCommitmentTransaction* operator ->() const { return &self; } + HolderCommitmentTransaction(const HolderCommitmentTransaction&) = delete; + ~HolderCommitmentTransaction() { HolderCommitmentTransaction_free(self); } + HolderCommitmentTransaction(HolderCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(HolderCommitmentTransaction)); } + HolderCommitmentTransaction(LDKHolderCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHolderCommitmentTransaction)); } + operator LDKHolderCommitmentTransaction() { LDKHolderCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKHolderCommitmentTransaction)); return res; } + LDKHolderCommitmentTransaction* operator &() { return &self; } + LDKHolderCommitmentTransaction* operator ->() { return &self; } + const LDKHolderCommitmentTransaction* operator &() const { return &self; } + const LDKHolderCommitmentTransaction* operator ->() const { return &self; } }; class InitFeatures { private: @@ -1326,61 +1396,33 @@ class NodeInfo { const LDKNodeInfo* operator &() const { return &self; } const LDKNodeInfo* operator ->() const { return &self; } }; -class CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ { -private: - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ self; -public: - CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(const CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&) = delete; - ~CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(self); } - CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); } - CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); } - operator LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); return res; } - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() { return &self; } - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() const { return &self; } -}; -class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { -private: - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self; -public: - CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete; - ~CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); } - CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); } - CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); } - operator LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; } - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; } - LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; } - const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; } - const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; } -}; -class CVec_CVec_RouteHopZZ { +class CResult_PublicKeySecpErrorZ { private: - LDKCVec_CVec_RouteHopZZ self; + LDKCResult_PublicKeySecpErrorZ self; public: - CVec_CVec_RouteHopZZ(const CVec_CVec_RouteHopZZ&) = delete; - ~CVec_CVec_RouteHopZZ() { CVec_CVec_RouteHopZZ_free(self); } - CVec_CVec_RouteHopZZ(CVec_CVec_RouteHopZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); } - CVec_CVec_RouteHopZZ(LDKCVec_CVec_RouteHopZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); } - operator LDKCVec_CVec_RouteHopZZ() { LDKCVec_CVec_RouteHopZZ res = self; memset(&self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); return res; } - LDKCVec_CVec_RouteHopZZ* operator &() { return &self; } - LDKCVec_CVec_RouteHopZZ* operator ->() { return &self; } - const LDKCVec_CVec_RouteHopZZ* operator &() const { return &self; } - const LDKCVec_CVec_RouteHopZZ* operator ->() const { return &self; } + CResult_PublicKeySecpErrorZ(const CResult_PublicKeySecpErrorZ&) = delete; + ~CResult_PublicKeySecpErrorZ() { CResult_PublicKeySecpErrorZ_free(self); } + CResult_PublicKeySecpErrorZ(CResult_PublicKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PublicKeySecpErrorZ)); } + CResult_PublicKeySecpErrorZ(LDKCResult_PublicKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); } + operator LDKCResult_PublicKeySecpErrorZ() { LDKCResult_PublicKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); return res; } + LDKCResult_PublicKeySecpErrorZ* operator &() { return &self; } + LDKCResult_PublicKeySecpErrorZ* operator ->() { return &self; } + const LDKCResult_PublicKeySecpErrorZ* operator &() const { return &self; } + const LDKCResult_PublicKeySecpErrorZ* operator ->() const { return &self; } }; -class CVec_HTLCOutputInCommitmentZ { +class CVec_u8Z { private: - LDKCVec_HTLCOutputInCommitmentZ self; + LDKCVec_u8Z self; public: - CVec_HTLCOutputInCommitmentZ(const CVec_HTLCOutputInCommitmentZ&) = delete; - ~CVec_HTLCOutputInCommitmentZ() { CVec_HTLCOutputInCommitmentZ_free(self); } - CVec_HTLCOutputInCommitmentZ(CVec_HTLCOutputInCommitmentZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); } - CVec_HTLCOutputInCommitmentZ(LDKCVec_HTLCOutputInCommitmentZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); } - operator LDKCVec_HTLCOutputInCommitmentZ() { LDKCVec_HTLCOutputInCommitmentZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); return res; } - LDKCVec_HTLCOutputInCommitmentZ* operator &() { return &self; } - LDKCVec_HTLCOutputInCommitmentZ* operator ->() { return &self; } - const LDKCVec_HTLCOutputInCommitmentZ* operator &() const { return &self; } - const LDKCVec_HTLCOutputInCommitmentZ* operator ->() const { return &self; } + CVec_u8Z(const CVec_u8Z&) = delete; + ~CVec_u8Z() { CVec_u8Z_free(self); } + CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); } + CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } + operator LDKCVec_u8Z() { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } + LDKCVec_u8Z* operator &() { return &self; } + LDKCVec_u8Z* operator ->() { return &self; } + const LDKCVec_u8Z* operator &() const { return &self; } + const LDKCVec_u8Z* operator ->() const { return &self; } }; class CResult_NoneMonitorUpdateErrorZ { private: @@ -1396,89 +1438,75 @@ class CResult_NoneMonitorUpdateErrorZ { const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; } const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; } }; -class C2Tuple_Txidu32Z { -private: - LDKC2Tuple_Txidu32Z self; -public: - C2Tuple_Txidu32Z(const C2Tuple_Txidu32Z&) = delete; - ~C2Tuple_Txidu32Z() { C2Tuple_Txidu32Z_free(self); } - C2Tuple_Txidu32Z(C2Tuple_Txidu32Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Txidu32Z)); } - C2Tuple_Txidu32Z(LDKC2Tuple_Txidu32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Txidu32Z)); } - operator LDKC2Tuple_Txidu32Z() { LDKC2Tuple_Txidu32Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Txidu32Z)); return res; } - LDKC2Tuple_Txidu32Z* operator &() { return &self; } - LDKC2Tuple_Txidu32Z* operator ->() { return &self; } - const LDKC2Tuple_Txidu32Z* operator &() const { return &self; } - const LDKC2Tuple_Txidu32Z* operator ->() const { return &self; } -}; -class CResult_SignatureNoneZ { +class C2Tuple_OutPointScriptZ { private: - LDKCResult_SignatureNoneZ self; + LDKC2Tuple_OutPointScriptZ self; public: - CResult_SignatureNoneZ(const CResult_SignatureNoneZ&) = delete; - ~CResult_SignatureNoneZ() { CResult_SignatureNoneZ_free(self); } - CResult_SignatureNoneZ(CResult_SignatureNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignatureNoneZ)); } - CResult_SignatureNoneZ(LDKCResult_SignatureNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignatureNoneZ)); } - operator LDKCResult_SignatureNoneZ() { LDKCResult_SignatureNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_SignatureNoneZ)); return res; } - LDKCResult_SignatureNoneZ* operator &() { return &self; } - LDKCResult_SignatureNoneZ* operator ->() { return &self; } - const LDKCResult_SignatureNoneZ* operator &() const { return &self; } - const LDKCResult_SignatureNoneZ* operator ->() const { return &self; } + C2Tuple_OutPointScriptZ(const C2Tuple_OutPointScriptZ&) = delete; + ~C2Tuple_OutPointScriptZ() { C2Tuple_OutPointScriptZ_free(self); } + C2Tuple_OutPointScriptZ(C2Tuple_OutPointScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointScriptZ)); } + C2Tuple_OutPointScriptZ(LDKC2Tuple_OutPointScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); } + operator LDKC2Tuple_OutPointScriptZ() { LDKC2Tuple_OutPointScriptZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); return res; } + LDKC2Tuple_OutPointScriptZ* operator &() { return &self; } + LDKC2Tuple_OutPointScriptZ* operator ->() { return &self; } + const LDKC2Tuple_OutPointScriptZ* operator &() const { return &self; } + const LDKC2Tuple_OutPointScriptZ* operator ->() const { return &self; } }; -class CVec_UpdateFailMalformedHTLCZ { +class CVec_u64Z { private: - LDKCVec_UpdateFailMalformedHTLCZ self; + LDKCVec_u64Z self; public: - CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete; - ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); } - CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); } - CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); } - operator LDKCVec_UpdateFailMalformedHTLCZ() { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; } - LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; } - LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; } - const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; } - const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; } + CVec_u64Z(const CVec_u64Z&) = delete; + ~CVec_u64Z() { CVec_u64Z_free(self); } + CVec_u64Z(CVec_u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u64Z)); } + CVec_u64Z(LDKCVec_u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u64Z)); } + operator LDKCVec_u64Z() { LDKCVec_u64Z res = self; memset(&self, 0, sizeof(LDKCVec_u64Z)); return res; } + LDKCVec_u64Z* operator &() { return &self; } + LDKCVec_u64Z* operator ->() { return &self; } + const LDKCVec_u64Z* operator &() const { return &self; } + const LDKCVec_u64Z* operator ->() const { return &self; } }; -class CResult_NoneAPIErrorZ { +class CVec_CVec_RouteHopZZ { private: - LDKCResult_NoneAPIErrorZ self; + LDKCVec_CVec_RouteHopZZ self; public: - CResult_NoneAPIErrorZ(const CResult_NoneAPIErrorZ&) = delete; - ~CResult_NoneAPIErrorZ() { CResult_NoneAPIErrorZ_free(self); } - CResult_NoneAPIErrorZ(CResult_NoneAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneAPIErrorZ)); } - CResult_NoneAPIErrorZ(LDKCResult_NoneAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); } - operator LDKCResult_NoneAPIErrorZ() { LDKCResult_NoneAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); return res; } - LDKCResult_NoneAPIErrorZ* operator &() { return &self; } - LDKCResult_NoneAPIErrorZ* operator ->() { return &self; } - const LDKCResult_NoneAPIErrorZ* operator &() const { return &self; } - const LDKCResult_NoneAPIErrorZ* operator ->() const { return &self; } + CVec_CVec_RouteHopZZ(const CVec_CVec_RouteHopZZ&) = delete; + ~CVec_CVec_RouteHopZZ() { CVec_CVec_RouteHopZZ_free(self); } + CVec_CVec_RouteHopZZ(CVec_CVec_RouteHopZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); } + CVec_CVec_RouteHopZZ(LDKCVec_CVec_RouteHopZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); } + operator LDKCVec_CVec_RouteHopZZ() { LDKCVec_CVec_RouteHopZZ res = self; memset(&self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); return res; } + LDKCVec_CVec_RouteHopZZ* operator &() { return &self; } + LDKCVec_CVec_RouteHopZZ* operator ->() { return &self; } + const LDKCVec_CVec_RouteHopZZ* operator &() const { return &self; } + const LDKCVec_CVec_RouteHopZZ* operator ->() const { return &self; } }; -class CVec_SpendableOutputDescriptorZ { +class CVec_TransactionZ { private: - LDKCVec_SpendableOutputDescriptorZ self; + LDKCVec_TransactionZ self; public: - CVec_SpendableOutputDescriptorZ(const CVec_SpendableOutputDescriptorZ&) = delete; - ~CVec_SpendableOutputDescriptorZ() { CVec_SpendableOutputDescriptorZ_free(self); } - CVec_SpendableOutputDescriptorZ(CVec_SpendableOutputDescriptorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SpendableOutputDescriptorZ)); } - CVec_SpendableOutputDescriptorZ(LDKCVec_SpendableOutputDescriptorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); } - operator LDKCVec_SpendableOutputDescriptorZ() { LDKCVec_SpendableOutputDescriptorZ res = self; memset(&self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); return res; } - LDKCVec_SpendableOutputDescriptorZ* operator &() { return &self; } - LDKCVec_SpendableOutputDescriptorZ* operator ->() { return &self; } - const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; } - const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; } + CVec_TransactionZ(const CVec_TransactionZ&) = delete; + ~CVec_TransactionZ() { CVec_TransactionZ_free(self); } + CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); } + CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); } + operator LDKCVec_TransactionZ() { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; } + LDKCVec_TransactionZ* operator &() { return &self; } + LDKCVec_TransactionZ* operator ->() { return &self; } + const LDKCVec_TransactionZ* operator &() const { return &self; } + const LDKCVec_TransactionZ* operator ->() const { return &self; } }; -class C2Tuple_SignatureCVec_SignatureZZ { +class CResult_C2Tuple_Scriptu64ZChainErrorZ { private: - LDKC2Tuple_SignatureCVec_SignatureZZ self; + LDKCResult_C2Tuple_Scriptu64ZChainErrorZ self; public: - C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete; - ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); } - C2Tuple_SignatureCVec_SignatureZZ(C2Tuple_SignatureCVec_SignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); } - C2Tuple_SignatureCVec_SignatureZZ(LDKC2Tuple_SignatureCVec_SignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); } - operator LDKC2Tuple_SignatureCVec_SignatureZZ() { LDKC2Tuple_SignatureCVec_SignatureZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); return res; } - LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() { return &self; } - LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() { return &self; } - const LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() const { return &self; } - const LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() const { return &self; } + CResult_C2Tuple_Scriptu64ZChainErrorZ(const CResult_C2Tuple_Scriptu64ZChainErrorZ&) = delete; + ~CResult_C2Tuple_Scriptu64ZChainErrorZ() { CResult_C2Tuple_Scriptu64ZChainErrorZ_free(self); } + CResult_C2Tuple_Scriptu64ZChainErrorZ(CResult_C2Tuple_Scriptu64ZChainErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_Scriptu64ZChainErrorZ)); } + CResult_C2Tuple_Scriptu64ZChainErrorZ(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); } + operator LDKCResult_C2Tuple_Scriptu64ZChainErrorZ() { LDKCResult_C2Tuple_Scriptu64ZChainErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); return res; } + LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() { return &self; } + LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() const { return &self; } }; class CResult_CVec_SignatureZNoneZ { private: @@ -1494,159 +1522,159 @@ class CResult_CVec_SignatureZNoneZ { const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; } }; -class CResult_CVec_u8ZPeerHandleErrorZ { +class CVec_NodeAnnouncementZ { private: - LDKCResult_CVec_u8ZPeerHandleErrorZ self; + LDKCVec_NodeAnnouncementZ self; public: - CResult_CVec_u8ZPeerHandleErrorZ(const CResult_CVec_u8ZPeerHandleErrorZ&) = delete; - ~CResult_CVec_u8ZPeerHandleErrorZ() { CResult_CVec_u8ZPeerHandleErrorZ_free(self); } - CResult_CVec_u8ZPeerHandleErrorZ(CResult_CVec_u8ZPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_u8ZPeerHandleErrorZ)); } - CResult_CVec_u8ZPeerHandleErrorZ(LDKCResult_CVec_u8ZPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); } - operator LDKCResult_CVec_u8ZPeerHandleErrorZ() { LDKCResult_CVec_u8ZPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); return res; } - LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() { return &self; } - LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() { return &self; } - const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; } - const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; } + CVec_NodeAnnouncementZ(const CVec_NodeAnnouncementZ&) = delete; + ~CVec_NodeAnnouncementZ() { CVec_NodeAnnouncementZ_free(self); } + CVec_NodeAnnouncementZ(CVec_NodeAnnouncementZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NodeAnnouncementZ)); } + CVec_NodeAnnouncementZ(LDKCVec_NodeAnnouncementZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); } + operator LDKCVec_NodeAnnouncementZ() { LDKCVec_NodeAnnouncementZ res = self; memset(&self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); return res; } + LDKCVec_NodeAnnouncementZ* operator &() { return &self; } + LDKCVec_NodeAnnouncementZ* operator ->() { return &self; } + const LDKCVec_NodeAnnouncementZ* operator &() const { return &self; } + const LDKCVec_NodeAnnouncementZ* operator ->() const { return &self; } }; -class CResult_TxCreationKeysSecpErrorZ { +class CResult_RouteLightningErrorZ { private: - LDKCResult_TxCreationKeysSecpErrorZ self; + LDKCResult_RouteLightningErrorZ self; public: - CResult_TxCreationKeysSecpErrorZ(const CResult_TxCreationKeysSecpErrorZ&) = delete; - ~CResult_TxCreationKeysSecpErrorZ() { CResult_TxCreationKeysSecpErrorZ_free(self); } - CResult_TxCreationKeysSecpErrorZ(CResult_TxCreationKeysSecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysSecpErrorZ)); } - CResult_TxCreationKeysSecpErrorZ(LDKCResult_TxCreationKeysSecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysSecpErrorZ)); } - operator LDKCResult_TxCreationKeysSecpErrorZ() { LDKCResult_TxCreationKeysSecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysSecpErrorZ)); return res; } - LDKCResult_TxCreationKeysSecpErrorZ* operator &() { return &self; } - LDKCResult_TxCreationKeysSecpErrorZ* operator ->() { return &self; } - const LDKCResult_TxCreationKeysSecpErrorZ* operator &() const { return &self; } - const LDKCResult_TxCreationKeysSecpErrorZ* operator ->() const { return &self; } + CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; + ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } + CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); } + CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); } + operator LDKCResult_RouteLightningErrorZ() { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; } + LDKCResult_RouteLightningErrorZ* operator &() { return &self; } + LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } + const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } + const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } }; -class CVec_RouteHopZ { +class CResult_boolPeerHandleErrorZ { private: - LDKCVec_RouteHopZ self; + LDKCResult_boolPeerHandleErrorZ self; public: - CVec_RouteHopZ(const CVec_RouteHopZ&) = delete; - ~CVec_RouteHopZ() { CVec_RouteHopZ_free(self); } - CVec_RouteHopZ(CVec_RouteHopZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHopZ)); } - CVec_RouteHopZ(LDKCVec_RouteHopZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHopZ)); } - operator LDKCVec_RouteHopZ() { LDKCVec_RouteHopZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHopZ)); return res; } - LDKCVec_RouteHopZ* operator &() { return &self; } - LDKCVec_RouteHopZ* operator ->() { return &self; } - const LDKCVec_RouteHopZ* operator &() const { return &self; } - const LDKCVec_RouteHopZ* operator ->() const { return &self; } -}; -class CVec_RouteHintZ { + CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete; + ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); } + CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); } + CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); } + operator LDKCResult_boolPeerHandleErrorZ() { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; } + LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; } + LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; } + const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } + const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } +}; +class C2Tuple_SignatureCVec_SignatureZZ { private: - LDKCVec_RouteHintZ self; + LDKC2Tuple_SignatureCVec_SignatureZZ self; public: - CVec_RouteHintZ(const CVec_RouteHintZ&) = delete; - ~CVec_RouteHintZ() { CVec_RouteHintZ_free(self); } - CVec_RouteHintZ(CVec_RouteHintZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHintZ)); } - CVec_RouteHintZ(LDKCVec_RouteHintZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHintZ)); } - operator LDKCVec_RouteHintZ() { LDKCVec_RouteHintZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHintZ)); return res; } - LDKCVec_RouteHintZ* operator &() { return &self; } - LDKCVec_RouteHintZ* operator ->() { return &self; } - const LDKCVec_RouteHintZ* operator &() const { return &self; } - const LDKCVec_RouteHintZ* operator ->() const { return &self; } + C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete; + ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); } + C2Tuple_SignatureCVec_SignatureZZ(C2Tuple_SignatureCVec_SignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); } + C2Tuple_SignatureCVec_SignatureZZ(LDKC2Tuple_SignatureCVec_SignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); } + operator LDKC2Tuple_SignatureCVec_SignatureZZ() { LDKC2Tuple_SignatureCVec_SignatureZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); return res; } + LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() { return &self; } + LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() { return &self; } + const LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() const { return &self; } + const LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() const { return &self; } }; -class CResult_RouteLightningErrorZ { +class CVec_HTLCOutputInCommitmentZ { private: - LDKCResult_RouteLightningErrorZ self; + LDKCVec_HTLCOutputInCommitmentZ self; public: - CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; - ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } - CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); } - CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); } - operator LDKCResult_RouteLightningErrorZ() { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; } - LDKCResult_RouteLightningErrorZ* operator &() { return &self; } - LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } - const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } - const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } + CVec_HTLCOutputInCommitmentZ(const CVec_HTLCOutputInCommitmentZ&) = delete; + ~CVec_HTLCOutputInCommitmentZ() { CVec_HTLCOutputInCommitmentZ_free(self); } + CVec_HTLCOutputInCommitmentZ(CVec_HTLCOutputInCommitmentZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); } + CVec_HTLCOutputInCommitmentZ(LDKCVec_HTLCOutputInCommitmentZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); } + operator LDKCVec_HTLCOutputInCommitmentZ() { LDKCVec_HTLCOutputInCommitmentZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); return res; } + LDKCVec_HTLCOutputInCommitmentZ* operator &() { return &self; } + LDKCVec_HTLCOutputInCommitmentZ* operator ->() { return &self; } + const LDKCVec_HTLCOutputInCommitmentZ* operator &() const { return &self; } + const LDKCVec_HTLCOutputInCommitmentZ* operator ->() const { return &self; } }; -class C2Tuple_u64u64Z { +class C2Tuple_Scriptu64Z { private: - LDKC2Tuple_u64u64Z self; + LDKC2Tuple_Scriptu64Z self; public: - C2Tuple_u64u64Z(const C2Tuple_u64u64Z&) = delete; - ~C2Tuple_u64u64Z() { C2Tuple_u64u64Z_free(self); } - C2Tuple_u64u64Z(C2Tuple_u64u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_u64u64Z)); } - C2Tuple_u64u64Z(LDKC2Tuple_u64u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_u64u64Z)); } - operator LDKC2Tuple_u64u64Z() { LDKC2Tuple_u64u64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_u64u64Z)); return res; } - LDKC2Tuple_u64u64Z* operator &() { return &self; } - LDKC2Tuple_u64u64Z* operator ->() { return &self; } - const LDKC2Tuple_u64u64Z* operator &() const { return &self; } - const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } + C2Tuple_Scriptu64Z(const C2Tuple_Scriptu64Z&) = delete; + ~C2Tuple_Scriptu64Z() { C2Tuple_Scriptu64Z_free(self); } + C2Tuple_Scriptu64Z(C2Tuple_Scriptu64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Scriptu64Z)); } + C2Tuple_Scriptu64Z(LDKC2Tuple_Scriptu64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); } + operator LDKC2Tuple_Scriptu64Z() { LDKC2Tuple_Scriptu64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); return res; } + LDKC2Tuple_Scriptu64Z* operator &() { return &self; } + LDKC2Tuple_Scriptu64Z* operator ->() { return &self; } + const LDKC2Tuple_Scriptu64Z* operator &() const { return &self; } + const LDKC2Tuple_Scriptu64Z* operator ->() const { return &self; } }; -class CVec_MessageSendEventZ { +class CVec_ChannelMonitorZ { private: - LDKCVec_MessageSendEventZ self; + LDKCVec_ChannelMonitorZ self; public: - CVec_MessageSendEventZ(const CVec_MessageSendEventZ&) = delete; - ~CVec_MessageSendEventZ() { CVec_MessageSendEventZ_free(self); } - CVec_MessageSendEventZ(CVec_MessageSendEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageSendEventZ)); } - CVec_MessageSendEventZ(LDKCVec_MessageSendEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageSendEventZ)); } - operator LDKCVec_MessageSendEventZ() { LDKCVec_MessageSendEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageSendEventZ)); return res; } - LDKCVec_MessageSendEventZ* operator &() { return &self; } - LDKCVec_MessageSendEventZ* operator ->() { return &self; } - const LDKCVec_MessageSendEventZ* operator &() const { return &self; } - const LDKCVec_MessageSendEventZ* operator ->() const { return &self; } + CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; + ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); } + CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); } + CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); } + operator LDKCVec_ChannelMonitorZ() { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; } + LDKCVec_ChannelMonitorZ* operator &() { return &self; } + LDKCVec_ChannelMonitorZ* operator ->() { return &self; } + const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } + const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } }; -class C2Tuple_HTLCOutputInCommitmentSignatureZ { +class C2Tuple_Txidu32Z { private: - LDKC2Tuple_HTLCOutputInCommitmentSignatureZ self; + LDKC2Tuple_Txidu32Z self; public: - C2Tuple_HTLCOutputInCommitmentSignatureZ(const C2Tuple_HTLCOutputInCommitmentSignatureZ&) = delete; - ~C2Tuple_HTLCOutputInCommitmentSignatureZ() { C2Tuple_HTLCOutputInCommitmentSignatureZ_free(self); } - C2Tuple_HTLCOutputInCommitmentSignatureZ(C2Tuple_HTLCOutputInCommitmentSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_HTLCOutputInCommitmentSignatureZ)); } - C2Tuple_HTLCOutputInCommitmentSignatureZ(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); } - operator LDKC2Tuple_HTLCOutputInCommitmentSignatureZ() { LDKC2Tuple_HTLCOutputInCommitmentSignatureZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); return res; } - LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() { return &self; } - LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() { return &self; } - const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() const { return &self; } - const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() const { return &self; } + C2Tuple_Txidu32Z(const C2Tuple_Txidu32Z&) = delete; + ~C2Tuple_Txidu32Z() { C2Tuple_Txidu32Z_free(self); } + C2Tuple_Txidu32Z(C2Tuple_Txidu32Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Txidu32Z)); } + C2Tuple_Txidu32Z(LDKC2Tuple_Txidu32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Txidu32Z)); } + operator LDKC2Tuple_Txidu32Z() { LDKC2Tuple_Txidu32Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Txidu32Z)); return res; } + LDKC2Tuple_Txidu32Z* operator &() { return &self; } + LDKC2Tuple_Txidu32Z* operator ->() { return &self; } + const LDKC2Tuple_Txidu32Z* operator &() const { return &self; } + const LDKC2Tuple_Txidu32Z* operator ->() const { return &self; } }; -class CVec_SignatureZ { +class CVec_ChannelDetailsZ { private: - LDKCVec_SignatureZ self; + LDKCVec_ChannelDetailsZ self; public: - CVec_SignatureZ(const CVec_SignatureZ&) = delete; - ~CVec_SignatureZ() { CVec_SignatureZ_free(self); } - CVec_SignatureZ(CVec_SignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SignatureZ)); } - CVec_SignatureZ(LDKCVec_SignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SignatureZ)); } - operator LDKCVec_SignatureZ() { LDKCVec_SignatureZ res = self; memset(&self, 0, sizeof(LDKCVec_SignatureZ)); return res; } - LDKCVec_SignatureZ* operator &() { return &self; } - LDKCVec_SignatureZ* operator ->() { return &self; } - const LDKCVec_SignatureZ* operator &() const { return &self; } - const LDKCVec_SignatureZ* operator ->() const { return &self; } + CVec_ChannelDetailsZ(const CVec_ChannelDetailsZ&) = delete; + ~CVec_ChannelDetailsZ() { CVec_ChannelDetailsZ_free(self); } + CVec_ChannelDetailsZ(CVec_ChannelDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelDetailsZ)); } + CVec_ChannelDetailsZ(LDKCVec_ChannelDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelDetailsZ)); } + operator LDKCVec_ChannelDetailsZ() { LDKCVec_ChannelDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelDetailsZ)); return res; } + LDKCVec_ChannelDetailsZ* operator &() { return &self; } + LDKCVec_ChannelDetailsZ* operator ->() { return &self; } + const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } + const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } }; -class CVec_usizeZ { +class C2Tuple_u64u64Z { private: - LDKCVec_usizeZ self; + LDKC2Tuple_u64u64Z self; public: - CVec_usizeZ(const CVec_usizeZ&) = delete; - ~CVec_usizeZ() { CVec_usizeZ_free(self); } - CVec_usizeZ(CVec_usizeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_usizeZ)); } - CVec_usizeZ(LDKCVec_usizeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_usizeZ)); } - operator LDKCVec_usizeZ() { LDKCVec_usizeZ res = self; memset(&self, 0, sizeof(LDKCVec_usizeZ)); return res; } - LDKCVec_usizeZ* operator &() { return &self; } - LDKCVec_usizeZ* operator ->() { return &self; } - const LDKCVec_usizeZ* operator &() const { return &self; } - const LDKCVec_usizeZ* operator ->() const { return &self; } + C2Tuple_u64u64Z(const C2Tuple_u64u64Z&) = delete; + ~C2Tuple_u64u64Z() { C2Tuple_u64u64Z_free(self); } + C2Tuple_u64u64Z(C2Tuple_u64u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_u64u64Z)); } + C2Tuple_u64u64Z(LDKC2Tuple_u64u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_u64u64Z)); } + operator LDKC2Tuple_u64u64Z() { LDKC2Tuple_u64u64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_u64u64Z)); return res; } + LDKC2Tuple_u64u64Z* operator &() { return &self; } + LDKC2Tuple_u64u64Z* operator ->() { return &self; } + const LDKC2Tuple_u64u64Z* operator &() const { return &self; } + const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } }; -class C2Tuple_Scriptu64Z { +class CResult_NonePaymentSendFailureZ { private: - LDKC2Tuple_Scriptu64Z self; + LDKCResult_NonePaymentSendFailureZ self; public: - C2Tuple_Scriptu64Z(const C2Tuple_Scriptu64Z&) = delete; - ~C2Tuple_Scriptu64Z() { C2Tuple_Scriptu64Z_free(self); } - C2Tuple_Scriptu64Z(C2Tuple_Scriptu64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Scriptu64Z)); } - C2Tuple_Scriptu64Z(LDKC2Tuple_Scriptu64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); } - operator LDKC2Tuple_Scriptu64Z() { LDKC2Tuple_Scriptu64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); return res; } - LDKC2Tuple_Scriptu64Z* operator &() { return &self; } - LDKC2Tuple_Scriptu64Z* operator ->() { return &self; } - const LDKC2Tuple_Scriptu64Z* operator &() const { return &self; } - const LDKC2Tuple_Scriptu64Z* operator ->() const { return &self; } + CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete; + ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); } + CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); } + CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); } + operator LDKCResult_NonePaymentSendFailureZ() { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; } + LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; } + LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; } + const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; } + const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; } }; class CResult_NoneChannelMonitorUpdateErrZ { private: @@ -1662,89 +1690,117 @@ class CResult_NoneChannelMonitorUpdateErrZ { const LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() const { return &self; } const LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() const { return &self; } }; -class CVec_u64Z { +class CVec_MonitorEventZ { private: - LDKCVec_u64Z self; + LDKCVec_MonitorEventZ self; public: - CVec_u64Z(const CVec_u64Z&) = delete; - ~CVec_u64Z() { CVec_u64Z_free(self); } - CVec_u64Z(CVec_u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u64Z)); } - CVec_u64Z(LDKCVec_u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u64Z)); } - operator LDKCVec_u64Z() { LDKCVec_u64Z res = self; memset(&self, 0, sizeof(LDKCVec_u64Z)); return res; } - LDKCVec_u64Z* operator &() { return &self; } - LDKCVec_u64Z* operator ->() { return &self; } - const LDKCVec_u64Z* operator &() const { return &self; } - const LDKCVec_u64Z* operator ->() const { return &self; } + CVec_MonitorEventZ(const CVec_MonitorEventZ&) = delete; + ~CVec_MonitorEventZ() { CVec_MonitorEventZ_free(self); } + CVec_MonitorEventZ(CVec_MonitorEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MonitorEventZ)); } + CVec_MonitorEventZ(LDKCVec_MonitorEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MonitorEventZ)); } + operator LDKCVec_MonitorEventZ() { LDKCVec_MonitorEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MonitorEventZ)); return res; } + LDKCVec_MonitorEventZ* operator &() { return &self; } + LDKCVec_MonitorEventZ* operator ->() { return &self; } + const LDKCVec_MonitorEventZ* operator &() const { return &self; } + const LDKCVec_MonitorEventZ* operator ->() const { return &self; } }; -class C2Tuple_OutPointScriptZ { +class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { private: - LDKC2Tuple_OutPointScriptZ self; + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self; public: - C2Tuple_OutPointScriptZ(const C2Tuple_OutPointScriptZ&) = delete; - ~C2Tuple_OutPointScriptZ() { C2Tuple_OutPointScriptZ_free(self); } - C2Tuple_OutPointScriptZ(C2Tuple_OutPointScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointScriptZ)); } - C2Tuple_OutPointScriptZ(LDKC2Tuple_OutPointScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); } - operator LDKC2Tuple_OutPointScriptZ() { LDKC2Tuple_OutPointScriptZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); return res; } - LDKC2Tuple_OutPointScriptZ* operator &() { return &self; } - LDKC2Tuple_OutPointScriptZ* operator ->() { return &self; } - const LDKC2Tuple_OutPointScriptZ* operator &() const { return &self; } - const LDKC2Tuple_OutPointScriptZ* operator ->() const { return &self; } + CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete; + ~CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); } + CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); } + CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); } + operator LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; } + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; } + LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; } + const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; } + const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; } }; -class CVec_ChannelMonitorZ { +class C2Tuple_HTLCOutputInCommitmentSignatureZ { private: - LDKCVec_ChannelMonitorZ self; + LDKC2Tuple_HTLCOutputInCommitmentSignatureZ self; public: - CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; - ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); } - CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); } - CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); } - operator LDKCVec_ChannelMonitorZ() { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; } - LDKCVec_ChannelMonitorZ* operator &() { return &self; } - LDKCVec_ChannelMonitorZ* operator ->() { return &self; } - const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } - const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } + C2Tuple_HTLCOutputInCommitmentSignatureZ(const C2Tuple_HTLCOutputInCommitmentSignatureZ&) = delete; + ~C2Tuple_HTLCOutputInCommitmentSignatureZ() { C2Tuple_HTLCOutputInCommitmentSignatureZ_free(self); } + C2Tuple_HTLCOutputInCommitmentSignatureZ(C2Tuple_HTLCOutputInCommitmentSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_HTLCOutputInCommitmentSignatureZ)); } + C2Tuple_HTLCOutputInCommitmentSignatureZ(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); } + operator LDKC2Tuple_HTLCOutputInCommitmentSignatureZ() { LDKC2Tuple_HTLCOutputInCommitmentSignatureZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); return res; } + LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() { return &self; } + LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() { return &self; } + const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() const { return &self; } + const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() const { return &self; } }; -class CVec_UpdateFulfillHTLCZ { +class CResult_SecretKeySecpErrorZ { private: - LDKCVec_UpdateFulfillHTLCZ self; + LDKCResult_SecretKeySecpErrorZ self; public: - CVec_UpdateFulfillHTLCZ(const CVec_UpdateFulfillHTLCZ&) = delete; - ~CVec_UpdateFulfillHTLCZ() { CVec_UpdateFulfillHTLCZ_free(self); } - CVec_UpdateFulfillHTLCZ(CVec_UpdateFulfillHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFulfillHTLCZ)); } - CVec_UpdateFulfillHTLCZ(LDKCVec_UpdateFulfillHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); } - operator LDKCVec_UpdateFulfillHTLCZ() { LDKCVec_UpdateFulfillHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); return res; } - LDKCVec_UpdateFulfillHTLCZ* operator &() { return &self; } - LDKCVec_UpdateFulfillHTLCZ* operator ->() { return &self; } - const LDKCVec_UpdateFulfillHTLCZ* operator &() const { return &self; } - const LDKCVec_UpdateFulfillHTLCZ* operator ->() const { return &self; } + CResult_SecretKeySecpErrorZ(const CResult_SecretKeySecpErrorZ&) = delete; + ~CResult_SecretKeySecpErrorZ() { CResult_SecretKeySecpErrorZ_free(self); } + CResult_SecretKeySecpErrorZ(CResult_SecretKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SecretKeySecpErrorZ)); } + CResult_SecretKeySecpErrorZ(LDKCResult_SecretKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); } + operator LDKCResult_SecretKeySecpErrorZ() { LDKCResult_SecretKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); return res; } + LDKCResult_SecretKeySecpErrorZ* operator &() { return &self; } + LDKCResult_SecretKeySecpErrorZ* operator ->() { return &self; } + const LDKCResult_SecretKeySecpErrorZ* operator &() const { return &self; } + const LDKCResult_SecretKeySecpErrorZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_Scriptu64ZChainErrorZ { +class CVec_RouteHintZ { private: - LDKCResult_C2Tuple_Scriptu64ZChainErrorZ self; + LDKCVec_RouteHintZ self; public: - CResult_C2Tuple_Scriptu64ZChainErrorZ(const CResult_C2Tuple_Scriptu64ZChainErrorZ&) = delete; - ~CResult_C2Tuple_Scriptu64ZChainErrorZ() { CResult_C2Tuple_Scriptu64ZChainErrorZ_free(self); } - CResult_C2Tuple_Scriptu64ZChainErrorZ(CResult_C2Tuple_Scriptu64ZChainErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_Scriptu64ZChainErrorZ)); } - CResult_C2Tuple_Scriptu64ZChainErrorZ(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); } - operator LDKCResult_C2Tuple_Scriptu64ZChainErrorZ() { LDKCResult_C2Tuple_Scriptu64ZChainErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); return res; } - LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() { return &self; } - LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() const { return &self; } + CVec_RouteHintZ(const CVec_RouteHintZ&) = delete; + ~CVec_RouteHintZ() { CVec_RouteHintZ_free(self); } + CVec_RouteHintZ(CVec_RouteHintZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHintZ)); } + CVec_RouteHintZ(LDKCVec_RouteHintZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHintZ)); } + operator LDKCVec_RouteHintZ() { LDKCVec_RouteHintZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHintZ)); return res; } + LDKCVec_RouteHintZ* operator &() { return &self; } + LDKCVec_RouteHintZ* operator ->() { return &self; } + const LDKCVec_RouteHintZ* operator &() const { return &self; } + const LDKCVec_RouteHintZ* operator ->() const { return &self; } }; -class CVec_ChannelDetailsZ { +class CVec_UpdateFailMalformedHTLCZ { private: - LDKCVec_ChannelDetailsZ self; + LDKCVec_UpdateFailMalformedHTLCZ self; public: - CVec_ChannelDetailsZ(const CVec_ChannelDetailsZ&) = delete; - ~CVec_ChannelDetailsZ() { CVec_ChannelDetailsZ_free(self); } - CVec_ChannelDetailsZ(CVec_ChannelDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelDetailsZ)); } - CVec_ChannelDetailsZ(LDKCVec_ChannelDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelDetailsZ)); } - operator LDKCVec_ChannelDetailsZ() { LDKCVec_ChannelDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelDetailsZ)); return res; } - LDKCVec_ChannelDetailsZ* operator &() { return &self; } - LDKCVec_ChannelDetailsZ* operator ->() { return &self; } - const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } - const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } + CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete; + ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); } + CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); } + CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); } + operator LDKCVec_UpdateFailMalformedHTLCZ() { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; } + LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; } + LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; } + const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; } + const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; } +}; +class CVec_RouteHopZ { +private: + LDKCVec_RouteHopZ self; +public: + CVec_RouteHopZ(const CVec_RouteHopZ&) = delete; + ~CVec_RouteHopZ() { CVec_RouteHopZ_free(self); } + CVec_RouteHopZ(CVec_RouteHopZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHopZ)); } + CVec_RouteHopZ(LDKCVec_RouteHopZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHopZ)); } + operator LDKCVec_RouteHopZ() { LDKCVec_RouteHopZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHopZ)); return res; } + LDKCVec_RouteHopZ* operator &() { return &self; } + LDKCVec_RouteHopZ* operator ->() { return &self; } + const LDKCVec_RouteHopZ* operator &() const { return &self; } + const LDKCVec_RouteHopZ* operator ->() const { return &self; } +}; +class CVec_SpendableOutputDescriptorZ { +private: + LDKCVec_SpendableOutputDescriptorZ self; +public: + CVec_SpendableOutputDescriptorZ(const CVec_SpendableOutputDescriptorZ&) = delete; + ~CVec_SpendableOutputDescriptorZ() { CVec_SpendableOutputDescriptorZ_free(self); } + CVec_SpendableOutputDescriptorZ(CVec_SpendableOutputDescriptorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SpendableOutputDescriptorZ)); } + CVec_SpendableOutputDescriptorZ(LDKCVec_SpendableOutputDescriptorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); } + operator LDKCVec_SpendableOutputDescriptorZ() { LDKCVec_SpendableOutputDescriptorZ res = self; memset(&self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); return res; } + LDKCVec_SpendableOutputDescriptorZ* operator &() { return &self; } + LDKCVec_SpendableOutputDescriptorZ* operator ->() { return &self; } + const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; } + const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; } }; class CResult_boolLightningErrorZ { private: @@ -1760,6 +1816,20 @@ class CResult_boolLightningErrorZ { const LDKCResult_boolLightningErrorZ* operator &() const { return &self; } const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; } }; +class CResult_NoneAPIErrorZ { +private: + LDKCResult_NoneAPIErrorZ self; +public: + CResult_NoneAPIErrorZ(const CResult_NoneAPIErrorZ&) = delete; + ~CResult_NoneAPIErrorZ() { CResult_NoneAPIErrorZ_free(self); } + CResult_NoneAPIErrorZ(CResult_NoneAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneAPIErrorZ)); } + CResult_NoneAPIErrorZ(LDKCResult_NoneAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); } + operator LDKCResult_NoneAPIErrorZ() { LDKCResult_NoneAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); return res; } + LDKCResult_NoneAPIErrorZ* operator &() { return &self; } + LDKCResult_NoneAPIErrorZ* operator ->() { return &self; } + const LDKCResult_NoneAPIErrorZ* operator &() const { return &self; } + const LDKCResult_NoneAPIErrorZ* operator ->() const { return &self; } +}; class CVec_NetAddressZ { private: LDKCVec_NetAddressZ self; @@ -1774,75 +1844,61 @@ class CVec_NetAddressZ { const LDKCVec_NetAddressZ* operator &() const { return &self; } const LDKCVec_NetAddressZ* operator ->() const { return &self; } }; -class CVec_UpdateFailHTLCZ { -private: - LDKCVec_UpdateFailHTLCZ self; -public: - CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete; - ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); } - CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); } - CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); } - operator LDKCVec_UpdateFailHTLCZ() { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; } - LDKCVec_UpdateFailHTLCZ* operator &() { return &self; } - LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; } - const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; } - const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; } -}; -class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { +class CResult_CVec_u8ZPeerHandleErrorZ { private: - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ self; + LDKCResult_CVec_u8ZPeerHandleErrorZ self; public: - C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(const C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&) = delete; - ~C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ() { C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(self); } - C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); } - C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); } - operator LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ() { LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); return res; } - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() { return &self; } - LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() { return &self; } - const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; } - const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; } + CResult_CVec_u8ZPeerHandleErrorZ(const CResult_CVec_u8ZPeerHandleErrorZ&) = delete; + ~CResult_CVec_u8ZPeerHandleErrorZ() { CResult_CVec_u8ZPeerHandleErrorZ_free(self); } + CResult_CVec_u8ZPeerHandleErrorZ(CResult_CVec_u8ZPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_u8ZPeerHandleErrorZ)); } + CResult_CVec_u8ZPeerHandleErrorZ(LDKCResult_CVec_u8ZPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); } + operator LDKCResult_CVec_u8ZPeerHandleErrorZ() { LDKCResult_CVec_u8ZPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); return res; } + LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() { return &self; } + LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() { return &self; } + const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; } + const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; } }; -class CVec_MonitorEventZ { +class CVec_usizeZ { private: - LDKCVec_MonitorEventZ self; + LDKCVec_usizeZ self; public: - CVec_MonitorEventZ(const CVec_MonitorEventZ&) = delete; - ~CVec_MonitorEventZ() { CVec_MonitorEventZ_free(self); } - CVec_MonitorEventZ(CVec_MonitorEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MonitorEventZ)); } - CVec_MonitorEventZ(LDKCVec_MonitorEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MonitorEventZ)); } - operator LDKCVec_MonitorEventZ() { LDKCVec_MonitorEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MonitorEventZ)); return res; } - LDKCVec_MonitorEventZ* operator &() { return &self; } - LDKCVec_MonitorEventZ* operator ->() { return &self; } - const LDKCVec_MonitorEventZ* operator &() const { return &self; } - const LDKCVec_MonitorEventZ* operator ->() const { return &self; } + CVec_usizeZ(const CVec_usizeZ&) = delete; + ~CVec_usizeZ() { CVec_usizeZ_free(self); } + CVec_usizeZ(CVec_usizeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_usizeZ)); } + CVec_usizeZ(LDKCVec_usizeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_usizeZ)); } + operator LDKCVec_usizeZ() { LDKCVec_usizeZ res = self; memset(&self, 0, sizeof(LDKCVec_usizeZ)); return res; } + LDKCVec_usizeZ* operator &() { return &self; } + LDKCVec_usizeZ* operator ->() { return &self; } + const LDKCVec_usizeZ* operator &() const { return &self; } + const LDKCVec_usizeZ* operator ->() const { return &self; } }; -class CVec_UpdateAddHTLCZ { +class CResult_NonePeerHandleErrorZ { private: - LDKCVec_UpdateAddHTLCZ self; + LDKCResult_NonePeerHandleErrorZ self; public: - CVec_UpdateAddHTLCZ(const CVec_UpdateAddHTLCZ&) = delete; - ~CVec_UpdateAddHTLCZ() { CVec_UpdateAddHTLCZ_free(self); } - CVec_UpdateAddHTLCZ(CVec_UpdateAddHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateAddHTLCZ)); } - CVec_UpdateAddHTLCZ(LDKCVec_UpdateAddHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateAddHTLCZ)); } - operator LDKCVec_UpdateAddHTLCZ() { LDKCVec_UpdateAddHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateAddHTLCZ)); return res; } - LDKCVec_UpdateAddHTLCZ* operator &() { return &self; } - LDKCVec_UpdateAddHTLCZ* operator ->() { return &self; } - const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; } - const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; } + CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete; + ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); } + CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); } + CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); } + operator LDKCResult_NonePeerHandleErrorZ() { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; } + LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; } + LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; } + const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } + const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +class CResult_TxCreationKeysSecpErrorZ { private: - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self; + LDKCResult_TxCreationKeysSecpErrorZ self; public: - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete; - ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); } - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } - operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; } - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; } - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; } + CResult_TxCreationKeysSecpErrorZ(const CResult_TxCreationKeysSecpErrorZ&) = delete; + ~CResult_TxCreationKeysSecpErrorZ() { CResult_TxCreationKeysSecpErrorZ_free(self); } + CResult_TxCreationKeysSecpErrorZ(CResult_TxCreationKeysSecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysSecpErrorZ)); } + CResult_TxCreationKeysSecpErrorZ(LDKCResult_TxCreationKeysSecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysSecpErrorZ)); } + operator LDKCResult_TxCreationKeysSecpErrorZ() { LDKCResult_TxCreationKeysSecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysSecpErrorZ)); return res; } + LDKCResult_TxCreationKeysSecpErrorZ* operator &() { return &self; } + LDKCResult_TxCreationKeysSecpErrorZ* operator ->() { return &self; } + const LDKCResult_TxCreationKeysSecpErrorZ* operator &() const { return &self; } + const LDKCResult_TxCreationKeysSecpErrorZ* operator ->() const { return &self; } }; class CVec_PublicKeyZ { private: @@ -1858,89 +1914,89 @@ class CVec_PublicKeyZ { const LDKCVec_PublicKeyZ* operator &() const { return &self; } const LDKCVec_PublicKeyZ* operator ->() const { return &self; } }; -class CResult_NonePeerHandleErrorZ { +class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { private: - LDKCResult_NonePeerHandleErrorZ self; + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self; public: - CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete; - ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); } - CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); } - CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); } - operator LDKCResult_NonePeerHandleErrorZ() { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; } - LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; } - LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; } - const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } - const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete; + ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); } + operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; } + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; } + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; } }; -class CVec_NodeAnnouncementZ { +class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { private: - LDKCVec_NodeAnnouncementZ self; + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ self; public: - CVec_NodeAnnouncementZ(const CVec_NodeAnnouncementZ&) = delete; - ~CVec_NodeAnnouncementZ() { CVec_NodeAnnouncementZ_free(self); } - CVec_NodeAnnouncementZ(CVec_NodeAnnouncementZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NodeAnnouncementZ)); } - CVec_NodeAnnouncementZ(LDKCVec_NodeAnnouncementZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); } - operator LDKCVec_NodeAnnouncementZ() { LDKCVec_NodeAnnouncementZ res = self; memset(&self, 0, sizeof(LDKCVec_NodeAnnouncementZ)); return res; } - LDKCVec_NodeAnnouncementZ* operator &() { return &self; } - LDKCVec_NodeAnnouncementZ* operator ->() { return &self; } - const LDKCVec_NodeAnnouncementZ* operator &() const { return &self; } - const LDKCVec_NodeAnnouncementZ* operator ->() const { return &self; } + C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(const C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&) = delete; + ~C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ() { C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(self); } + C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); } + C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); } + operator LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ() { LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ)); return res; } + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() { return &self; } + LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() { return &self; } + const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; } + const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; } }; -class CResult_boolPeerHandleErrorZ { +class CVec_MessageSendEventZ { private: - LDKCResult_boolPeerHandleErrorZ self; + LDKCVec_MessageSendEventZ self; public: - CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete; - ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); } - CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); } - CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); } - operator LDKCResult_boolPeerHandleErrorZ() { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; } - LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; } - LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; } - const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } - const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } + CVec_MessageSendEventZ(const CVec_MessageSendEventZ&) = delete; + ~CVec_MessageSendEventZ() { CVec_MessageSendEventZ_free(self); } + CVec_MessageSendEventZ(CVec_MessageSendEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageSendEventZ)); } + CVec_MessageSendEventZ(LDKCVec_MessageSendEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageSendEventZ)); } + operator LDKCVec_MessageSendEventZ() { LDKCVec_MessageSendEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageSendEventZ)); return res; } + LDKCVec_MessageSendEventZ* operator &() { return &self; } + LDKCVec_MessageSendEventZ* operator ->() { return &self; } + const LDKCVec_MessageSendEventZ* operator &() const { return &self; } + const LDKCVec_MessageSendEventZ* operator ->() const { return &self; } }; -class CResult_SecretKeySecpErrorZ { +class CVec_UpdateFailHTLCZ { private: - LDKCResult_SecretKeySecpErrorZ self; + LDKCVec_UpdateFailHTLCZ self; public: - CResult_SecretKeySecpErrorZ(const CResult_SecretKeySecpErrorZ&) = delete; - ~CResult_SecretKeySecpErrorZ() { CResult_SecretKeySecpErrorZ_free(self); } - CResult_SecretKeySecpErrorZ(CResult_SecretKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SecretKeySecpErrorZ)); } - CResult_SecretKeySecpErrorZ(LDKCResult_SecretKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); } - operator LDKCResult_SecretKeySecpErrorZ() { LDKCResult_SecretKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); return res; } - LDKCResult_SecretKeySecpErrorZ* operator &() { return &self; } - LDKCResult_SecretKeySecpErrorZ* operator ->() { return &self; } - const LDKCResult_SecretKeySecpErrorZ* operator &() const { return &self; } - const LDKCResult_SecretKeySecpErrorZ* operator ->() const { return &self; } + CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete; + ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); } + CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); } + CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); } + operator LDKCVec_UpdateFailHTLCZ() { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; } + LDKCVec_UpdateFailHTLCZ* operator &() { return &self; } + LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; } + const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; } + const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; } }; -class CVec_TransactionZ { +class CVec_UpdateFulfillHTLCZ { private: - LDKCVec_TransactionZ self; + LDKCVec_UpdateFulfillHTLCZ self; public: - CVec_TransactionZ(const CVec_TransactionZ&) = delete; - ~CVec_TransactionZ() { CVec_TransactionZ_free(self); } - CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); } - CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); } - operator LDKCVec_TransactionZ() { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; } - LDKCVec_TransactionZ* operator &() { return &self; } - LDKCVec_TransactionZ* operator ->() { return &self; } - const LDKCVec_TransactionZ* operator &() const { return &self; } - const LDKCVec_TransactionZ* operator ->() const { return &self; } + CVec_UpdateFulfillHTLCZ(const CVec_UpdateFulfillHTLCZ&) = delete; + ~CVec_UpdateFulfillHTLCZ() { CVec_UpdateFulfillHTLCZ_free(self); } + CVec_UpdateFulfillHTLCZ(CVec_UpdateFulfillHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFulfillHTLCZ)); } + CVec_UpdateFulfillHTLCZ(LDKCVec_UpdateFulfillHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); } + operator LDKCVec_UpdateFulfillHTLCZ() { LDKCVec_UpdateFulfillHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); return res; } + LDKCVec_UpdateFulfillHTLCZ* operator &() { return &self; } + LDKCVec_UpdateFulfillHTLCZ* operator ->() { return &self; } + const LDKCVec_UpdateFulfillHTLCZ* operator &() const { return &self; } + const LDKCVec_UpdateFulfillHTLCZ* operator ->() const { return &self; } }; -class CResult_NonePaymentSendFailureZ { +class CVec_UpdateAddHTLCZ { private: - LDKCResult_NonePaymentSendFailureZ self; + LDKCVec_UpdateAddHTLCZ self; public: - CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete; - ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); } - CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); } - CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); } - operator LDKCResult_NonePaymentSendFailureZ() { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; } - LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; } - LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; } - const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; } - const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; } + CVec_UpdateAddHTLCZ(const CVec_UpdateAddHTLCZ&) = delete; + ~CVec_UpdateAddHTLCZ() { CVec_UpdateAddHTLCZ_free(self); } + CVec_UpdateAddHTLCZ(CVec_UpdateAddHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateAddHTLCZ)); } + CVec_UpdateAddHTLCZ(LDKCVec_UpdateAddHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateAddHTLCZ)); } + operator LDKCVec_UpdateAddHTLCZ() { LDKCVec_UpdateAddHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateAddHTLCZ)); return res; } + LDKCVec_UpdateAddHTLCZ* operator &() { return &self; } + LDKCVec_UpdateAddHTLCZ* operator ->() { return &self; } + const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; } + const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; } }; class CVec_EventZ { private: @@ -1956,32 +2012,46 @@ class CVec_EventZ { const LDKCVec_EventZ* operator &() const { return &self; } const LDKCVec_EventZ* operator ->() const { return &self; } }; -class CVec_u8Z { +class CVec_SignatureZ { private: - LDKCVec_u8Z self; + LDKCVec_SignatureZ self; public: - CVec_u8Z(const CVec_u8Z&) = delete; - ~CVec_u8Z() { CVec_u8Z_free(self); } - CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); } - CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } - operator LDKCVec_u8Z() { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } - LDKCVec_u8Z* operator &() { return &self; } - LDKCVec_u8Z* operator ->() { return &self; } - const LDKCVec_u8Z* operator &() const { return &self; } - const LDKCVec_u8Z* operator ->() const { return &self; } + CVec_SignatureZ(const CVec_SignatureZ&) = delete; + ~CVec_SignatureZ() { CVec_SignatureZ_free(self); } + CVec_SignatureZ(CVec_SignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SignatureZ)); } + CVec_SignatureZ(LDKCVec_SignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SignatureZ)); } + operator LDKCVec_SignatureZ() { LDKCVec_SignatureZ res = self; memset(&self, 0, sizeof(LDKCVec_SignatureZ)); return res; } + LDKCVec_SignatureZ* operator &() { return &self; } + LDKCVec_SignatureZ* operator ->() { return &self; } + const LDKCVec_SignatureZ* operator &() const { return &self; } + const LDKCVec_SignatureZ* operator ->() const { return &self; } }; -class CResult_PublicKeySecpErrorZ { +class CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ { private: - LDKCResult_PublicKeySecpErrorZ self; + LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ self; public: - CResult_PublicKeySecpErrorZ(const CResult_PublicKeySecpErrorZ&) = delete; - ~CResult_PublicKeySecpErrorZ() { CResult_PublicKeySecpErrorZ_free(self); } - CResult_PublicKeySecpErrorZ(CResult_PublicKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PublicKeySecpErrorZ)); } - CResult_PublicKeySecpErrorZ(LDKCResult_PublicKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); } - operator LDKCResult_PublicKeySecpErrorZ() { LDKCResult_PublicKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); return res; } - LDKCResult_PublicKeySecpErrorZ* operator &() { return &self; } - LDKCResult_PublicKeySecpErrorZ* operator ->() { return &self; } - const LDKCResult_PublicKeySecpErrorZ* operator &() const { return &self; } - const LDKCResult_PublicKeySecpErrorZ* operator ->() const { return &self; } + CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(const CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&) = delete; + ~CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(self); } + CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); } + CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); } + operator LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); return res; } + LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() { return &self; } + LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() const { return &self; } +}; +class CResult_SignatureNoneZ { +private: + LDKCResult_SignatureNoneZ self; +public: + CResult_SignatureNoneZ(const CResult_SignatureNoneZ&) = delete; + ~CResult_SignatureNoneZ() { CResult_SignatureNoneZ_free(self); } + CResult_SignatureNoneZ(CResult_SignatureNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignatureNoneZ)); } + CResult_SignatureNoneZ(LDKCResult_SignatureNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignatureNoneZ)); } + operator LDKCResult_SignatureNoneZ() { LDKCResult_SignatureNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_SignatureNoneZ)); return res; } + LDKCResult_SignatureNoneZ* operator &() { return &self; } + LDKCResult_SignatureNoneZ* operator ->() { return &self; } + const LDKCResult_SignatureNoneZ* operator &() const { return &self; } + const LDKCResult_SignatureNoneZ* operator ->() const { return &self; } }; } diff --git a/lightning-c-bindings/include/rust_types.h b/lightning-c-bindings/include/rust_types.h index 3b6821aa6c9..e328836e1bc 100644 --- a/lightning-c-bindings/include/rust_types.h +++ b/lightning-c-bindings/include/rust_types.h @@ -104,6 +104,16 @@ struct nativeUnsignedChannelUpdateOpaque; typedef struct nativeUnsignedChannelUpdateOpaque LDKnativeUnsignedChannelUpdate; struct nativeChannelUpdateOpaque; typedef struct nativeChannelUpdateOpaque LDKnativeChannelUpdate; +struct nativeQueryChannelRangeOpaque; +typedef struct nativeQueryChannelRangeOpaque LDKnativeQueryChannelRange; +struct nativeReplyChannelRangeOpaque; +typedef struct nativeReplyChannelRangeOpaque LDKnativeReplyChannelRange; +struct nativeQueryShortChannelIdsOpaque; +typedef struct nativeQueryShortChannelIdsOpaque LDKnativeQueryShortChannelIds; +struct nativeReplyShortChannelIdsEndOpaque; +typedef struct nativeReplyShortChannelIdsEndOpaque LDKnativeReplyShortChannelIdsEnd; +struct nativeGossipTimestampFilterOpaque; +typedef struct nativeGossipTimestampFilterOpaque LDKnativeGossipTimestampFilter; struct nativeLightningErrorOpaque; typedef struct nativeLightningErrorOpaque LDKnativeLightningError; struct nativeCommitmentUpdateOpaque; @@ -122,8 +132,8 @@ struct nativeChannelPublicKeysOpaque; typedef struct nativeChannelPublicKeysOpaque LDKnativeChannelPublicKeys; struct nativeHTLCOutputInCommitmentOpaque; typedef struct nativeHTLCOutputInCommitmentOpaque LDKnativeHTLCOutputInCommitment; -struct nativeLocalCommitmentTransactionOpaque; -typedef struct nativeLocalCommitmentTransactionOpaque LDKnativeLocalCommitmentTransaction; +struct nativeHolderCommitmentTransactionOpaque; +typedef struct nativeHolderCommitmentTransactionOpaque LDKnativeHolderCommitmentTransaction; struct nativeInitFeaturesOpaque; typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; struct nativeNodeFeaturesOpaque; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index 8d1e8041bbb..16463a1894e 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -216,6 +216,11 @@ pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutP } } +#[no_mangle] +pub type CVec_u64Z = crate::c_types::CVecTempl; +#[no_mangle] +pub static CVec_u64Z_free: extern "C" fn(CVec_u64Z) = crate::c_types::CVecTempl_free::; + #[no_mangle] pub type CVec_UpdateAddHTLCZ = crate::c_types::CVecTempl; #[no_mangle] @@ -398,8 +403,3 @@ pub static CResult_RouteLightningErrorZ_ok: extern "C" fn (crate::routing::route pub static CResult_RouteLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] -pub type CVec_u64Z = crate::c_types::CVecTempl; -#[no_mangle] -pub static CVec_u64Z_free: extern "C" fn(CVec_u64Z) = crate::c_types::CVecTempl_free::; - diff --git a/lightning-c-bindings/src/chain/keysinterface.rs b/lightning-c-bindings/src/chain/keysinterface.rs index c68c219c24e..290b295537f 100644 --- a/lightning-c-bindings/src/chain/keysinterface.rs +++ b/lightning-c-bindings/src/chain/keysinterface.rs @@ -44,7 +44,7 @@ pub enum SpendableOutputDescriptor { /// ChannelKeys::pubkeys(). /// /// To derive the revocation_pubkey provided here (which is used in the witness - /// script generation), you must pass the revocation_basepoint (which appears in the + /// script generation), you must pass the counterparty revocation_basepoint (which appears in the /// call to ChannelKeys::on_accept) and the provided per_commitment point /// to chan_utils::derive_public_revocation_key. /// @@ -261,7 +261,7 @@ pub struct ChannelKeys { /// TODO: return a Result so we can signal a validation error #[must_use] pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, - /// Gets the local channel public keys and basepoints + /// Gets the holder's channel public keys and basepoints pub pubkeys: crate::ln::chan_utils::ChannelPublicKeys, /// 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 @@ -272,18 +272,18 @@ pub struct ChannelKeys { /// ChannelKeys object uniquely and lookup or re-derive its keys. #[must_use] pub key_derivation_params: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::C2Tuple_u64u64Z, - /// Create a signature for a counterparty commitment transaction and associated HTLC transactions. + /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. /// /// Note that if signing fails or is rejected, the channel will be force-closed. #[must_use] pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// Create a signature for a local commitment transaction. This will only ever be called with - /// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees + /// Create a signature for a holder's commitment transaction. This will only ever be called with + /// the same holder_commitment_tx (or a copy thereof), though there are currently no guarantees /// that it will not be called multiple times. /// An external signer implementation should check that the commitment has not been revoked. #[must_use] pub sign_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for each HTLC transaction spending a holder commitment transaction. + /// Create a signature for each HTLC transaction spending a holder's commitment transaction. /// /// Unlike sign_holder_commitment, this may be called multiple times with *different* /// holder_commitment_tx values. While this will never be called with a revoked @@ -309,8 +309,8 @@ pub struct ChannelKeys { /// Amount is value of the output spent by this input, committed to in the BIP 143 signature. /// /// per_commitment_key is revocation secret which was provided by our counterparty when they - /// revoked the state which they eventually broadcast. It's not a _local_ secret key and does - /// not allow the spending of any funds by itself (you need our local revocation_secret to do + /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + /// not allow the spending of any funds by itself (you need our holder revocation_secret to do /// so). /// /// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus @@ -318,7 +318,7 @@ pub struct ChannelKeys { /// signatures). #[must_use] pub sign_justice_transaction: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for a claiming transaction for a HTLC output on a counterparty commitment + /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment /// transaction, either offered or received. /// /// Such a transaction may claim multiples offered outputs at same time if we know the @@ -351,13 +351,13 @@ pub struct ChannelKeys { /// protocol. #[must_use] pub sign_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Set the counterparty channel basepoints and counterparty/local to_self_delay. + /// Set the counterparty channel basepoints and counterparty_selected/holder_selected_contest_delay. /// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels. /// - /// We bind local_to_self_delay late here for API convenience. + /// We bind holder_selected_contest_delay late here for API convenience. /// /// Will be called before any signatures are applied. - pub on_accept: extern "C" fn (this_arg: *mut c_void, channel_points: &crate::ln::chan_utils::ChannelPublicKeys, counterparty_to_self_delay: u16, local_to_self_delay: u16), + pub on_accept: extern "C" fn (this_arg: *mut c_void, channel_points: &crate::ln::chan_utils::ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16), pub clone: Option *mut c_void>, pub free: Option, } @@ -413,13 +413,13 @@ impl rustChannelKeys for ChannelKeys { let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })}; local_ret } - fn sign_holder_commitment(&self, local_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_holder_commitment)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false }); + fn sign_holder_commitment(&self, holder_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_holder_commitment)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (holder_commitment_tx as *const _) as *mut _ }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })}; local_ret } - fn sign_holder_commitment_htlc_transactions(&self, local_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result>, ()> { - let mut ret = (self.sign_holder_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false }); + fn sign_holder_commitment_htlc_transactions(&self, holder_commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result>, ()> { + let mut ret = (self.sign_holder_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (holder_commitment_tx as *const _) as *mut _ }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust().drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_null() { None } else { Some( { item.into_rust() }) }; local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })}; local_ret } @@ -447,8 +447,8 @@ impl rustChannelKeys for ChannelKeys { let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })}; local_ret } - fn on_accept(&mut self, channel_points: &lightning::ln::chan_utils::ChannelPublicKeys, counterparty_to_self_delay: u16, local_to_self_delay: u16) { - (self.on_accept)(self.this_arg, &crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { (channel_points as *const _) as *mut _ }, is_owned: false }, counterparty_to_self_delay, local_to_self_delay) + fn on_accept(&mut self, channel_points: &lightning::ln::chan_utils::ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16) { + (self.on_accept)(self.this_arg, &crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { (channel_points as *const _) as *mut _ }, is_owned: false }, counterparty_selected_contest_delay, holder_selected_contest_delay) } } @@ -602,46 +602,46 @@ pub extern "C" fn InMemoryChannelKeys_get_funding_key(this_ptr: &InMemoryChannel pub extern "C" fn InMemoryChannelKeys_set_funding_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) { unsafe { &mut *this_ptr.inner }.funding_key = val.into_rust(); } -/// Local secret key for blinded revocation pubkey +/// Holder secret key for blinded revocation pubkey #[no_mangle] pub extern "C" fn InMemoryChannelKeys_get_revocation_base_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key; (*inner_val).as_ref() } -/// Local secret key for blinded revocation pubkey +/// 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) { unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust(); } -/// Local secret key used for our balance in counterparty-broadcasted commitment transactions +/// 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] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key; (*inner_val).as_ref() } -/// Local secret key used for our balance in counterparty-broadcasted commitment transactions +/// 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) { unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust(); } -/// Local secret key used in HTLC tx +/// 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] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key; (*inner_val).as_ref() } -/// Local secret key used in HTLC tx +/// 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) { unsafe { &mut *this_ptr.inner }.delayed_payment_base_key = val.into_rust(); } -/// Local htlc secret key used in commitment tx htlc outputs +/// 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] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key; (*inner_val).as_ref() } -/// Local htlc secret key used in commitment tx htlc outputs +/// 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) { unsafe { &mut *this_ptr.inner }.htlc_base_key = val.into_rust(); @@ -675,10 +675,10 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryCh crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } -/// The contest delay value specified by our counterparty and applied on holder-broadcastable +/// The contest_delay value specified by our counterparty and applied on holder-broadcastable /// transactions, ie the amount of time that we have to wait to recover our funds if we /// broadcast a transaction. You'll likely want to pass this to the -/// ln::chan_utils::build*_transaction functions when signing holder transactions. +/// ln::chan_utils::build*_transaction functions when signing holder's transactions. /// Will panic if on_accept wasn't called. #[must_use] #[no_mangle] @@ -687,7 +687,7 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_a ret } -/// The to_contest delay value specified by us and applied on transactions broadcastable +/// The contest_delay value specified by us and applied on transactions broadcastable /// by our counterparty, ie the amount of time that they have to wait to recover their funds /// if they broadcast a transaction. /// Will panic if on_accept wasn't called. @@ -757,14 +757,14 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_ local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment(this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment(unsafe { &*holder_commitment_tx.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) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) }; local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_htlc_transactions(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions(this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_htlc_transactions(unsafe { &*holder_commitment_tx.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 item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_none() { crate::c_types::Signature::null() } else { { crate::c_types::Signature::from_rust(&(item.unwrap())) } }; local_ret_0_0 }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) }; local_ret } diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs index d4f551b2317..bf3953a09e4 100644 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ b/lightning-c-bindings/src/ln/chan_utils.rs @@ -40,11 +40,16 @@ pub extern "C" fn derive_public_key(per_commitment_point: crate::c_types::Public /// Derives a per-commitment-transaction revocation key from its constituent parts. /// +/// Only the cheating participant owns a valid witness to propagate a revoked +/// commitment transaction, thus per_commitment_secret always come from cheater +/// and revocation_base_secret always come from punisher, which is the broadcaster +/// of the transaction spending with this key knowledge. +/// /// Note that this is infallible iff we trust that at least one of the two input keys are randomly /// generated (ie our own). #[no_mangle] -pub extern "C" fn derive_private_revocation_key(per_commitment_secret: *const [u8; 32], revocation_base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeySecpErrorZ { - let mut ret = lightning::ln::chan_utils::derive_private_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_secret}[..]).unwrap(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *revocation_base_secret}[..]).unwrap()); +pub extern "C" fn derive_private_revocation_key(per_commitment_secret: *const [u8; 32], countersignatory_revocation_base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeySecpErrorZ { + let mut ret = lightning::ln::chan_utils::derive_private_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_secret}[..]).unwrap(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *countersignatory_revocation_base_secret}[..]).unwrap()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SecretKey::from_rust(o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) }; local_ret } @@ -53,11 +58,16 @@ pub extern "C" fn derive_private_revocation_key(per_commitment_secret: *const [u /// the public equivalend of derive_private_revocation_key - using only public keys to derive a /// public key instead of private keys. /// +/// Only the cheating participant owns a valid witness to propagate a revoked +/// commitment transaction, thus per_commitment_point always come from cheater +/// and revocation_base_point always come from punisher, which is the broadcaster +/// of the transaction spending with this key knowledge. +/// /// Note that this is infallible iff we trust that at least one of the two input keys are randomly /// generated (ie our own). #[no_mangle] -pub extern "C" fn derive_public_revocation_key(per_commitment_point: crate::c_types::PublicKey, revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ { - let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &revocation_base_point.into_rust()); +pub extern "C" fn derive_public_revocation_key(per_commitment_point: crate::c_types::PublicKey, countersignatory_revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ { + let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &countersignatory_revocation_base_point.into_rust()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) }; local_ret } @@ -69,6 +79,10 @@ type nativeTxCreationKeys = nativeTxCreationKeysImport; /// The set of public keys which are used in the creation of one commitment transaction. /// These are derived from the channel base keys and per-commitment data. /// +/// A broadcaster key is provided from potential broadcaster of the computed transaction. +/// A countersignatory key is coming from a protocol participant unable to broadcast the +/// transaction. +/// /// These keys are assumed to be good, either because the code derived them from /// channel basepoints via the new function, or they were obtained via /// PreCalculatedTxCreationKeys.trust_key_derivation because we trusted the source of the @@ -119,26 +133,28 @@ impl Clone for TxCreationKeys { pub(crate) extern "C" fn TxCreationKeys_clone_void(this_ptr: *const c_void) -> *mut c_void { Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxCreationKeys)).clone() })) as *mut c_void } -/// The per-commitment public key which was used to derive the other keys. +/// The broadcaster's per-commitment public key which was used to derive the other keys. #[no_mangle] pub extern "C" fn TxCreationKeys_get_per_commitment_point(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point; crate::c_types::PublicKey::from_rust(&(*inner_val)) } -/// The per-commitment public key which was used to derive the other keys. +/// The broadcaster's per-commitment public key which was used to derive the other keys. #[no_mangle] pub extern "C" fn TxCreationKeys_set_per_commitment_point(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust(); } -/// The revocation key which is used to allow the owner of the commitment transaction to -/// provide their counterparty the ability to punish them if they broadcast an old state. +/// The revocation key which is used to allow the broadcaster of the commitment +/// transaction to provide their counterparty the ability to punish them if they broadcast +/// an old state. #[no_mangle] pub extern "C" fn TxCreationKeys_get_revocation_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_key; crate::c_types::PublicKey::from_rust(&(*inner_val)) } -/// The revocation key which is used to allow the owner of the commitment transaction to -/// provide their counterparty the ability to punish them if they broadcast an old state. +/// The revocation key which is used to allow the broadcaster of the commitment +/// transaction to provide their counterparty the ability to punish them if they broadcast +/// an old state. #[no_mangle] pub extern "C" fn TxCreationKeys_set_revocation_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *this_ptr.inner }.revocation_key = val.into_rust(); @@ -165,13 +181,13 @@ pub extern "C" fn TxCreationKeys_get_countersignatory_htlc_key(this_ptr: &TxCrea pub extern "C" fn TxCreationKeys_set_countersignatory_htlc_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key = val.into_rust(); } -/// Payment Key (which isn't allowed to be spent from for some delay) +/// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) #[no_mangle] pub extern "C" fn TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key; crate::c_types::PublicKey::from_rust(&(*inner_val)) } -/// Payment Key (which isn't allowed to be spent from for some delay) +/// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) #[no_mangle] pub extern "C" fn TxCreationKeys_set_broadcaster_delayed_payment_key(this_ptr: &mut TxCreationKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key = val.into_rust(); @@ -346,17 +362,17 @@ pub extern "C" fn ChannelPublicKeys_get_revocation_basepoint(this_ptr: &ChannelP pub extern "C" fn ChannelPublicKeys_set_revocation_basepoint(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust(); } -/// The public key which receives our immediately spendable primary channel balance in -/// counterparty-broadcasted commitment transactions. This key is static across every commitment -/// transaction. +/// The public key on which the non-broadcaster (ie the countersignatory) receives an immediately +/// spendable primary channel balance on the broadcaster's commitment transaction. This key is +/// static across every commitment transaction. #[no_mangle] pub extern "C" fn ChannelPublicKeys_get_payment_point(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point; crate::c_types::PublicKey::from_rust(&(*inner_val)) } -/// The public key which receives our immediately spendable primary channel balance in -/// counterparty-broadcasted commitment transactions. This key is static across every commitment -/// transaction. +/// The public key on which the non-broadcaster (ie the countersignatory) receives an immediately +/// spendable primary channel balance on the broadcaster's commitment transaction. This key is +/// static across every commitment transaction. #[no_mangle] pub extern "C" fn ChannelPublicKeys_set_payment_point(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust(); @@ -415,18 +431,18 @@ pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> Channe /// Create a new TxCreationKeys from channel base points and the per-commitment point #[must_use] #[no_mangle] -pub extern "C" fn TxCreationKeys_derive_new(per_commitment_point: crate::c_types::PublicKey, a_delayed_payment_base: crate::c_types::PublicKey, a_htlc_base: crate::c_types::PublicKey, b_revocation_base: crate::c_types::PublicKey, b_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ { - let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &a_delayed_payment_base.into_rust(), &a_htlc_base.into_rust(), &b_revocation_base.into_rust(), &b_htlc_base.into_rust()); +pub extern "C" fn TxCreationKeys_derive_new(per_commitment_point: crate::c_types::PublicKey, broadcaster_delayed_payment_base: crate::c_types::PublicKey, broadcaster_htlc_base: crate::c_types::PublicKey, countersignatory_revocation_base: crate::c_types::PublicKey, countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ { + let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &broadcaster_delayed_payment_base.into_rust(), &broadcaster_htlc_base.into_rust(), &countersignatory_revocation_base.into_rust(), &countersignatory_htlc_base.into_rust()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) }; local_ret } /// A script either spendable by the revocation /// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. -/// Encumbering a `to_local` output on a commitment transaction or 2nd-stage HTLC transactions. +/// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. #[no_mangle] -pub extern "C" fn get_revokeable_redeemscript(revocation_key: crate::c_types::PublicKey, mut to_self_delay: u16, broadcaster_delayed_payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { - let mut ret = lightning::ln::chan_utils::get_revokeable_redeemscript(&revocation_key.into_rust(), to_self_delay, &broadcaster_delayed_payment_key.into_rust()); +pub extern "C" fn get_revokeable_redeemscript(revocation_key: crate::c_types::PublicKey, mut contest_delay: u16, broadcaster_delayed_payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { + let mut ret = lightning::ln::chan_utils::get_revokeable_redeemscript(&revocation_key.into_rust(), contest_delay, &broadcaster_delayed_payment_key.into_rust()); ret.into_bytes().into() } @@ -545,8 +561,8 @@ pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> H HTLCOutputInCommitment { inner: std::ptr::null_mut(), is_owned: true } } } -/// note here that 'a_revocation_key' is generated using b_revocation_basepoint and a's -/// commitment secret. 'htlc' does *not* need to have its previous_output_index filled. +/// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc +/// does not need to have its previous_output_index filled. #[no_mangle] pub extern "C" fn get_htlc_redeemscript(htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, keys: &crate::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(unsafe { &*htlc.inner }, unsafe { &*keys.inner }); @@ -556,15 +572,15 @@ pub extern "C" fn get_htlc_redeemscript(htlc: &crate::ln::chan_utils::HTLCOutput /// Gets the redeemscript for a funding output from the two funding public keys. /// Note that the order of funding public keys does not matter. #[no_mangle] -pub extern "C" fn make_funding_redeemscript(a: crate::c_types::PublicKey, b: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { - let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&a.into_rust(), &b.into_rust()); +pub extern "C" fn make_funding_redeemscript(broadcaster: crate::c_types::PublicKey, countersignatory: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { + let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&broadcaster.into_rust(), &countersignatory.into_rust()); ret.into_bytes().into() } /// panics if htlc.transaction_output_index.is_none()! #[no_mangle] -pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut to_self_delay: u16, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, broadcaster_delayed_payment_key: crate::c_types::PublicKey, revocation_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { - let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, to_self_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); +pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, broadcaster_delayed_payment_key: crate::c_types::PublicKey, revocation_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { + let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); let mut local_ret = ::bitcoin::consensus::encode::serialize(&ret); local_ret.into() } @@ -662,7 +678,7 @@ pub extern "C" fn HolderCommitmentTransaction_set_feerate_per_kw(this_ptr: &mut /// /// Note that this includes all HTLCs, including ones which were considered dust and not /// actually included in the transaction as it appears on-chain, but who's value is burned as -/// fees and not included in the to_local or to_remote outputs. +/// fees and not included in the to_holder or to_counterparty outputs. /// /// The counterparty HTLC signatures in the second element will always be set for non-dust HTLCs, ie /// those for which transaction_output_index.is_some(). @@ -679,8 +695,8 @@ pub extern "C" fn HolderCommitmentTransaction_set_per_htlc(this_ptr: &mut Holder #[must_use] #[no_mangle] pub extern "C" fn HolderCommitmentTransaction_new_missing_holder_sig(mut unsigned_tx: crate::c_types::derived::CVec_u8Z, mut counterparty_sig: crate::c_types::Signature, holder_funding_key: crate::c_types::PublicKey, counterparty_funding_key: crate::c_types::PublicKey, mut keys: crate::ln::chan_utils::TxCreationKeys, mut feerate_per_kw: u32, mut htlc_data: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) -> crate::ln::chan_utils::HolderCommitmentTransaction { - let mut holder_htlc_data = Vec::new(); for mut item in htlc_data.into_rust().drain(..) { holder_htlc_data.push( { let (mut orig_htlc_data_0_0, mut orig_htlc_data_0_1) = item.to_rust(); let mut holder_orig_htlc_data_0_1 = if orig_htlc_data_0_1.is_null() { None } else { Some( { orig_htlc_data_0_1.into_rust() }) }; let mut holder_htlc_data_0 = (*unsafe { Box::from_raw(orig_htlc_data_0_0.take_ptr()) }, holder_orig_htlc_data_0_1); holder_htlc_data_0 }); }; - let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new_missing_holder_sig(::bitcoin::consensus::encode::deserialize(&unsigned_tx.into_rust()[..]).unwrap(), counterparty_sig.into_rust(), &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust(), *unsafe { Box::from_raw(keys.take_ptr()) }, feerate_per_kw, holder_htlc_data); + let mut local_htlc_data = Vec::new(); for mut item in htlc_data.into_rust().drain(..) { local_htlc_data.push( { let (mut orig_htlc_data_0_0, mut orig_htlc_data_0_1) = item.to_rust(); let mut local_orig_htlc_data_0_1 = if orig_htlc_data_0_1.is_null() { None } else { Some( { orig_htlc_data_0_1.into_rust() }) }; let mut local_htlc_data_0 = (*unsafe { Box::from_raw(orig_htlc_data_0_0.take_ptr()) }, local_orig_htlc_data_0_1); local_htlc_data_0 }); }; + let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new_missing_holder_sig(::bitcoin::consensus::encode::deserialize(&unsigned_tx.into_rust()[..]).unwrap(), counterparty_sig.into_rust(), &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust(), *unsafe { Box::from_raw(keys.take_ptr()) }, feerate_per_kw, local_htlc_data); crate::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } } @@ -702,7 +718,7 @@ pub extern "C" fn HolderCommitmentTransaction_txid(this_arg: &HolderCommitmentTr crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } } -/// Gets our signature for the contained commitment transaction given our funding private key. +/// Gets holder signature for the contained commitment transaction given holder funding private key. /// /// Funding key is your key included in the 2-2 funding_outpoint lock. Should be provided /// by your ChannelKeys. diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index 43e38b357ae..c71305904c7 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -624,62 +624,62 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: *const Chann } } use lightning::ln::msgs::ChannelMessageHandler as ChannelMessageHandlerTraitImport; -extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_open_channel(&their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_open_channel(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_accept_channel(&their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_accept_channel(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_created(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_created(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_signed(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_signed(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_locked(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_locked(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_shutdown(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_shutdown(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_closing_signed(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_closing_signed(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_add_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_add_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fulfill_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fulfill_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_malformed_htlc(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_malformed_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_commitment_signed(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_commitment_signed(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_revoke_and_ack(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_revoke_and_ack(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fee(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fee(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_announcement_signatures(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_announcement_signatures(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_channel_reestablish(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_channel_reestablish(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_disconnected(&their_node_id.into_rust(), no_connection_possible) +extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_disconnected(&counterparty_node_id.into_rust(), no_connection_possible) } -extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_connected(&their_node_id.into_rust(), unsafe { &*init_msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_connected(&counterparty_node_id.into_rust(), unsafe { &*init_msg.inner }) } -extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage) { - unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_error(&their_node_id.into_rust(), unsafe { &*msg.inner }) +extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage) { + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_error(&counterparty_node_id.into_rust(), unsafe { &*msg.inner }) } use lightning::util::events::MessageSendEventsProvider as nativeMessageSendEventsProviderTrait; #[must_use] diff --git a/lightning-c-bindings/src/ln/channelmonitor.rs b/lightning-c-bindings/src/ln/channelmonitor.rs index c53d7197ac6..671566af385 100644 --- a/lightning-c-bindings/src/ln/channelmonitor.rs +++ b/lightning-c-bindings/src/ln/channelmonitor.rs @@ -111,7 +111,7 @@ pub enum ChannelMonitorUpdateErr { /// our state failed, but is expected to succeed at some point in the future). /// /// Such a failure will \"freeze\" a channel, preventing us from revoking old states or - /// submitting new commitment transactions to the remote party. Once the update(s) which failed + /// submitting new commitment transactions to the counterparty. Once the update(s) which failed /// have been successfully applied, ChannelManager::channel_monitor_updated can be used to /// restore the channel to an operational state. /// @@ -144,11 +144,19 @@ pub enum ChannelMonitorUpdateErr { TemporaryFailure, /// Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a /// different watchtower and cannot update with all watchtowers that were previously informed - /// of this channel). This will force-close the channel in question (which will generate one - /// final ChannelMonitorUpdate which must be delivered to at least one ChannelMonitor copy). + /// of this channel). /// - /// Should also be used to indicate a failure to update the local persisted copy of the channel - /// monitor. + /// At reception of this error, ChannelManager will force-close the channel and return at + /// least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at + /// least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel + /// update must be rejected. + /// + /// This failure may also signal a failure to update the local persisted copy of one of + /// the channel monitor instance. + /// + /// Note that even when you fail a holder commitment transaction update, you must store the + /// update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor + /// broadcasts it (e.g distributed channel-monitor deployment) PermanentFailure, } use lightning::ln::channelmonitor::ChannelMonitorUpdateErr as nativeChannelMonitorUpdateErr; @@ -424,6 +432,11 @@ pub struct ManyChannelMonitor { /// /// Any spends of outputs which should have been registered which aren't passed to /// ChannelMonitors via block_connected may result in FUNDS LOSS. + /// + /// In case of distributed watchtowers deployment, even if an Err is return, the new version + /// must be written to disk, as state may have been stored but rejected due to a block forcing + /// a commitment broadcast. This storage is used to claim outputs of rejected state confirmed + /// onchain by another watchtower, lagging behind on block processing. #[must_use] pub update_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ, /// Used by ChannelManager to get list of HTLC resolved onchain and which needed to be updated @@ -531,12 +544,12 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut Cha local_ret.into() } -/// Used by ChannelManager deserialization to broadcast the latest local state if its copy of -/// the Channel was out-of-date. You may use it to get a broadcastable local toxic tx in case of -/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our remote side knows -/// a higher revocation secret than the local commitment number we are aware of. Broadcasting these -/// transactions are UNSAFE, as they allow remote side to punish you. Nevertheless you may want to -/// broadcast them if remote don't close channel with his higher commitment transaction after a +/// Used by ChannelManager deserialization to broadcast the latest holder state if its copy of +/// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of +/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows +/// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these +/// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to +/// broadcast them if counterparty don't close channel with his higher commitment transaction after a /// substantial amount of time (a month or even a year) to get back funds. Best may be to contact /// out-of-band the other node operator to coordinate with him if option is available to you. /// In any-case, choice is up to the user. diff --git a/lightning-c-bindings/src/ln/msgs.rs b/lightning-c-bindings/src/ln/msgs.rs index 6726b9521a6..e3ca0944af4 100644 --- a/lightning-c-bindings/src/ln/msgs.rs +++ b/lightning-c-bindings/src/ln/msgs.rs @@ -2920,6 +2920,488 @@ pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) }, })), is_owned: true } } + +use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport; +type nativeQueryChannelRange = nativeQueryChannelRangeImport; + +/// A query_channel_range message is used to query a peer for channel +/// UTXOs in a range of blocks. The recipient of a query makes a best +/// effort to reply to the query using one or more reply_channel_range +/// messages. +#[must_use] +#[repr(C)] +pub struct QueryChannelRange { + /// Nearly everyhwere, 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 nativeQueryChannelRange, + pub is_owned: bool, +} + +impl Drop for QueryChannelRange { + fn drop(&mut self) { + if self.is_owned && !self.inner.is_null() { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +#[no_mangle] +pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl QueryChannelRange { + pub(crate) fn take_ptr(mut self) -> *mut nativeQueryChannelRange { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for QueryChannelRange { + fn clone(&self) -> Self { + Self { + inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())), + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; + (*inner_val).as_inner() +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The height of the first block for the channel UTXOs being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; + (*inner_val) +} +/// The height of the first block for the channel UTXOs being queried +#[no_mangle] +pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.first_blocknum = val; +} +/// The number of blocks to include in the query results +#[no_mangle] +pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; + (*inner_val) +} +/// The number of blocks to include in the query results +#[no_mangle] +pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.number_of_blocks = val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange { + QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + first_blocknum: first_blocknum_arg, + number_of_blocks: number_of_blocks_arg, + })), is_owned: true } +} + +use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport; +type nativeReplyChannelRange = nativeReplyChannelRangeImport; + +/// A reply_channel_range message is a reply to a query_channel_range +/// message. Multiple reply_channel_range messages can be sent in reply +/// to a single query_channel_range message. The query recipient makes a +/// best effort to respond based on their local network view which may +/// not be a perfect view of the network. The short_channel_ids in the +/// reply are encoded. We only support encoding_type=0 uncompressed +/// serialization and do not support encoding_type=1 zlib serialization. +#[must_use] +#[repr(C)] +pub struct ReplyChannelRange { + /// Nearly everyhwere, 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 nativeReplyChannelRange, + pub is_owned: bool, +} + +impl Drop for ReplyChannelRange { + fn drop(&mut self) { + if self.is_owned && !self.inner.is_null() { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +#[no_mangle] +pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ReplyChannelRange { + pub(crate) fn take_ptr(mut self) -> *mut nativeReplyChannelRange { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for ReplyChannelRange { + fn clone(&self) -> Self { + Self { + inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())), + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; + (*inner_val).as_inner() +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The height of the first block in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; + (*inner_val) +} +/// The height of the first block in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.first_blocknum = val; +} +/// The number of blocks included in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; + (*inner_val) +} +/// The number of blocks included in the range of the reply +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) { + unsafe { &mut *this_ptr.inner }.number_of_blocks = val; +} +/// Indicates if the query recipient maintains up-to-date channel +/// information for the chain_hash +#[no_mangle] +pub extern "C" fn ReplyChannelRange_get_full_information(this_ptr: &ReplyChannelRange) -> bool { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information; + (*inner_val) +} +/// Indicates if the query recipient maintains up-to-date channel +/// information for the chain_hash +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_full_information(this_ptr: &mut ReplyChannelRange, mut val: bool) { + unsafe { &mut *this_ptr.inner }.full_information = val; +} +/// The short_channel_ids in the channel range +#[no_mangle] +pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut full_information_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange { + let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; + ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + first_blocknum: first_blocknum_arg, + number_of_blocks: number_of_blocks_arg, + full_information: full_information_arg, + short_channel_ids: local_short_channel_ids_arg, + })), is_owned: true } +} + +use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport; +type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport; + +/// A query_short_channel_ids message is used to query a peer for +/// routing gossip messages related to one or more short_channel_ids. +/// The query recipient will reply with the latest, if available, +/// channel_announcement, channel_update and node_announcement messages +/// it maintains for the requested short_channel_ids followed by a +/// reply_short_channel_ids_end message. The short_channel_ids sent in +/// this query are encoded. We only support encoding_type=0 uncompressed +/// serialization and do not support encoding_type=1 zlib serialization. +#[must_use] +#[repr(C)] +pub struct QueryShortChannelIds { + /// Nearly everyhwere, 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 nativeQueryShortChannelIds, + pub is_owned: bool, +} + +impl Drop for QueryShortChannelIds { + fn drop(&mut self) { + if self.is_owned && !self.inner.is_null() { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl QueryShortChannelIds { + pub(crate) fn take_ptr(mut self) -> *mut nativeQueryShortChannelIds { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for QueryShortChannelIds { + fn clone(&self) -> Self { + Self { + inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())), + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; + (*inner_val).as_inner() +} +/// The genesis hash of the blockchain being queried +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The short_channel_ids that are being queried +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds { + let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; + QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + short_channel_ids: local_short_channel_ids_arg, + })), is_owned: true } +} + +use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport; +type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport; + +/// A reply_short_channel_ids_end message is sent as a reply to a +/// query_short_channel_ids message. The query recipient makes a best +/// effort to respond based on their local network view which may not be +/// a perfect view of the network. +#[must_use] +#[repr(C)] +pub struct ReplyShortChannelIdsEnd { + /// Nearly everyhwere, 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 nativeReplyShortChannelIdsEnd, + pub is_owned: bool, +} + +impl Drop for ReplyShortChannelIdsEnd { + fn drop(&mut self) { + if self.is_owned && !self.inner.is_null() { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ReplyShortChannelIdsEnd { + pub(crate) fn take_ptr(mut self) -> *mut nativeReplyShortChannelIdsEnd { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for ReplyShortChannelIdsEnd { + fn clone(&self) -> Self { + Self { + inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())), + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void +} +/// The genesis hash of the blockchain that was queried +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; + (*inner_val).as_inner() +} +/// The genesis hash of the blockchain that was queried +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// Indicates if the query recipient maintains up-to-date channel +/// information for the chain_hash +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information; + (*inner_val) +} +/// Indicates if the query recipient maintains up-to-date channel +/// information for the chain_hash +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) { + unsafe { &mut *this_ptr.inner }.full_information = val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd { + ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + full_information: full_information_arg, + })), is_owned: true } +} + +use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport; +type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport; + +/// A gossip_timestamp_filter message is used by a node to request +/// gossip relay for messages in the requested time range when the +/// gossip_queries feature has been negotiated. +#[must_use] +#[repr(C)] +pub struct GossipTimestampFilter { + /// Nearly everyhwere, 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 nativeGossipTimestampFilter, + pub is_owned: bool, +} + +impl Drop for GossipTimestampFilter { + fn drop(&mut self) { + if self.is_owned && !self.inner.is_null() { + let _ = unsafe { Box::from_raw(self.inner) }; + } + } +} +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl GossipTimestampFilter { + pub(crate) fn take_ptr(mut self) -> *mut nativeGossipTimestampFilter { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for GossipTimestampFilter { + fn clone(&self) -> Self { + Self { + inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())), + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void +} +/// The genesis hash of the blockchain for channel and node information +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; + (*inner_val).as_inner() +} +/// The genesis hash of the blockchain for channel and node information +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The starting unix timestamp +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp; + (*inner_val) +} +/// The starting unix timestamp +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) { + unsafe { &mut *this_ptr.inner }.first_timestamp = val; +} +/// The range of information in seconds +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range; + (*inner_val) +} +/// The range of information in seconds +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) { + unsafe { &mut *this_ptr.inner }.timestamp_range = val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter { + GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + first_timestamp: first_timestamp_arg, + timestamp_range: timestamp_range_arg, + })), is_owned: true } +} /// Used to put an error message in a LightningError #[must_use] #[derive(Clone)] @@ -3865,3 +4347,63 @@ pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnn NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true } } } +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> QueryShortChannelIds { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + QueryShortChannelIds { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + QueryShortChannelIds { inner: std::ptr::null_mut(), is_owned: true } + } +} +#[no_mangle] +pub extern "C" fn QueryShortChannelIds_write(obj: *const QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> ReplyShortChannelIdsEnd { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + ReplyShortChannelIdsEnd { inner: std::ptr::null_mut(), is_owned: true } + } +} +#[no_mangle] +pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: *const ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> QueryChannelRange { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + QueryChannelRange { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + QueryChannelRange { inner: std::ptr::null_mut(), is_owned: true } + } +} +#[no_mangle] +pub extern "C" fn QueryChannelRange_write(obj: *const QueryChannelRange) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> ReplyChannelRange { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + ReplyChannelRange { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + ReplyChannelRange { inner: std::ptr::null_mut(), is_owned: true } + } +} +#[no_mangle] +pub extern "C" fn ReplyChannelRange_write(obj: *const ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> GossipTimestampFilter { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + GossipTimestampFilter { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + GossipTimestampFilter { inner: std::ptr::null_mut(), is_owned: true } + } +} +#[no_mangle] +pub extern "C" fn GossipTimestampFilter_write(obj: *const GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} From a8be9af7d3af020d64a0c7a4638eeb27c4bb3977 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 14 Sep 2020 16:49:05 -0400 Subject: [PATCH 3/4] Move onion failure tests from functional_tests to their own file They all have a specific structure, so having them in the mess that is functional_tests isn't really conducive to readability. More importantly, functional_tests is so big it slows down compilation, so even dropping a few hundred lines is a win. --- lightning/src/ln/functional_tests.rs | 456 +----------------------- lightning/src/ln/mod.rs | 3 + lightning/src/ln/onion_route_tests.rs | 488 ++++++++++++++++++++++++++ 3 files changed, 495 insertions(+), 452 deletions(-) create mode 100644 lightning/src/ln/onion_route_tests.rs diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 6bc8efec2d5..a94003c484a 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -16,7 +16,7 @@ use chain::keysinterface::{ChannelKeys, KeysInterface, SpendableOutputDescriptor use chain::chaininterface; use chain::chaininterface::{ChainListener, ChainWatchInterfaceUtil, BlockNotifier}; use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC}; -use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,HTLCForwardInfo,RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSecret, PaymentSendFailure, BREAKDOWN_TIMEOUT}; +use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSecret, PaymentSendFailure, BREAKDOWN_TIMEOUT}; use ln::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ManyChannelMonitor, ANTI_REORG_DELAY}; use ln::channelmonitor; use ln::channel::{Channel, ChannelError}; @@ -24,12 +24,12 @@ use ln::{chan_utils, onion_utils}; use routing::router::{Route, RouteHop, get_route}; use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures}; use ln::msgs; -use ln::msgs::{ChannelMessageHandler,RoutingMessageHandler,HTLCFailChannelUpdate, ErrorAction, OptionalField}; +use ln::msgs::{ChannelMessageHandler,RoutingMessageHandler,HTLCFailChannelUpdate, ErrorAction}; use util::enforcing_trait_impls::EnforcingChannelKeys; use util::{byte_utils, test_utils}; use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider}; use util::errors::APIError; -use util::ser::{Writeable, Writer, ReadableArgs, Readable}; +use util::ser::{Writeable, ReadableArgs, Readable}; use util::config::UserConfig; use bitcoin::hashes::sha256d::Hash as Sha256dHash; @@ -57,7 +57,7 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use std::default::Default; use std::sync::{Arc, Mutex}; use std::sync::atomic::Ordering; -use std::{mem, io}; +use std::mem; use ln::functional_test_utils::*; use ln::chan_utils::PreCalculatedTxCreationKeys; @@ -5921,454 +5921,6 @@ fn htlc_claim_single_commitment_only_b() { do_htlc_claim_previous_remote_commitment_only(false, true); } -fn run_onion_failure_test(_name: &str, test_case: u8, nodes: &Vec, route: &Route, payment_hash: &PaymentHash, callback_msg: F1, callback_node: F2, expected_retryable: bool, expected_error_code: Option, expected_channel_update: Option) - where F1: for <'a> FnMut(&'a mut msgs::UpdateAddHTLC), - F2: FnMut(), -{ - run_onion_failure_test_with_fail_intercept(_name, test_case, nodes, route, payment_hash, callback_msg, |_|{}, callback_node, expected_retryable, expected_error_code, expected_channel_update); -} - -// test_case -// 0: node1 fails backward -// 1: final node fails backward -// 2: payment completed but the user rejects the payment -// 3: final node fails backward (but tamper onion payloads from node0) -// 100: trigger error in the intermediate node and tamper returning fail_htlc -// 200: trigger error in the final node and tamper returning fail_htlc -fn run_onion_failure_test_with_fail_intercept(_name: &str, test_case: u8, nodes: &Vec, route: &Route, payment_hash: &PaymentHash, mut callback_msg: F1, mut callback_fail: F2, mut callback_node: F3, expected_retryable: bool, expected_error_code: Option, expected_channel_update: Option) - where F1: for <'a> FnMut(&'a mut msgs::UpdateAddHTLC), - F2: for <'a> FnMut(&'a mut msgs::UpdateFailHTLC), - F3: FnMut(), -{ - - // reset block height - let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - for ix in 0..nodes.len() { - nodes[ix].block_notifier.block_connected_checked(&header, 1, &[], &[]); - } - - macro_rules! expect_event { - ($node: expr, $event_type: path) => {{ - let events = $node.node.get_and_clear_pending_events(); - assert_eq!(events.len(), 1); - match events[0] { - $event_type { .. } => {}, - _ => panic!("Unexpected event"), - } - }} - } - - macro_rules! expect_htlc_forward { - ($node: expr) => {{ - expect_event!($node, Event::PendingHTLCsForwardable); - $node.node.process_pending_htlc_forwards(); - }} - } - - // 0 ~~> 2 send payment - nodes[0].node.send_payment(&route, payment_hash.clone(), &None).unwrap(); - check_added_monitors!(nodes[0], 1); - let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id()); - // temper update_add (0 => 1) - let mut update_add_0 = update_0.update_add_htlcs[0].clone(); - if test_case == 0 || test_case == 3 || test_case == 100 { - callback_msg(&mut update_add_0); - callback_node(); - } - // 0 => 1 update_add & CS - nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_0); - commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true); - - let update_1_0 = match test_case { - 0|100 => { // intermediate node failure; fail backward to 0 - let update_1_0 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); - assert!(update_1_0.update_fail_htlcs.len()+update_1_0.update_fail_malformed_htlcs.len()==1 && (update_1_0.update_fail_htlcs.len()==1 || update_1_0.update_fail_malformed_htlcs.len()==1)); - update_1_0 - }, - 1|2|3|200 => { // final node failure; forwarding to 2 - assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); - // forwarding on 1 - if test_case != 200 { - callback_node(); - } - expect_htlc_forward!(&nodes[1]); - - let update_1 = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id()); - check_added_monitors!(&nodes[1], 1); - assert_eq!(update_1.update_add_htlcs.len(), 1); - // tamper update_add (1 => 2) - let mut update_add_1 = update_1.update_add_htlcs[0].clone(); - if test_case != 3 && test_case != 200 { - callback_msg(&mut update_add_1); - } - - // 1 => 2 - nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_1); - commitment_signed_dance!(nodes[2], nodes[1], update_1.commitment_signed, false, true); - - if test_case == 2 || test_case == 200 { - expect_htlc_forward!(&nodes[2]); - expect_event!(&nodes[2], Event::PaymentReceived); - callback_node(); - expect_pending_htlcs_forwardable!(nodes[2]); - } - - let update_2_1 = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id()); - if test_case == 2 || test_case == 200 { - check_added_monitors!(&nodes[2], 1); - } - assert!(update_2_1.update_fail_htlcs.len() == 1); - - let mut fail_msg = update_2_1.update_fail_htlcs[0].clone(); - if test_case == 200 { - callback_fail(&mut fail_msg); - } - - // 2 => 1 - nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &fail_msg); - commitment_signed_dance!(nodes[1], nodes[2], update_2_1.commitment_signed, true); - - // backward fail on 1 - let update_1_0 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); - assert!(update_1_0.update_fail_htlcs.len() == 1); - update_1_0 - }, - _ => unreachable!(), - }; - - // 1 => 0 commitment_signed_dance - if update_1_0.update_fail_htlcs.len() > 0 { - let mut fail_msg = update_1_0.update_fail_htlcs[0].clone(); - if test_case == 100 { - callback_fail(&mut fail_msg); - } - nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg); - } else { - nodes[0].node.handle_update_fail_malformed_htlc(&nodes[1].node.get_our_node_id(), &update_1_0.update_fail_malformed_htlcs[0]); - }; - - commitment_signed_dance!(nodes[0], nodes[1], update_1_0.commitment_signed, false, true); - - let events = nodes[0].node.get_and_clear_pending_events(); - assert_eq!(events.len(), 1); - if let &Event::PaymentFailed { payment_hash:_, ref rejected_by_dest, ref error_code, error_data: _ } = &events[0] { - assert_eq!(*rejected_by_dest, !expected_retryable); - assert_eq!(*error_code, expected_error_code); - } else { - panic!("Uexpected event"); - } - - let events = nodes[0].node.get_and_clear_pending_msg_events(); - if expected_channel_update.is_some() { - assert_eq!(events.len(), 1); - match events[0] { - MessageSendEvent::PaymentFailureNetworkUpdate { ref update } => { - match update { - &HTLCFailChannelUpdate::ChannelUpdateMessage { .. } => { - if let HTLCFailChannelUpdate::ChannelUpdateMessage { .. } = expected_channel_update.unwrap() {} else { - panic!("channel_update not found!"); - } - }, - &HTLCFailChannelUpdate::ChannelClosed { ref short_channel_id, ref is_permanent } => { - if let HTLCFailChannelUpdate::ChannelClosed { short_channel_id: ref expected_short_channel_id, is_permanent: ref expected_is_permanent } = expected_channel_update.unwrap() { - assert!(*short_channel_id == *expected_short_channel_id); - assert!(*is_permanent == *expected_is_permanent); - } else { - panic!("Unexpected message event"); - } - }, - &HTLCFailChannelUpdate::NodeFailure { ref node_id, ref is_permanent } => { - if let HTLCFailChannelUpdate::NodeFailure { node_id: ref expected_node_id, is_permanent: ref expected_is_permanent } = expected_channel_update.unwrap() { - assert!(*node_id == *expected_node_id); - assert!(*is_permanent == *expected_is_permanent); - } else { - panic!("Unexpected message event"); - } - }, - } - }, - _ => panic!("Unexpected message event"), - } - } else { - assert_eq!(events.len(), 0); - } -} - -impl msgs::ChannelUpdate { - fn dummy() -> msgs::ChannelUpdate { - use bitcoin::secp256k1::ffi::Signature as FFISignature; - use bitcoin::secp256k1::Signature; - msgs::ChannelUpdate { - signature: Signature::from(FFISignature::new()), - contents: msgs::UnsignedChannelUpdate { - chain_hash: BlockHash::hash(&vec![0u8][..]), - short_channel_id: 0, - timestamp: 0, - flags: 0, - cltv_expiry_delta: 0, - htlc_minimum_msat: 0, - htlc_maximum_msat: OptionalField::Absent, - fee_base_msat: 0, - fee_proportional_millionths: 0, - excess_data: vec![], - } - } - } -} - -struct BogusOnionHopData { - data: Vec -} -impl BogusOnionHopData { - fn new(orig: msgs::OnionHopData) -> Self { - Self { data: orig.encode() } - } -} -impl Writeable for BogusOnionHopData { - fn write(&self, writer: &mut W) -> Result<(), io::Error> { - writer.write_all(&self.data[..]) - } -} - -#[test] -fn test_onion_failure() { - use ln::msgs::ChannelUpdate; - use ln::channelmanager::CLTV_FAR_FAR_AWAY; - use bitcoin::secp256k1; - - const BADONION: u16 = 0x8000; - const PERM: u16 = 0x4000; - const NODE: u16 = 0x2000; - const UPDATE: u16 = 0x1000; - - let chanmon_cfgs = create_chanmon_cfgs(3); - let node_cfgs = create_node_cfgs(3, &chanmon_cfgs); - let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); - let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs); - for node in nodes.iter() { - *node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]); - } - let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()), create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known())]; - let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]); - let net_graph_msg_handler = &nodes[0].net_graph_msg_handler; - let logger = test_utils::TestLogger::new(); - let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, &Vec::new(), 40000, TEST_FINAL_CLTV, &logger).unwrap(); - // positve case - send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 40000, 40_000); - - // intermediate node failure - run_onion_failure_test("invalid_realm", 0, &nodes, &route, &payment_hash, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let cur_height = nodes[0].node.latest_block_height.load(Ordering::Acquire) as u32 + 1; - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - let (mut onion_payloads, _htlc_msat, _htlc_cltv) = onion_utils::build_onion_payloads(&route.paths[0], 40000, &None, cur_height).unwrap(); - let mut new_payloads = Vec::new(); - for payload in onion_payloads.drain(..) { - new_payloads.push(BogusOnionHopData::new(payload)); - } - // break the first (non-final) hop payload by swapping the realm (0) byte for a byte - // describing a length-1 TLV payload, which is obviously bogus. - new_payloads[0].data[0] = 1; - msg.onion_routing_packet = onion_utils::construct_onion_packet_bogus_hopdata(new_payloads, onion_keys, [0; 32], &payment_hash); - }, ||{}, true, Some(PERM|22), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true}));//XXX incremented channels idx here - - // final node failure - run_onion_failure_test("invalid_realm", 3, &nodes, &route, &payment_hash, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let cur_height = nodes[0].node.latest_block_height.load(Ordering::Acquire) as u32 + 1; - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - let (mut onion_payloads, _htlc_msat, _htlc_cltv) = onion_utils::build_onion_payloads(&route.paths[0], 40000, &None, cur_height).unwrap(); - let mut new_payloads = Vec::new(); - for payload in onion_payloads.drain(..) { - new_payloads.push(BogusOnionHopData::new(payload)); - } - // break the last-hop payload by swapping the realm (0) byte for a byte describing a - // length-1 TLV payload, which is obviously bogus. - new_payloads[1].data[0] = 1; - msg.onion_routing_packet = onion_utils::construct_onion_packet_bogus_hopdata(new_payloads, onion_keys, [0; 32], &payment_hash); - }, ||{}, false, Some(PERM|22), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true})); - - // the following three with run_onion_failure_test_with_fail_intercept() test only the origin node - // receiving simulated fail messages - // intermediate node failure - run_onion_failure_test_with_fail_intercept("temporary_node_failure", 100, &nodes, &route, &payment_hash, |msg| { - // trigger error - msg.amount_msat -= 1; - }, |msg| { - // and tamper returning error message - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], NODE|2, &[0;0]); - }, ||{}, true, Some(NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: false})); - - // final node failure - run_onion_failure_test_with_fail_intercept("temporary_node_failure", 200, &nodes, &route, &payment_hash, |_msg| {}, |msg| { - // and tamper returning error message - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], NODE|2, &[0;0]); - }, ||{ - nodes[2].node.fail_htlc_backwards(&payment_hash, &None); - }, true, Some(NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: false})); - - // intermediate node failure - run_onion_failure_test_with_fail_intercept("permanent_node_failure", 100, &nodes, &route, &payment_hash, |msg| { - msg.amount_msat -= 1; - }, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|NODE|2, &[0;0]); - }, ||{}, true, Some(PERM|NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: true})); - - // final node failure - run_onion_failure_test_with_fail_intercept("permanent_node_failure", 200, &nodes, &route, &payment_hash, |_msg| {}, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], PERM|NODE|2, &[0;0]); - }, ||{ - nodes[2].node.fail_htlc_backwards(&payment_hash, &None); - }, false, Some(PERM|NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: true})); - - // intermediate node failure - run_onion_failure_test_with_fail_intercept("required_node_feature_missing", 100, &nodes, &route, &payment_hash, |msg| { - msg.amount_msat -= 1; - }, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|NODE|3, &[0;0]); - }, ||{ - nodes[2].node.fail_htlc_backwards(&payment_hash, &None); - }, true, Some(PERM|NODE|3), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: true})); - - // final node failure - run_onion_failure_test_with_fail_intercept("required_node_feature_missing", 200, &nodes, &route, &payment_hash, |_msg| {}, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], PERM|NODE|3, &[0;0]); - }, ||{ - nodes[2].node.fail_htlc_backwards(&payment_hash, &None); - }, false, Some(PERM|NODE|3), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: true})); - - run_onion_failure_test("invalid_onion_version", 0, &nodes, &route, &payment_hash, |msg| { msg.onion_routing_packet.version = 1; }, ||{}, true, - Some(BADONION|PERM|4), None); - - run_onion_failure_test("invalid_onion_hmac", 0, &nodes, &route, &payment_hash, |msg| { msg.onion_routing_packet.hmac = [3; 32]; }, ||{}, true, - Some(BADONION|PERM|5), None); - - run_onion_failure_test("invalid_onion_key", 0, &nodes, &route, &payment_hash, |msg| { msg.onion_routing_packet.public_key = Err(secp256k1::Error::InvalidPublicKey);}, ||{}, true, - Some(BADONION|PERM|6), None); - - run_onion_failure_test_with_fail_intercept("temporary_channel_failure", 100, &nodes, &route, &payment_hash, |msg| { - msg.amount_msat -= 1; - }, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], UPDATE|7, &ChannelUpdate::dummy().encode_with_len()[..]); - }, ||{}, true, Some(UPDATE|7), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); - - run_onion_failure_test_with_fail_intercept("permanent_channel_failure", 100, &nodes, &route, &payment_hash, |msg| { - msg.amount_msat -= 1; - }, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|8, &[0;0]); - // short_channel_id from the processing node - }, ||{}, true, Some(PERM|8), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true})); - - run_onion_failure_test_with_fail_intercept("required_channel_feature_missing", 100, &nodes, &route, &payment_hash, |msg| { - msg.amount_msat -= 1; - }, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|9, &[0;0]); - // short_channel_id from the processing node - }, ||{}, true, Some(PERM|9), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true})); - - let mut bogus_route = route.clone(); - bogus_route.paths[0][1].short_channel_id -= 1; - run_onion_failure_test("unknown_next_peer", 0, &nodes, &bogus_route, &payment_hash, |_| {}, ||{}, true, Some(PERM|10), - Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: bogus_route.paths[0][1].short_channel_id, is_permanent:true})); - - let amt_to_forward = nodes[1].node.channel_state.lock().unwrap().by_id.get(&channels[1].2).unwrap().get_counterparty_htlc_minimum_msat() - 1; - let mut bogus_route = route.clone(); - let route_len = bogus_route.paths[0].len(); - bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward; - run_onion_failure_test("amount_below_minimum", 0, &nodes, &bogus_route, &payment_hash, |_| {}, ||{}, true, Some(UPDATE|11), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); - - //TODO: with new config API, we will be able to generate both valid and - //invalid channel_update cases. - run_onion_failure_test("fee_insufficient", 0, &nodes, &route, &payment_hash, |msg| { - msg.amount_msat -= 1; - }, || {}, true, Some(UPDATE|12), Some(msgs::HTLCFailChannelUpdate::ChannelClosed { short_channel_id: channels[0].0.contents.short_channel_id, is_permanent: true})); - - run_onion_failure_test("incorrect_cltv_expiry", 0, &nodes, &route, &payment_hash, |msg| { - // need to violate: cltv_expiry - cltv_expiry_delta >= outgoing_cltv_value - msg.cltv_expiry -= 1; - }, || {}, true, Some(UPDATE|13), Some(msgs::HTLCFailChannelUpdate::ChannelClosed { short_channel_id: channels[0].0.contents.short_channel_id, is_permanent: true})); - - run_onion_failure_test("expiry_too_soon", 0, &nodes, &route, &payment_hash, |msg| { - let height = msg.cltv_expiry - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS + 1; - let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - - nodes[1].block_notifier.block_connected_checked(&header, height, &[], &[]); - }, ||{}, true, Some(UPDATE|14), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); - - run_onion_failure_test("unknown_payment_hash", 2, &nodes, &route, &payment_hash, |_| {}, || { - nodes[2].node.fail_htlc_backwards(&payment_hash, &None); - }, false, Some(PERM|15), None); - - run_onion_failure_test("final_expiry_too_soon", 1, &nodes, &route, &payment_hash, |msg| { - let height = msg.cltv_expiry - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS + 1; - let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - - nodes[2].block_notifier.block_connected_checked(&header, height, &[], &[]); - }, || {}, true, Some(17), None); - - run_onion_failure_test("final_incorrect_cltv_expiry", 1, &nodes, &route, &payment_hash, |_| {}, || { - for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { - for f in pending_forwards.iter_mut() { - match f { - &mut HTLCForwardInfo::AddHTLC { ref mut forward_info, .. } => - forward_info.outgoing_cltv_value += 1, - _ => {}, - } - } - } - }, true, Some(18), None); - - run_onion_failure_test("final_incorrect_htlc_amount", 1, &nodes, &route, &payment_hash, |_| {}, || { - // violate amt_to_forward > msg.amount_msat - for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { - for f in pending_forwards.iter_mut() { - match f { - &mut HTLCForwardInfo::AddHTLC { ref mut forward_info, .. } => - forward_info.amt_to_forward -= 1, - _ => {}, - } - } - } - }, true, Some(19), None); - - run_onion_failure_test("channel_disabled", 0, &nodes, &route, &payment_hash, |_| {}, || { - // disconnect event to the channel between nodes[1] ~ nodes[2] - nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id(), false); - nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false); - }, true, Some(UPDATE|20), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); - reconnect_nodes(&nodes[1], &nodes[2], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (false, false)); - - run_onion_failure_test("expiry_too_far", 0, &nodes, &route, &payment_hash, |msg| { - let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); - let mut route = route.clone(); - let height = 1; - route.paths[0][1].cltv_expiry_delta += CLTV_FAR_FAR_AWAY + route.paths[0][0].cltv_expiry_delta + 1; - let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); - let (onion_payloads, _, htlc_cltv) = onion_utils::build_onion_payloads(&route.paths[0], 40000, &None, height).unwrap(); - let onion_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys, [0; 32], &payment_hash); - msg.cltv_expiry = htlc_cltv; - msg.onion_routing_packet = onion_packet; - }, ||{}, true, Some(21), None); -} - #[test] #[should_panic] fn bolt2_open_channel_sending_node_checks_part1() { //This test needs to be on its own as we are catching a panic diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs index b0c0283cb01..9bb8438f200 100644 --- a/lightning/src/ln/mod.rs +++ b/lightning/src/ln/mod.rs @@ -50,5 +50,8 @@ mod functional_tests; mod chanmon_update_fail_tests; #[cfg(test)] mod reorg_tests; +#[cfg(test)] +#[allow(unused_mut)] +mod onion_route_tests; pub use self::peer_channel_encryptor::LN_MAX_MSG_LEN; diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs new file mode 100644 index 00000000000..9a91efa4980 --- /dev/null +++ b/lightning/src/ln/onion_route_tests.rs @@ -0,0 +1,488 @@ +// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. + +//! Tests of the onion error messages/codes which are returned when routing a payment fails. +//! These tests work by standing up full nodes and route payments across the network, checking the +//! returned errors decode to the correct thing. + +use ln::channelmanager::{HTLCForwardInfo, PaymentPreimage, PaymentHash}; +use ln::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS}; +use ln::onion_utils; +use routing::router::{Route, get_route}; +use ln::features::InitFeatures; +use ln::msgs; +use ln::msgs::{ChannelMessageHandler, HTLCFailChannelUpdate, OptionalField}; +use util::test_utils; +use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider}; +use util::ser::{Writeable, Writer}; + +use bitcoin::blockdata::block::BlockHeader; +use bitcoin::hash_types::BlockHash; + +use bitcoin::hashes::sha256::Hash as Sha256; +use bitcoin::hashes::Hash; + +use bitcoin::secp256k1::Secp256k1; +use bitcoin::secp256k1::key::SecretKey; + +use std::default::Default; +use std::sync::atomic::Ordering; +use std::io; + +use ln::functional_test_utils::*; + +fn run_onion_failure_test(_name: &str, test_case: u8, nodes: &Vec, route: &Route, payment_hash: &PaymentHash, callback_msg: F1, callback_node: F2, expected_retryable: bool, expected_error_code: Option, expected_channel_update: Option) + where F1: for <'a> FnMut(&'a mut msgs::UpdateAddHTLC), + F2: FnMut(), +{ + run_onion_failure_test_with_fail_intercept(_name, test_case, nodes, route, payment_hash, callback_msg, |_|{}, callback_node, expected_retryable, expected_error_code, expected_channel_update); +} + +// test_case +// 0: node1 fails backward +// 1: final node fails backward +// 2: payment completed but the user rejects the payment +// 3: final node fails backward (but tamper onion payloads from node0) +// 100: trigger error in the intermediate node and tamper returning fail_htlc +// 200: trigger error in the final node and tamper returning fail_htlc +fn run_onion_failure_test_with_fail_intercept(_name: &str, test_case: u8, nodes: &Vec, route: &Route, payment_hash: &PaymentHash, mut callback_msg: F1, mut callback_fail: F2, mut callback_node: F3, expected_retryable: bool, expected_error_code: Option, expected_channel_update: Option) + where F1: for <'a> FnMut(&'a mut msgs::UpdateAddHTLC), + F2: for <'a> FnMut(&'a mut msgs::UpdateFailHTLC), + F3: FnMut(), +{ + + // reset block height + let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; + for ix in 0..nodes.len() { + nodes[ix].block_notifier.block_connected_checked(&header, 1, &[], &[]); + } + + macro_rules! expect_event { + ($node: expr, $event_type: path) => {{ + let events = $node.node.get_and_clear_pending_events(); + assert_eq!(events.len(), 1); + match events[0] { + $event_type { .. } => {}, + _ => panic!("Unexpected event"), + } + }} + } + + macro_rules! expect_htlc_forward { + ($node: expr) => {{ + expect_event!($node, Event::PendingHTLCsForwardable); + $node.node.process_pending_htlc_forwards(); + }} + } + + // 0 ~~> 2 send payment + nodes[0].node.send_payment(&route, payment_hash.clone(), &None).unwrap(); + check_added_monitors!(nodes[0], 1); + let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id()); + // temper update_add (0 => 1) + let mut update_add_0 = update_0.update_add_htlcs[0].clone(); + if test_case == 0 || test_case == 3 || test_case == 100 { + callback_msg(&mut update_add_0); + callback_node(); + } + // 0 => 1 update_add & CS + nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &update_add_0); + commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true); + + let update_1_0 = match test_case { + 0|100 => { // intermediate node failure; fail backward to 0 + let update_1_0 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); + assert!(update_1_0.update_fail_htlcs.len()+update_1_0.update_fail_malformed_htlcs.len()==1 && (update_1_0.update_fail_htlcs.len()==1 || update_1_0.update_fail_malformed_htlcs.len()==1)); + update_1_0 + }, + 1|2|3|200 => { // final node failure; forwarding to 2 + assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); + // forwarding on 1 + if test_case != 200 { + callback_node(); + } + expect_htlc_forward!(&nodes[1]); + + let update_1 = get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id()); + check_added_monitors!(&nodes[1], 1); + assert_eq!(update_1.update_add_htlcs.len(), 1); + // tamper update_add (1 => 2) + let mut update_add_1 = update_1.update_add_htlcs[0].clone(); + if test_case != 3 && test_case != 200 { + callback_msg(&mut update_add_1); + } + + // 1 => 2 + nodes[2].node.handle_update_add_htlc(&nodes[1].node.get_our_node_id(), &update_add_1); + commitment_signed_dance!(nodes[2], nodes[1], update_1.commitment_signed, false, true); + + if test_case == 2 || test_case == 200 { + expect_htlc_forward!(&nodes[2]); + expect_event!(&nodes[2], Event::PaymentReceived); + callback_node(); + expect_pending_htlcs_forwardable!(nodes[2]); + } + + let update_2_1 = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id()); + if test_case == 2 || test_case == 200 { + check_added_monitors!(&nodes[2], 1); + } + assert!(update_2_1.update_fail_htlcs.len() == 1); + + let mut fail_msg = update_2_1.update_fail_htlcs[0].clone(); + if test_case == 200 { + callback_fail(&mut fail_msg); + } + + // 2 => 1 + nodes[1].node.handle_update_fail_htlc(&nodes[2].node.get_our_node_id(), &fail_msg); + commitment_signed_dance!(nodes[1], nodes[2], update_2_1.commitment_signed, true); + + // backward fail on 1 + let update_1_0 = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); + assert!(update_1_0.update_fail_htlcs.len() == 1); + update_1_0 + }, + _ => unreachable!(), + }; + + // 1 => 0 commitment_signed_dance + if update_1_0.update_fail_htlcs.len() > 0 { + let mut fail_msg = update_1_0.update_fail_htlcs[0].clone(); + if test_case == 100 { + callback_fail(&mut fail_msg); + } + nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &fail_msg); + } else { + nodes[0].node.handle_update_fail_malformed_htlc(&nodes[1].node.get_our_node_id(), &update_1_0.update_fail_malformed_htlcs[0]); + }; + + commitment_signed_dance!(nodes[0], nodes[1], update_1_0.commitment_signed, false, true); + + let events = nodes[0].node.get_and_clear_pending_events(); + assert_eq!(events.len(), 1); + if let &Event::PaymentFailed { payment_hash:_, ref rejected_by_dest, ref error_code, error_data: _ } = &events[0] { + assert_eq!(*rejected_by_dest, !expected_retryable); + assert_eq!(*error_code, expected_error_code); + } else { + panic!("Uexpected event"); + } + + let events = nodes[0].node.get_and_clear_pending_msg_events(); + if expected_channel_update.is_some() { + assert_eq!(events.len(), 1); + match events[0] { + MessageSendEvent::PaymentFailureNetworkUpdate { ref update } => { + match update { + &HTLCFailChannelUpdate::ChannelUpdateMessage { .. } => { + if let HTLCFailChannelUpdate::ChannelUpdateMessage { .. } = expected_channel_update.unwrap() {} else { + panic!("channel_update not found!"); + } + }, + &HTLCFailChannelUpdate::ChannelClosed { ref short_channel_id, ref is_permanent } => { + if let HTLCFailChannelUpdate::ChannelClosed { short_channel_id: ref expected_short_channel_id, is_permanent: ref expected_is_permanent } = expected_channel_update.unwrap() { + assert!(*short_channel_id == *expected_short_channel_id); + assert!(*is_permanent == *expected_is_permanent); + } else { + panic!("Unexpected message event"); + } + }, + &HTLCFailChannelUpdate::NodeFailure { ref node_id, ref is_permanent } => { + if let HTLCFailChannelUpdate::NodeFailure { node_id: ref expected_node_id, is_permanent: ref expected_is_permanent } = expected_channel_update.unwrap() { + assert!(*node_id == *expected_node_id); + assert!(*is_permanent == *expected_is_permanent); + } else { + panic!("Unexpected message event"); + } + }, + } + }, + _ => panic!("Unexpected message event"), + } + } else { + assert_eq!(events.len(), 0); + } +} + +impl msgs::ChannelUpdate { + fn dummy() -> msgs::ChannelUpdate { + use bitcoin::secp256k1::ffi::Signature as FFISignature; + use bitcoin::secp256k1::Signature; + msgs::ChannelUpdate { + signature: Signature::from(FFISignature::new()), + contents: msgs::UnsignedChannelUpdate { + chain_hash: BlockHash::hash(&vec![0u8][..]), + short_channel_id: 0, + timestamp: 0, + flags: 0, + cltv_expiry_delta: 0, + htlc_minimum_msat: 0, + htlc_maximum_msat: OptionalField::Absent, + fee_base_msat: 0, + fee_proportional_millionths: 0, + excess_data: vec![], + } + } + } +} + +struct BogusOnionHopData { + data: Vec +} +impl BogusOnionHopData { + fn new(orig: msgs::OnionHopData) -> Self { + Self { data: orig.encode() } + } +} +impl Writeable for BogusOnionHopData { + fn write(&self, writer: &mut W) -> Result<(), io::Error> { + writer.write_all(&self.data[..]) + } +} + +#[test] +fn test_onion_failure() { + use ln::msgs::ChannelUpdate; + use ln::channelmanager::CLTV_FAR_FAR_AWAY; + use bitcoin::secp256k1; + + const BADONION: u16 = 0x8000; + const PERM: u16 = 0x4000; + const NODE: u16 = 0x2000; + const UPDATE: u16 = 0x1000; + + let chanmon_cfgs = create_chanmon_cfgs(3); + let node_cfgs = create_node_cfgs(3, &chanmon_cfgs); + let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); + let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs); + for node in nodes.iter() { + *node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]); + } + let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()), create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known())]; + let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]); + let net_graph_msg_handler = &nodes[0].net_graph_msg_handler; + let logger = test_utils::TestLogger::new(); + let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, &Vec::new(), 40000, TEST_FINAL_CLTV, &logger).unwrap(); + // positve case + send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 40000, 40_000); + + // intermediate node failure + run_onion_failure_test("invalid_realm", 0, &nodes, &route, &payment_hash, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let cur_height = nodes[0].node.latest_block_height.load(Ordering::Acquire) as u32 + 1; + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + let (mut onion_payloads, _htlc_msat, _htlc_cltv) = onion_utils::build_onion_payloads(&route.paths[0], 40000, &None, cur_height).unwrap(); + let mut new_payloads = Vec::new(); + for payload in onion_payloads.drain(..) { + new_payloads.push(BogusOnionHopData::new(payload)); + } + // break the first (non-final) hop payload by swapping the realm (0) byte for a byte + // describing a length-1 TLV payload, which is obviously bogus. + new_payloads[0].data[0] = 1; + msg.onion_routing_packet = onion_utils::construct_onion_packet_bogus_hopdata(new_payloads, onion_keys, [0; 32], &payment_hash); + }, ||{}, true, Some(PERM|22), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true}));//XXX incremented channels idx here + + // final node failure + run_onion_failure_test("invalid_realm", 3, &nodes, &route, &payment_hash, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let cur_height = nodes[0].node.latest_block_height.load(Ordering::Acquire) as u32 + 1; + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + let (mut onion_payloads, _htlc_msat, _htlc_cltv) = onion_utils::build_onion_payloads(&route.paths[0], 40000, &None, cur_height).unwrap(); + let mut new_payloads = Vec::new(); + for payload in onion_payloads.drain(..) { + new_payloads.push(BogusOnionHopData::new(payload)); + } + // break the last-hop payload by swapping the realm (0) byte for a byte describing a + // length-1 TLV payload, which is obviously bogus. + new_payloads[1].data[0] = 1; + msg.onion_routing_packet = onion_utils::construct_onion_packet_bogus_hopdata(new_payloads, onion_keys, [0; 32], &payment_hash); + }, ||{}, false, Some(PERM|22), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true})); + + // the following three with run_onion_failure_test_with_fail_intercept() test only the origin node + // receiving simulated fail messages + // intermediate node failure + run_onion_failure_test_with_fail_intercept("temporary_node_failure", 100, &nodes, &route, &payment_hash, |msg| { + // trigger error + msg.amount_msat -= 1; + }, |msg| { + // and tamper returning error message + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], NODE|2, &[0;0]); + }, ||{}, true, Some(NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: false})); + + // final node failure + run_onion_failure_test_with_fail_intercept("temporary_node_failure", 200, &nodes, &route, &payment_hash, |_msg| {}, |msg| { + // and tamper returning error message + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], NODE|2, &[0;0]); + }, ||{ + nodes[2].node.fail_htlc_backwards(&payment_hash, &None); + }, true, Some(NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: false})); + + // intermediate node failure + run_onion_failure_test_with_fail_intercept("permanent_node_failure", 100, &nodes, &route, &payment_hash, |msg| { + msg.amount_msat -= 1; + }, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|NODE|2, &[0;0]); + }, ||{}, true, Some(PERM|NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: true})); + + // final node failure + run_onion_failure_test_with_fail_intercept("permanent_node_failure", 200, &nodes, &route, &payment_hash, |_msg| {}, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], PERM|NODE|2, &[0;0]); + }, ||{ + nodes[2].node.fail_htlc_backwards(&payment_hash, &None); + }, false, Some(PERM|NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: true})); + + // intermediate node failure + run_onion_failure_test_with_fail_intercept("required_node_feature_missing", 100, &nodes, &route, &payment_hash, |msg| { + msg.amount_msat -= 1; + }, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|NODE|3, &[0;0]); + }, ||{ + nodes[2].node.fail_htlc_backwards(&payment_hash, &None); + }, true, Some(PERM|NODE|3), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: true})); + + // final node failure + run_onion_failure_test_with_fail_intercept("required_node_feature_missing", 200, &nodes, &route, &payment_hash, |_msg| {}, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], PERM|NODE|3, &[0;0]); + }, ||{ + nodes[2].node.fail_htlc_backwards(&payment_hash, &None); + }, false, Some(PERM|NODE|3), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: true})); + + run_onion_failure_test("invalid_onion_version", 0, &nodes, &route, &payment_hash, |msg| { msg.onion_routing_packet.version = 1; }, ||{}, true, + Some(BADONION|PERM|4), None); + + run_onion_failure_test("invalid_onion_hmac", 0, &nodes, &route, &payment_hash, |msg| { msg.onion_routing_packet.hmac = [3; 32]; }, ||{}, true, + Some(BADONION|PERM|5), None); + + run_onion_failure_test("invalid_onion_key", 0, &nodes, &route, &payment_hash, |msg| { msg.onion_routing_packet.public_key = Err(secp256k1::Error::InvalidPublicKey);}, ||{}, true, + Some(BADONION|PERM|6), None); + + run_onion_failure_test_with_fail_intercept("temporary_channel_failure", 100, &nodes, &route, &payment_hash, |msg| { + msg.amount_msat -= 1; + }, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], UPDATE|7, &ChannelUpdate::dummy().encode_with_len()[..]); + }, ||{}, true, Some(UPDATE|7), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); + + run_onion_failure_test_with_fail_intercept("permanent_channel_failure", 100, &nodes, &route, &payment_hash, |msg| { + msg.amount_msat -= 1; + }, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|8, &[0;0]); + // short_channel_id from the processing node + }, ||{}, true, Some(PERM|8), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true})); + + run_onion_failure_test_with_fail_intercept("required_channel_feature_missing", 100, &nodes, &route, &payment_hash, |msg| { + msg.amount_msat -= 1; + }, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|9, &[0;0]); + // short_channel_id from the processing node + }, ||{}, true, Some(PERM|9), Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: channels[1].0.contents.short_channel_id, is_permanent: true})); + + let mut bogus_route = route.clone(); + bogus_route.paths[0][1].short_channel_id -= 1; + run_onion_failure_test("unknown_next_peer", 0, &nodes, &bogus_route, &payment_hash, |_| {}, ||{}, true, Some(PERM|10), + Some(msgs::HTLCFailChannelUpdate::ChannelClosed{short_channel_id: bogus_route.paths[0][1].short_channel_id, is_permanent:true})); + + let amt_to_forward = nodes[1].node.channel_state.lock().unwrap().by_id.get(&channels[1].2).unwrap().get_counterparty_htlc_minimum_msat() - 1; + let mut bogus_route = route.clone(); + let route_len = bogus_route.paths[0].len(); + bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward; + run_onion_failure_test("amount_below_minimum", 0, &nodes, &bogus_route, &payment_hash, |_| {}, ||{}, true, Some(UPDATE|11), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); + + //TODO: with new config API, we will be able to generate both valid and + //invalid channel_update cases. + run_onion_failure_test("fee_insufficient", 0, &nodes, &route, &payment_hash, |msg| { + msg.amount_msat -= 1; + }, || {}, true, Some(UPDATE|12), Some(msgs::HTLCFailChannelUpdate::ChannelClosed { short_channel_id: channels[0].0.contents.short_channel_id, is_permanent: true})); + + run_onion_failure_test("incorrect_cltv_expiry", 0, &nodes, &route, &payment_hash, |msg| { + // need to violate: cltv_expiry - cltv_expiry_delta >= outgoing_cltv_value + msg.cltv_expiry -= 1; + }, || {}, true, Some(UPDATE|13), Some(msgs::HTLCFailChannelUpdate::ChannelClosed { short_channel_id: channels[0].0.contents.short_channel_id, is_permanent: true})); + + run_onion_failure_test("expiry_too_soon", 0, &nodes, &route, &payment_hash, |msg| { + let height = msg.cltv_expiry - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS + 1; + let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; + + nodes[1].block_notifier.block_connected_checked(&header, height, &[], &[]); + }, ||{}, true, Some(UPDATE|14), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); + + run_onion_failure_test("unknown_payment_hash", 2, &nodes, &route, &payment_hash, |_| {}, || { + nodes[2].node.fail_htlc_backwards(&payment_hash, &None); + }, false, Some(PERM|15), None); + + run_onion_failure_test("final_expiry_too_soon", 1, &nodes, &route, &payment_hash, |msg| { + let height = msg.cltv_expiry - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS + 1; + let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; + + nodes[2].block_notifier.block_connected_checked(&header, height, &[], &[]); + }, || {}, true, Some(17), None); + + run_onion_failure_test("final_incorrect_cltv_expiry", 1, &nodes, &route, &payment_hash, |_| {}, || { + for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { + for f in pending_forwards.iter_mut() { + match f { + &mut HTLCForwardInfo::AddHTLC { ref mut forward_info, .. } => + forward_info.outgoing_cltv_value += 1, + _ => {}, + } + } + } + }, true, Some(18), None); + + run_onion_failure_test("final_incorrect_htlc_amount", 1, &nodes, &route, &payment_hash, |_| {}, || { + // violate amt_to_forward > msg.amount_msat + for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { + for f in pending_forwards.iter_mut() { + match f { + &mut HTLCForwardInfo::AddHTLC { ref mut forward_info, .. } => + forward_info.amt_to_forward -= 1, + _ => {}, + } + } + } + }, true, Some(19), None); + + run_onion_failure_test("channel_disabled", 0, &nodes, &route, &payment_hash, |_| {}, || { + // disconnect event to the channel between nodes[1] ~ nodes[2] + nodes[1].node.peer_disconnected(&nodes[2].node.get_our_node_id(), false); + nodes[2].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false); + }, true, Some(UPDATE|20), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); + reconnect_nodes(&nodes[1], &nodes[2], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (false, false)); + + run_onion_failure_test("expiry_too_far", 0, &nodes, &route, &payment_hash, |msg| { + let session_priv = SecretKey::from_slice(&[3; 32]).unwrap(); + let mut route = route.clone(); + let height = 1; + route.paths[0][1].cltv_expiry_delta += CLTV_FAR_FAR_AWAY + route.paths[0][0].cltv_expiry_delta + 1; + let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap(); + let (onion_payloads, _, htlc_cltv) = onion_utils::build_onion_payloads(&route.paths[0], 40000, &None, height).unwrap(); + let onion_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys, [0; 32], &payment_hash); + msg.cltv_expiry = htlc_cltv; + msg.onion_routing_packet = onion_packet; + }, ||{}, true, Some(21), None); +} + + From 0f6b0004c490855ad88ce1bb545268eb6561fdc2 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 14 Sep 2020 17:39:42 -0400 Subject: [PATCH 4/4] Fix two bugs which access the wrong peer's htlc_minimum_msat value * Channel::get_counterparty_htlc_minimum_msat() returned holder_htlc_minimum_msat, which was obviously incorrect. * ChannelManager::get_channel_update set htlc_minimum_msat to Channel::get_holder_htlc_minimum_msat(), but the spec explicitly states we "MUST set htlc_minimum_msat to the minimum HTLC value (in millisatoshi) that the channel peer will accept." This makes sense because the reason we're rejecting the HTLC is because our counterparty's HTLC minimum value is too small for us to send to them, our own HTLC minimum value plays no role. Further, our router already expects this - looking at the same directional channel info as it does fees. Finally, we add a test in the existing onion router test cases which fails if either of the above is incorrect (the second issue discovered in the process of writing the test). --- lightning/src/ln/channel.rs | 3 ++- lightning/src/ln/channelmanager.rs | 2 +- lightning/src/ln/onion_route_tests.rs | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 2699e461806..dd9170b47e7 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -3125,6 +3125,7 @@ impl Channel { } /// Allowed in any state (including after shutdown) + #[cfg(test)] pub fn get_holder_htlc_minimum_msat(&self) -> u64 { self.holder_htlc_minimum_msat } @@ -3143,7 +3144,7 @@ impl Channel { /// Allowed in any state (including after shutdown) pub fn get_counterparty_htlc_minimum_msat(&self) -> u64 { - self.holder_htlc_minimum_msat + self.counterparty_htlc_minimum_msat } pub fn get_value_satoshis(&self) -> u64 { diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index cc15861f877..59d513b3968 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -1228,7 +1228,7 @@ impl timestamp: chan.get_update_time_counter(), flags: (!were_node_one) as u8 | ((!chan.is_live() as u8) << 1), cltv_expiry_delta: CLTV_EXPIRY_DELTA, - htlc_minimum_msat: chan.get_holder_htlc_minimum_msat(), + htlc_minimum_msat: chan.get_counterparty_htlc_minimum_msat(), htlc_maximum_msat: OptionalField::Present(chan.get_announced_htlc_max_msat()), fee_base_msat: chan.get_holder_fee_base_msat(&self.fee_estimator), fee_proportional_millionths: chan.get_fee_proportional_millionths(), diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 9a91efa4980..3db4c4d52f1 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -21,6 +21,7 @@ use ln::msgs::{ChannelMessageHandler, HTLCFailChannelUpdate, OptionalField}; use util::test_utils; use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider}; use util::ser::{Writeable, Writer}; +use util::config::UserConfig; use bitcoin::blockdata::block::BlockHeader; use bitcoin::hash_types::BlockHash; @@ -257,9 +258,19 @@ fn test_onion_failure() { const NODE: u16 = 0x2000; const UPDATE: u16 = 0x1000; + // When we check for amount_below_minimum below, we want to test that we're using the *right* + // amount, thus we need different htlc_minimum_msat values. We set node[2]'s htlc_minimum_msat + // to 2000, which is above the default value of 1000 set in create_node_chanmgrs. + // This exposed a previous bug because we were using the wrong value all the way down in + // Channel::get_counterparty_htlc_minimum_msat(). + let mut node_2_cfg: UserConfig = Default::default(); + node_2_cfg.own_channel_config.our_htlc_minimum_msat = 2000; + node_2_cfg.channel_options.announced_channel = true; + node_2_cfg.peer_channel_config_limits.force_announced_channel_preference = false; + let chanmon_cfgs = create_chanmon_cfgs(3); let node_cfgs = create_node_cfgs(3, &chanmon_cfgs); - let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); + let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, Some(node_2_cfg)]); let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs); for node in nodes.iter() { *node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]); @@ -411,6 +422,11 @@ fn test_onion_failure() { bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward; run_onion_failure_test("amount_below_minimum", 0, &nodes, &bogus_route, &payment_hash, |_| {}, ||{}, true, Some(UPDATE|11), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); + // Test a positive test-case with one extra msat, meeting the minimum. + bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward + 1; + let (preimage, _) = send_along_route(&nodes[0], bogus_route, &[&nodes[1], &nodes[2]], amt_to_forward+1); + claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], preimage, amt_to_forward+1); + //TODO: with new config API, we will be able to generate both valid and //invalid channel_update cases. run_onion_failure_test("fee_insufficient", 0, &nodes, &route, &payment_hash, |msg| {