From 30a42f45973c9994f177f12fa7215a65fc09c226 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 2 Feb 2021 16:53:33 -0500 Subject: [PATCH] Update auto-generated bindings, including bumping cbindgen version --- lightning-c-bindings/include/lightning.h | 3079 ++++++++++------- lightning-c-bindings/include/lightningpp.hpp | 234 +- lightning-c-bindings/include/rust_types.h | 14 +- lightning-c-bindings/src/c_types/derived.rs | 108 +- .../src/chain/chainmonitor.rs | 26 +- .../src/chain/channelmonitor.rs | 28 +- .../src/chain/keysinterface.rs | 225 +- lightning-c-bindings/src/chain/mod.rs | 10 +- lightning-c-bindings/src/chain/transaction.rs | 6 +- lightning-c-bindings/src/ln/chan_utils.rs | 910 ++++- lightning-c-bindings/src/ln/channelmanager.rs | 69 +- lightning-c-bindings/src/ln/features.rs | 6 +- lightning-c-bindings/src/ln/msgs.rs | 317 +- lightning-c-bindings/src/ln/peer_handler.rs | 20 +- .../src/routing/network_graph.rs | 169 +- lightning-c-bindings/src/routing/router.rs | 26 +- lightning-c-bindings/src/util/config.rs | 24 +- lightning-c-bindings/src/util/events.rs | 131 +- lightning-c-bindings/src/util/ser.rs | 3 + 19 files changed, 3455 insertions(+), 1950 deletions(-) diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 615480226..ca86c4a91 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -1,6 +1,6 @@ /* Text to put at the beginning of the generated file. Probably a license. */ -/* Generated with cbindgen:0.14.4 */ +/* Generated with cbindgen:0.16.0 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -211,7 +211,7 @@ typedef struct LDKCVecTempl_u8 { uintptr_t datalen; } LDKCVecTempl_u8; -typedef LDKCVecTempl_u8 LDKCVec_u8Z; +typedef struct LDKCVecTempl_u8 LDKCVec_u8Z; /** * A transaction output including a scriptPubKey and value. @@ -224,22 +224,22 @@ typedef struct LDKTxOut { typedef struct LDKC2TupleTempl_usize__Transaction { uintptr_t a; - LDKTransaction b; + struct LDKTransaction b; } LDKC2TupleTempl_usize__Transaction; -typedef LDKC2TupleTempl_usize__Transaction LDKC2Tuple_usizeTransactionZ; +typedef struct LDKC2TupleTempl_usize__Transaction LDKC2Tuple_usizeTransactionZ; typedef union LDKCResultPtr_u8__ChannelMonitorUpdateErr { uint8_t *result; - LDKChannelMonitorUpdateErr *err; + enum LDKChannelMonitorUpdateErr *err; } LDKCResultPtr_u8__ChannelMonitorUpdateErr; typedef struct LDKCResultTempl_u8__ChannelMonitorUpdateErr { - LDKCResultPtr_u8__ChannelMonitorUpdateErr contents; + union LDKCResultPtr_u8__ChannelMonitorUpdateErr contents; bool result_ok; } LDKCResultTempl_u8__ChannelMonitorUpdateErr; -typedef LDKCResultTempl_u8__ChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ; +typedef struct LDKCResultTempl_u8__ChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ; @@ -261,15 +261,15 @@ typedef struct MUST_USE_STRUCT LDKMonitorUpdateError { typedef union LDKCResultPtr_u8__MonitorUpdateError { uint8_t *result; - LDKMonitorUpdateError *err; + struct LDKMonitorUpdateError *err; } LDKCResultPtr_u8__MonitorUpdateError; typedef struct LDKCResultTempl_u8__MonitorUpdateError { - LDKCResultPtr_u8__MonitorUpdateError contents; + union LDKCResultPtr_u8__MonitorUpdateError contents; bool result_ok; } LDKCResultTempl_u8__MonitorUpdateError; -typedef LDKCResultTempl_u8__MonitorUpdateError LDKCResult_NoneMonitorUpdateErrorZ; +typedef struct LDKCResultTempl_u8__MonitorUpdateError LDKCResult_NoneMonitorUpdateErrorZ; @@ -289,18 +289,18 @@ typedef struct MUST_USE_STRUCT LDKOutPoint { } LDKOutPoint; typedef struct LDKC2TupleTempl_OutPoint__CVec_u8Z { - LDKOutPoint a; + struct LDKOutPoint a; LDKCVec_u8Z b; } LDKC2TupleTempl_OutPoint__CVec_u8Z; -typedef LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ; +typedef struct LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ; typedef struct LDKC2TupleTempl_u32__TxOut { uint32_t a; - LDKTxOut b; + struct LDKTxOut b; } LDKC2TupleTempl_u32__TxOut; -typedef LDKC2TupleTempl_u32__TxOut LDKC2Tuple_u32TxOutZ; +typedef struct LDKC2TupleTempl_u32__TxOut LDKC2Tuple_u32TxOutZ; /** * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to @@ -311,79 +311,67 @@ typedef struct LDKThirtyTwoBytes { } LDKThirtyTwoBytes; typedef struct LDKCVecTempl_C2TupleTempl_u32__TxOut { - LDKC2TupleTempl_u32__TxOut *data; + struct LDKC2TupleTempl_u32__TxOut *data; uintptr_t datalen; } LDKCVecTempl_C2TupleTempl_u32__TxOut; typedef struct LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut { - LDKThirtyTwoBytes a; - LDKCVecTempl_C2TupleTempl_u32__TxOut b; + struct LDKThirtyTwoBytes a; + struct LDKCVecTempl_C2TupleTempl_u32__TxOut b; } LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut; -typedef LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; +typedef struct LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; -typedef LDKCVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_u32TxOutZZ; +typedef struct LDKCVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_u32TxOutZZ; typedef struct LDKC2TupleTempl_u64__u64 { uint64_t a; uint64_t b; } LDKC2TupleTempl_u64__u64; -typedef LDKC2TupleTempl_u64__u64 LDKC2Tuple_u64u64Z; +typedef struct LDKC2TupleTempl_u64__u64 LDKC2Tuple_u64u64Z; typedef struct LDKSignature { uint8_t compact_form[64]; } LDKSignature; typedef struct LDKCVecTempl_Signature { - LDKSignature *data; + struct LDKSignature *data; uintptr_t datalen; } LDKCVecTempl_Signature; typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature { - LDKSignature a; - LDKCVecTempl_Signature b; + struct LDKSignature a; + struct LDKCVecTempl_Signature b; } LDKC2TupleTempl_Signature__CVecTempl_Signature; -typedef LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ; +typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ; -typedef LDKCVecTempl_Signature LDKCVec_SignatureZ; +typedef struct LDKCVecTempl_Signature LDKCVec_SignatureZ; typedef union LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 { - LDKC2TupleTempl_Signature__CVecTempl_Signature *result; + struct LDKC2TupleTempl_Signature__CVecTempl_Signature *result; uint8_t *err; } LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8; typedef struct LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 { - LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 contents; + union LDKCResultPtr_C2TupleTempl_Signature__CVecTempl_Signature________u8 contents; bool result_ok; } LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8; -typedef LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; +typedef struct LDKCResultTempl_C2TupleTempl_Signature__CVecTempl_Signature________u8 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; typedef union LDKCResultPtr_Signature__u8 { - LDKSignature *result; + struct LDKSignature *result; uint8_t *err; } LDKCResultPtr_Signature__u8; typedef struct LDKCResultTempl_Signature__u8 { - LDKCResultPtr_Signature__u8 contents; + union LDKCResultPtr_Signature__u8 contents; bool result_ok; } LDKCResultTempl_Signature__u8; -typedef LDKCResultTempl_Signature__u8 LDKCResult_SignatureNoneZ; - -typedef union LDKCResultPtr_CVecTempl_Signature_____u8 { - LDKCVecTempl_Signature *result; - uint8_t *err; -} LDKCResultPtr_CVecTempl_Signature_____u8; - -typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 { - LDKCResultPtr_CVecTempl_Signature_____u8 contents; - bool result_ok; -} LDKCResultTempl_CVecTempl_Signature_____u8; - -typedef LDKCResultTempl_CVecTempl_Signature_____u8 LDKCResult_CVec_SignatureZNoneZ; +typedef struct LDKCResultTempl_Signature__u8 LDKCResult_SignatureNoneZ; /** * A Rust str object, ie a reference to a UTF8-valid string. @@ -442,14 +430,14 @@ typedef struct LDKAPIError_LDKFeeRateTooHigh_Body { } LDKAPIError_LDKFeeRateTooHigh_Body; typedef struct LDKAPIError_LDKRouteError_Body { - LDKStr err; + struct LDKStr err; } LDKAPIError_LDKRouteError_Body; typedef struct LDKAPIError_LDKChannelUnavailable_Body { LDKCVec_u8Z err; } LDKAPIError_LDKChannelUnavailable_Body; -typedef struct LDKAPIError { +typedef struct MUST_USE_STRUCT LDKAPIError { LDKAPIError_Tag tag; union { LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; @@ -461,15 +449,15 @@ typedef struct LDKAPIError { typedef union LDKCResultPtr_u8__APIError { uint8_t *result; - LDKAPIError *err; + struct LDKAPIError *err; } LDKCResultPtr_u8__APIError; typedef struct LDKCResultTempl_u8__APIError { - LDKCResultPtr_u8__APIError contents; + union LDKCResultPtr_u8__APIError contents; bool result_ok; } LDKCResultTempl_u8__APIError; -typedef LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ; +typedef struct LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ; @@ -489,15 +477,15 @@ typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { typedef union LDKCResultPtr_u8__PaymentSendFailure { uint8_t *result; - LDKPaymentSendFailure *err; + struct LDKPaymentSendFailure *err; } LDKCResultPtr_u8__PaymentSendFailure; typedef struct LDKCResultTempl_u8__PaymentSendFailure { - LDKCResultPtr_u8__PaymentSendFailure contents; + union LDKCResultPtr_u8__PaymentSendFailure contents; bool result_ok; } LDKCResultTempl_u8__PaymentSendFailure; -typedef LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ; +typedef struct LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ; @@ -528,12 +516,38 @@ typedef struct MUST_USE_STRUCT LDKChannelUpdate { } LDKChannelUpdate; typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate { - LDKChannelAnnouncement a; - LDKChannelUpdate b; - LDKChannelUpdate c; + struct LDKChannelAnnouncement a; + struct LDKChannelUpdate b; + struct LDKChannelUpdate c; } LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate; -typedef LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; +typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; + + + +/** + * An Err type for failure to process messages. + */ +typedef struct MUST_USE_STRUCT LDKLightningError { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLightningError *inner; + bool is_owned; +} LDKLightningError; + +typedef union LDKCResultPtr_u8__LightningError { + uint8_t *result; + struct LDKLightningError *err; +} LDKCResultPtr_u8__LightningError; + +typedef struct LDKCResultTempl_u8__LightningError { + union LDKCResultPtr_u8__LightningError contents; + bool result_ok; +} LDKCResultTempl_u8__LightningError; + +typedef struct LDKCResultTempl_u8__LightningError LDKCResult_NoneLightningErrorZ; @@ -555,62 +569,58 @@ typedef struct MUST_USE_STRUCT LDKPeerHandleError { typedef union LDKCResultPtr_u8__PeerHandleError { uint8_t *result; - LDKPeerHandleError *err; + struct LDKPeerHandleError *err; } LDKCResultPtr_u8__PeerHandleError; typedef struct LDKCResultTempl_u8__PeerHandleError { - LDKCResultPtr_u8__PeerHandleError contents; + union LDKCResultPtr_u8__PeerHandleError contents; bool result_ok; } LDKCResultTempl_u8__PeerHandleError; -typedef LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ; +typedef struct LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ; /** - * Information about an HTLC as it appears in a commitment transaction + * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin + * transaction and the transaction creation keys) are trusted. + * + * See trust() and verify() functions on CommitmentTransaction. + * + * This structure implements Deref. */ -typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment { +typedef struct MUST_USE_STRUCT LDKTrustedCommitmentTransaction { /** * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeHTLCOutputInCommitment *inner; + LDKnativeTrustedCommitmentTransaction *inner; bool is_owned; -} LDKHTLCOutputInCommitment; - -typedef struct LDKC2TupleTempl_HTLCOutputInCommitment__Signature { - LDKHTLCOutputInCommitment a; - LDKSignature b; -} LDKC2TupleTempl_HTLCOutputInCommitment__Signature; - -typedef LDKC2TupleTempl_HTLCOutputInCommitment__Signature LDKC2Tuple_HTLCOutputInCommitmentSignatureZ; +} LDKTrustedCommitmentTransaction; +typedef union LDKCResultPtr_TrustedCommitmentTransaction__u8 { + struct LDKTrustedCommitmentTransaction *result; + uint8_t *err; +} LDKCResultPtr_TrustedCommitmentTransaction__u8; +typedef struct LDKCResultTempl_TrustedCommitmentTransaction__u8 { + union LDKCResultPtr_TrustedCommitmentTransaction__u8 contents; + bool result_ok; +} LDKCResultTempl_TrustedCommitmentTransaction__u8; -/** - * An Err type for failure to process messages. - */ -typedef struct MUST_USE_STRUCT LDKLightningError { - /** - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeLightningError *inner; - bool is_owned; -} LDKLightningError; +typedef struct LDKCResultTempl_TrustedCommitmentTransaction__u8 LDKCResult_TrustedCommitmentTransactionNoneZ; -typedef union LDKCResultPtr_u8__LightningError { - uint8_t *result; - LDKLightningError *err; -} LDKCResultPtr_u8__LightningError; +typedef union LDKCResultPtr_CVecTempl_Signature_____u8 { + struct LDKCVecTempl_Signature *result; + uint8_t *err; +} LDKCResultPtr_CVecTempl_Signature_____u8; -typedef struct LDKCResultTempl_u8__LightningError { - LDKCResultPtr_u8__LightningError contents; +typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 { + union LDKCResultPtr_CVecTempl_Signature_____u8 contents; bool result_ok; -} LDKCResultTempl_u8__LightningError; +} LDKCResultTempl_CVecTempl_Signature_____u8; -typedef LDKCResultTempl_u8__LightningError LDKCResult_NoneLightningErrorZ; +typedef struct LDKCResultTempl_CVecTempl_Signature_____u8 LDKCResult_CVec_SignatureZNoneZ; typedef struct LDKPublicKey { uint8_t compressed_form[33]; @@ -654,7 +664,7 @@ typedef enum LDKSpendableOutputDescriptor_Tag { * * 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 + * call to ChannelKeys::ready_channel) and the provided per_commitment point * to chan_utils::derive_public_revocation_key. * * The witness script which is hashed and included in the output script_pubkey may be @@ -680,26 +690,26 @@ typedef enum LDKSpendableOutputDescriptor_Tag { } LDKSpendableOutputDescriptor_Tag; typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { - LDKOutPoint outpoint; - LDKTxOut output; + struct LDKOutPoint outpoint; + struct LDKTxOut output; } LDKSpendableOutputDescriptor_LDKStaticOutput_Body; typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body { - LDKOutPoint outpoint; - LDKPublicKey per_commitment_point; + struct LDKOutPoint outpoint; + struct LDKPublicKey per_commitment_point; uint16_t to_self_delay; - LDKTxOut output; + struct LDKTxOut output; LDKC2Tuple_u64u64Z key_derivation_params; - LDKPublicKey revocation_pubkey; + struct LDKPublicKey revocation_pubkey; } LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body; typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body { - LDKOutPoint outpoint; - LDKTxOut output; + struct LDKOutPoint outpoint; + struct LDKTxOut output; LDKC2Tuple_u64u64Z key_derivation_params; } LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body; -typedef struct LDKSpendableOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { LDKSpendableOutputDescriptor_Tag tag; union { LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; @@ -709,11 +719,11 @@ typedef struct LDKSpendableOutputDescriptor { } LDKSpendableOutputDescriptor; typedef struct LDKCVecTempl_SpendableOutputDescriptor { - LDKSpendableOutputDescriptor *data; + struct LDKSpendableOutputDescriptor *data; uintptr_t datalen; } LDKCVecTempl_SpendableOutputDescriptor; -typedef LDKCVecTempl_SpendableOutputDescriptor LDKCVec_SpendableOutputDescriptorZ; +typedef struct LDKCVecTempl_SpendableOutputDescriptor LDKCVec_SpendableOutputDescriptorZ; /** * An Event which you should probably take some action in response to. @@ -783,29 +793,29 @@ typedef enum LDKEvent_Tag { } LDKEvent_Tag; typedef struct LDKEvent_LDKFundingGenerationReady_Body { - LDKThirtyTwoBytes temporary_channel_id; + struct LDKThirtyTwoBytes temporary_channel_id; uint64_t channel_value_satoshis; LDKCVec_u8Z output_script; uint64_t user_channel_id; } LDKEvent_LDKFundingGenerationReady_Body; typedef struct LDKEvent_LDKFundingBroadcastSafe_Body { - LDKOutPoint funding_txo; + struct LDKOutPoint funding_txo; uint64_t user_channel_id; } LDKEvent_LDKFundingBroadcastSafe_Body; typedef struct LDKEvent_LDKPaymentReceived_Body { - LDKThirtyTwoBytes payment_hash; - LDKThirtyTwoBytes payment_secret; + struct LDKThirtyTwoBytes payment_hash; + struct LDKThirtyTwoBytes payment_secret; uint64_t amt; } LDKEvent_LDKPaymentReceived_Body; typedef struct LDKEvent_LDKPaymentSent_Body { - LDKThirtyTwoBytes payment_preimage; + struct LDKThirtyTwoBytes payment_preimage; } LDKEvent_LDKPaymentSent_Body; typedef struct LDKEvent_LDKPaymentFailed_Body { - LDKThirtyTwoBytes payment_hash; + struct LDKThirtyTwoBytes payment_hash; bool rejected_by_dest; } LDKEvent_LDKPaymentFailed_Body; @@ -817,7 +827,7 @@ typedef struct LDKEvent_LDKSpendableOutputs_Body { LDKCVec_SpendableOutputDescriptorZ outputs; } LDKEvent_LDKSpendableOutputs_Body; -typedef struct LDKEvent { +typedef struct MUST_USE_STRUCT LDKEvent { LDKEvent_Tag tag; union { LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; @@ -1036,14 +1046,14 @@ typedef enum LDKErrorAction_Tag { } LDKErrorAction_Tag; typedef struct LDKErrorAction_LDKDisconnectPeer_Body { - LDKErrorMessage msg; + struct LDKErrorMessage msg; } LDKErrorAction_LDKDisconnectPeer_Body; typedef struct LDKErrorAction_LDKSendErrorMessage_Body { - LDKErrorMessage msg; + struct LDKErrorMessage msg; } LDKErrorAction_LDKSendErrorMessage_Body; -typedef struct LDKErrorAction { +typedef struct MUST_USE_STRUCT LDKErrorAction { LDKErrorAction_Tag tag; union { LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer; @@ -1076,7 +1086,7 @@ typedef enum LDKHTLCFailChannelUpdate_Tag { } LDKHTLCFailChannelUpdate_Tag; typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body { - LDKChannelUpdate msg; + struct LDKChannelUpdate msg; } LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body; typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body { @@ -1085,11 +1095,11 @@ typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body { } LDKHTLCFailChannelUpdate_LDKChannelClosed_Body; typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body { - LDKPublicKey node_id; + struct LDKPublicKey node_id; bool is_permanent; } LDKHTLCFailChannelUpdate_LDKNodeFailure_Body; -typedef struct LDKHTLCFailChannelUpdate { +typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate { LDKHTLCFailChannelUpdate_Tag tag; union { LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message; @@ -1098,6 +1108,44 @@ typedef struct LDKHTLCFailChannelUpdate { }; } LDKHTLCFailChannelUpdate; + + +/** + * A query_channel_range message is used to query a peer for channel + * UTXOs in a range of blocks. The recipient of a query makes a best + * effort to reply to the query using one or more reply_channel_range + * messages. + */ +typedef struct MUST_USE_STRUCT LDKQueryChannelRange { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeQueryChannelRange *inner; + bool is_owned; +} LDKQueryChannelRange; + + + +/** + * A query_short_channel_ids message is used to query a peer for + * routing gossip messages related to one or more short_channel_ids. + * The query recipient will reply with the latest, if available, + * channel_announcement, channel_update and node_announcement messages + * it maintains for the requested short_channel_ids followed by a + * reply_short_channel_ids_end message. The short_channel_ids sent in + * this query are encoded. We only support encoding_type=0 uncompressed + * serialization and do not support encoding_type=1 zlib serialization. + */ +typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeQueryShortChannelIds *inner; + bool is_owned; +} LDKQueryShortChannelIds; + /** * An event generated by ChannelManager which indicates a message should be sent to a peer (or * broadcast to most peers). @@ -1179,6 +1227,15 @@ typedef enum LDKMessageSendEvent_Tag { * cases this event is generated so that we can inform the network graph of this information. */ LDKMessageSendEvent_PaymentFailureNetworkUpdate, + /** + * Query a peer for channels with funding transaction UTXOs in a block range. + */ + LDKMessageSendEvent_SendChannelRangeQuery, + /** + * Request routing gossip messages from a peer for a list of channels identified by + * their short_channel_ids. + */ + LDKMessageSendEvent_SendShortIdsQuery, /** * Must be last for serialization purposes */ @@ -1186,83 +1243,93 @@ typedef enum LDKMessageSendEvent_Tag { } LDKMessageSendEvent_Tag; typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { - LDKPublicKey node_id; - LDKAcceptChannel msg; + struct LDKPublicKey node_id; + struct LDKAcceptChannel msg; } LDKMessageSendEvent_LDKSendAcceptChannel_Body; typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { - LDKPublicKey node_id; - LDKOpenChannel msg; + struct LDKPublicKey node_id; + struct LDKOpenChannel msg; } LDKMessageSendEvent_LDKSendOpenChannel_Body; typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { - LDKPublicKey node_id; - LDKFundingCreated msg; + struct LDKPublicKey node_id; + struct LDKFundingCreated msg; } LDKMessageSendEvent_LDKSendFundingCreated_Body; typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { - LDKPublicKey node_id; - LDKFundingSigned msg; + struct LDKPublicKey node_id; + struct LDKFundingSigned msg; } LDKMessageSendEvent_LDKSendFundingSigned_Body; typedef struct LDKMessageSendEvent_LDKSendFundingLocked_Body { - LDKPublicKey node_id; - LDKFundingLocked msg; + struct LDKPublicKey node_id; + struct LDKFundingLocked msg; } LDKMessageSendEvent_LDKSendFundingLocked_Body; typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { - LDKPublicKey node_id; - LDKAnnouncementSignatures msg; + struct LDKPublicKey node_id; + struct LDKAnnouncementSignatures msg; } LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { - LDKPublicKey node_id; - LDKCommitmentUpdate updates; + struct LDKPublicKey node_id; + struct LDKCommitmentUpdate updates; } LDKMessageSendEvent_LDKUpdateHTLCs_Body; typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { - LDKPublicKey node_id; - LDKRevokeAndACK msg; + struct LDKPublicKey node_id; + struct LDKRevokeAndACK msg; } LDKMessageSendEvent_LDKSendRevokeAndACK_Body; typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { - LDKPublicKey node_id; - LDKClosingSigned msg; + struct LDKPublicKey node_id; + struct LDKClosingSigned msg; } LDKMessageSendEvent_LDKSendClosingSigned_Body; typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { - LDKPublicKey node_id; - LDKShutdown msg; + struct LDKPublicKey node_id; + struct LDKShutdown msg; } LDKMessageSendEvent_LDKSendShutdown_Body; typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { - LDKPublicKey node_id; - LDKChannelReestablish msg; + struct LDKPublicKey node_id; + struct LDKChannelReestablish msg; } LDKMessageSendEvent_LDKSendChannelReestablish_Body; typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { - LDKChannelAnnouncement msg; - LDKChannelUpdate update_msg; + struct LDKChannelAnnouncement msg; + struct LDKChannelUpdate update_msg; } LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { - LDKNodeAnnouncement msg; + struct LDKNodeAnnouncement msg; } LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { - LDKChannelUpdate msg; + struct LDKChannelUpdate msg; } LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; typedef struct LDKMessageSendEvent_LDKHandleError_Body { - LDKPublicKey node_id; - LDKErrorAction action; + struct LDKPublicKey node_id; + struct LDKErrorAction action; } LDKMessageSendEvent_LDKHandleError_Body; typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body { - LDKHTLCFailChannelUpdate update; + struct LDKHTLCFailChannelUpdate update; } LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body; -typedef struct LDKMessageSendEvent { +typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { + struct LDKPublicKey node_id; + struct LDKQueryChannelRange msg; +} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; + +typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { + struct LDKPublicKey node_id; + struct LDKQueryShortChannelIds msg; +} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; + +typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_Tag tag; union { LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; @@ -1281,15 +1348,17 @@ typedef struct LDKMessageSendEvent { LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; LDKMessageSendEvent_LDKHandleError_Body handle_error; LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update; + LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; + LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; }; } LDKMessageSendEvent; typedef struct LDKCVecTempl_MessageSendEvent { - LDKMessageSendEvent *data; + struct LDKMessageSendEvent *data; uintptr_t datalen; } LDKCVecTempl_MessageSendEvent; -typedef LDKCVecTempl_MessageSendEvent LDKCVec_MessageSendEventZ; +typedef struct LDKCVecTempl_MessageSendEvent LDKCVec_MessageSendEventZ; /** * A trait indicating an object may generate message send events @@ -1305,11 +1374,11 @@ typedef struct LDKMessageSendEventsProvider { } LDKMessageSendEventsProvider; typedef struct LDKCVecTempl_Event { - LDKEvent *data; + struct LDKEvent *data; uintptr_t datalen; } LDKCVecTempl_Event; -typedef LDKCVecTempl_Event LDKCVec_EventZ; +typedef struct LDKCVecTempl_Event LDKCVec_EventZ; /** * A trait indicating an object may generate events @@ -1414,16 +1483,16 @@ typedef struct MUST_USE_STRUCT LDKUserConfig { } LDKUserConfig; typedef union LDKCResultPtr_TxOut__AccessError { - LDKTxOut *result; - LDKAccessError *err; + struct LDKTxOut *result; + enum LDKAccessError *err; } LDKCResultPtr_TxOut__AccessError; typedef struct LDKCResultTempl_TxOut__AccessError { - LDKCResultPtr_TxOut__AccessError contents; + union LDKCResultPtr_TxOut__AccessError contents; bool result_ok; } LDKCResultTempl_TxOut__AccessError; -typedef LDKCResultTempl_TxOut__AccessError LDKCResult_TxOutAccessErrorZ; +typedef struct LDKCResultTempl_TxOut__AccessError LDKCResult_TxOutAccessErrorZ; /** * The `Access` trait defines behavior for accessing chain data and state, such as blocks and @@ -1459,33 +1528,28 @@ typedef struct MUST_USE_STRUCT LDKChannelPublicKeys { /** - * The per-commitment point and a set of pre-calculated public keys used for transaction creation - * in the signer. - * The pre-calculated keys are an optimization, because ChannelKeys has enough - * information to re-derive them. + * This class tracks the per-transaction information needed to build a commitment transaction and to + * actually build it and sign. It is used for holder transactions that we sign only when needed + * and for transactions we sign for the counterparty. + * + * This class can be used inside a signer implementation to generate a signature given the relevant + * secret key. */ -typedef struct MUST_USE_STRUCT LDKPreCalculatedTxCreationKeys { +typedef struct MUST_USE_STRUCT LDKCommitmentTransaction { /** * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePreCalculatedTxCreationKeys *inner; + LDKnativeCommitmentTransaction *inner; bool is_owned; -} LDKPreCalculatedTxCreationKeys; - -typedef struct LDKCVecTempl_HTLCOutputInCommitment { - LDKHTLCOutputInCommitment *data; - uintptr_t datalen; -} LDKCVecTempl_HTLCOutputInCommitment; - -typedef LDKCVecTempl_HTLCOutputInCommitment LDKCVec_HTLCOutputInCommitmentZ; +} LDKCommitmentTransaction; /** - * 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. + * Information needed to build and sign a holder's commitment transaction. + * + * The transaction is only signed once we are ready to broadcast. */ typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction { /** @@ -1498,6 +1562,20 @@ typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction { +/** + * Information about an HTLC as it appears in a commitment transaction + */ +typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeHTLCOutputInCommitment *inner; + bool is_owned; +} LDKHTLCOutputInCommitment; + + + /** * The unsigned part of a channel_announcement */ @@ -1510,6 +1588,24 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { bool is_owned; } LDKUnsignedChannelAnnouncement; + + +/** + * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). + * The fields are organized by holder/counterparty. + * + * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters + * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions. + */ +typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelTransactionParameters *inner; + bool is_owned; +} LDKChannelTransactionParameters; + /** * Set of lightning keys needed to operate a channel as described in BOLT 3. * @@ -1541,7 +1637,7 @@ typedef struct LDKChannelKeys { * * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. */ - LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); /** * Gets the commitment secret for a specific commitment number as part of the revocation process * @@ -1553,17 +1649,17 @@ typedef struct LDKChannelKeys { * Note that the commitment number starts at (1 << 48) - 1 and counts backwards. * TODO: return a Result so we can signal a validation error */ - LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); + struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** * Gets the holder's channel public keys and basepoints */ - LDKChannelPublicKeys pubkeys; + struct LDKChannelPublicKeys pubkeys; /** * Fill in the pubkeys field as a reference to it will be given to Rust after this returns * Note that this takes a pointer to this object, not the this_ptr like other methods do * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. */ - void (*set_pubkeys)(const LDKChannelKeys*); + void (*set_pubkeys)(const struct LDKChannelKeys*); /** * Gets arbitrary identifiers describing the set of keys which are provided back to you in * some SpendableOutputDescriptor types. These should be sufficient to identify this @@ -1575,30 +1671,21 @@ typedef struct LDKChannelKeys { * * Note that if signing fails or is rejected, the channel will be force-closed. */ - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, 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, const struct LDKCommitmentTransaction *commitment_tx); /** - * 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_holder_commitment)(const void *this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx); - /** - * Create a signature for each HTLC transaction spending a holder's commitment transaction. + * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. + * This will only ever be called with a non-revoked commitment_tx. This will be called with the + * latest commitment_tx when we initiate a force-close. + * This will be called with the previous latest, just to get claiming HTLC signatures, if we are + * reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to + * the latest. + * This may be called multiple times for the same transaction. * - * 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. + * An external signer implementation should check that the commitment has not been revoked. * - * Either an Err should be returned, or a Vec with one entry for each HTLC which exists in - * 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. + * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. */ - LDKCResult_CVec_SignatureZNoneZ (*sign_holder_commitment_htlc_transactions)(const void *this_arg, const LDKHolderCommitmentTransaction *holder_commitment_tx); + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *commitment_tx); /** * Create a signature for the given input in a transaction spending an HTLC or commitment * transaction output when our counterparty broadcasts an old state. @@ -1619,7 +1706,7 @@ typedef struct LDKChannelKeys { * changing the format of the witness script (which is committed to in the BIP 143 * signatures). */ - LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const LDKHTLCOutputInCommitment *htlc); + LDKCResult_SignatureNoneZ (*sign_justice_transaction)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *htlc); /** * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment * transaction, either offered or received. @@ -1639,14 +1726,14 @@ 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_counterparty_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, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *htlc); /** * Create a signature for a (proposed) closing transaction. * * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have * chosen to forgo their output as dust. */ - LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, LDKTransaction closing_tx); + LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx); /** * Signs a channel announcement message with our funding key, proving it comes from one * of the channel participants. @@ -1655,17 +1742,22 @@ typedef struct LDKChannelKeys { * our counterparty may (though likely will not) close the channel on us for violating the * protocol. */ - LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const LDKUnsignedChannelAnnouncement *msg); + LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *msg); /** - * 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. + * Set the counterparty static channel data, including basepoints, + * counterparty_selected/holder_selected_contest_delay and funding outpoint. + * This is done as soon as the funding outpoint is known. Since these are static channel data, + * they MUST NOT be allowed to change to different values once set. + * + * channel_parameters.is_populated() MUST be true. * * We bind holder_selected_contest_delay late here for API convenience. * * Will be called before any signatures are applied. */ - void (*on_accept)(void *this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay); + void (*ready_channel)(void *this_arg, const struct LDKChannelTransactionParameters *channel_parameters); void *(*clone)(const void *this_arg); + LDKCVec_u8Z (*write)(const void *this_arg); void (*free)(void *this_arg); } LDKChannelKeys; @@ -1682,6 +1774,12 @@ typedef struct LDKChannelKeys { * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events * gotten are fully handled before re-serializing the new state. + * + * Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the + * returned block hash and the the current chain and then reconnecting blocks to get to the + * best chain) upon deserializing the object! */ typedef struct MUST_USE_STRUCT LDKChannelMonitor { /** @@ -1722,11 +1820,11 @@ typedef struct MUST_USE_STRUCT LDKMonitorEvent { } LDKMonitorEvent; typedef struct LDKCVecTempl_MonitorEvent { - LDKMonitorEvent *data; + struct LDKMonitorEvent *data; uintptr_t datalen; } LDKCVecTempl_MonitorEvent; -typedef LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ; +typedef struct LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ; /** * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as @@ -1764,7 +1862,7 @@ typedef struct LDKWatch { * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected */ - LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor); + LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** * Updates a channel identified by `funding_txo` by applying `update` to its monitor. * @@ -1774,7 +1872,7 @@ typedef struct LDKWatch { * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html */ - LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update); + LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); /** * Returns any monitor events since the last call. Subsequent calls must only return new * events. @@ -1812,12 +1910,12 @@ typedef struct LDKFilter { * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as * a spending condition. */ - void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], LDKu8slice script_pubkey); + void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); /** * Registers interest in spends of a transaction output identified by `outpoint` having * `script_pubkey` as the spending condition. */ - void (*register_output)(const void *this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey); + void (*register_output)(const void *this_arg, const struct LDKOutPoint *outpoint, struct LDKu8slice script_pubkey); void (*free)(void *this_arg); } LDKFilter; @@ -1829,7 +1927,7 @@ typedef struct LDKBroadcasterInterface { /** * Sends a transaction out to (hopefully) be mined. */ - void (*broadcast_transaction)(const void *this_arg, LDKTransaction tx); + void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); void (*free)(void *this_arg); } LDKBroadcasterInterface; @@ -1852,7 +1950,7 @@ typedef struct LDKFeeEstimator { * * satoshis-per-byte * 250 * * ceil(satoshis-per-kbyte / 4) */ - uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, LDKConfirmationTarget confirmation_target); + uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); void (*free)(void *this_arg); } LDKFeeEstimator; @@ -1884,7 +1982,7 @@ typedef struct LDKPersist { * [`ChannelMonitor::serialize_for_disk`]: struct.ChannelMonitor.html#method.serialize_for_disk * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html */ - LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, LDKOutPoint id, const LDKChannelMonitor *data); + LDKCResult_NoneChannelMonitorUpdateErrZ (*persist_new_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *data); /** * Update one channel's data. The provided `ChannelMonitor` has already * applied the given update. @@ -1914,7 +2012,7 @@ typedef struct LDKPersist { * [`ChannelMonitorUpdate::write`]: struct.ChannelMonitorUpdate.html#method.write * [`ChannelMonitorUpdateErr`]: enum.ChannelMonitorUpdateErr.html */ - LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate *update, const LDKChannelMonitor *data); + LDKCResult_NoneChannelMonitorUpdateErrZ (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *update, const struct LDKChannelMonitor *data); void (*free)(void *this_arg); } LDKPersist; @@ -1942,11 +2040,11 @@ typedef struct MUST_USE_STRUCT LDKChainMonitor { } LDKChainMonitor; typedef struct LDKCVecTempl_C2TupleTempl_usize__Transaction { - LDKC2TupleTempl_usize__Transaction *data; + struct LDKC2TupleTempl_usize__Transaction *data; uintptr_t datalen; } LDKCVecTempl_C2TupleTempl_usize__Transaction; -typedef LDKCVecTempl_C2TupleTempl_usize__Transaction LDKCVec_C2Tuple_usizeTransactionZZ; +typedef struct LDKCVecTempl_C2TupleTempl_usize__Transaction LDKCVec_C2Tuple_usizeTransactionZZ; @@ -1967,23 +2065,49 @@ typedef struct MUST_USE_STRUCT LDKHTLCUpdate { } LDKHTLCUpdate; typedef struct LDKCVecTempl_Transaction { - LDKTransaction *data; + struct LDKTransaction *data; uintptr_t datalen; } LDKCVecTempl_Transaction; -typedef LDKCVecTempl_Transaction LDKCVec_TransactionZ; +typedef struct LDKCVecTempl_Transaction LDKCVec_TransactionZ; typedef struct LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut { - LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut *data; + struct LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut *data; uintptr_t datalen; } LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut; -typedef LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ; +typedef struct LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_C2TupleTempl_u32__TxOut LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ; typedef struct LDKSecretKey { uint8_t bytes[32]; } LDKSecretKey; + + +/** + * An error in decoding a message or struct. + */ +typedef struct MUST_USE_STRUCT LDKDecodeError { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDecodeError *inner; + bool is_owned; +} LDKDecodeError; + +typedef union LDKCResultPtr_ChannelKeys__DecodeError { + struct LDKChannelKeys *result; + struct LDKDecodeError *err; +} LDKCResultPtr_ChannelKeys__DecodeError; + +typedef struct LDKCResultTempl_ChannelKeys__DecodeError { + union LDKCResultPtr_ChannelKeys__DecodeError contents; + bool result_ok; +} LDKCResultTempl_ChannelKeys__DecodeError; + +typedef struct LDKCResultTempl_ChannelKeys__DecodeError LDKCResult_ChanKeySignerDecodeErrorZ; + /** * A trait to describe an object which can get user secrets and key material. */ @@ -1992,7 +2116,7 @@ typedef struct LDKKeysInterface { /** * Get node secret key (aka node_id or network_key) */ - LDKSecretKey (*get_node_secret)(const void *this_arg); + struct LDKSecretKey (*get_node_secret)(const void *this_arg); /** * Get destination redeemScript to encumber static protocol exit points. */ @@ -2000,18 +2124,27 @@ typedef struct LDKKeysInterface { /** * Get shutdown_pubkey to use as PublicKey at channel closure */ - LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); + struct LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg); /** * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you * restarted with some stale data! */ - LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); + struct LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); /** * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting * onion packets and for temporary channel IDs. There is no requirement that these be * persisted anywhere, though they must be unique across restarts. */ - LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); + struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); + /** + * Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream. + * This is only called during deserialization of other objects which contain + * `ChannelKeys`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). + * The bytes are exactly those which `::write()` writes, and + * contain no versioning scheme. You may wish to include your own version prefix and ensure + * you've read all of the provided bytes to ensure no corruption occurred. + */ + LDKCResult_ChanKeySignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); void (*free)(void *this_arg); } LDKKeysInterface; @@ -2019,6 +2152,9 @@ typedef struct LDKKeysInterface { /** * A simple implementation of ChannelKeys that just keeps the private keys in memory. + * + * This implementation performs no policy checks and is insufficient by itself as + * a secure external signer. */ typedef struct MUST_USE_STRUCT LDKInMemoryChannelKeys { /** @@ -2127,11 +2263,11 @@ typedef struct MUST_USE_STRUCT LDKInitFeatures { } LDKInitFeatures; typedef struct LDKCVecTempl_ChannelDetails { - LDKChannelDetails *data; + struct LDKChannelDetails *data; uintptr_t datalen; } LDKCVecTempl_ChannelDetails; -typedef LDKCVecTempl_ChannelDetails LDKCVec_ChannelDetailsZ; +typedef struct LDKCVecTempl_ChannelDetails LDKCVec_ChannelDetailsZ; @@ -2193,28 +2329,28 @@ typedef enum LDKNetAddress_Tag { } LDKNetAddress_Tag; typedef struct LDKNetAddress_LDKIPv4_Body { - LDKFourBytes addr; + struct LDKFourBytes addr; uint16_t port; } LDKNetAddress_LDKIPv4_Body; typedef struct LDKNetAddress_LDKIPv6_Body { - LDKSixteenBytes addr; + struct LDKSixteenBytes addr; uint16_t port; } LDKNetAddress_LDKIPv6_Body; typedef struct LDKNetAddress_LDKOnionV2_Body { - LDKTenBytes addr; + struct LDKTenBytes addr; uint16_t port; } LDKNetAddress_LDKOnionV2_Body; typedef struct LDKNetAddress_LDKOnionV3_Body { - LDKThirtyTwoBytes ed25519_pubkey; + struct LDKThirtyTwoBytes ed25519_pubkey; uint16_t checksum; uint8_t version; uint16_t port; } LDKNetAddress_LDKOnionV3_Body; -typedef struct LDKNetAddress { +typedef struct MUST_USE_STRUCT LDKNetAddress { LDKNetAddress_Tag tag; union { LDKNetAddress_LDKIPv4_Body i_pv4; @@ -2225,11 +2361,11 @@ typedef struct LDKNetAddress { } LDKNetAddress; typedef struct LDKCVecTempl_NetAddress { - LDKNetAddress *data; + struct LDKNetAddress *data; uintptr_t datalen; } LDKCVecTempl_NetAddress; -typedef LDKCVecTempl_NetAddress LDKCVec_NetAddressZ; +typedef struct LDKCVecTempl_NetAddress LDKCVec_NetAddressZ; @@ -2340,83 +2476,83 @@ typedef struct LDKChannelMessageHandler { /** * Handle an incoming open_channel message from the given peer. */ - void (*handle_open_channel)(const void *this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel *msg); + void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKOpenChannel *msg); /** * Handle an incoming accept_channel message from the given peer. */ - void (*handle_accept_channel)(const void *this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg); + void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKAcceptChannel *msg); /** * Handle an incoming funding_created message from the given peer. */ - void (*handle_funding_created)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg); + void (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *msg); /** * Handle an incoming funding_signed message from the given peer. */ - void (*handle_funding_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg); + void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *msg); /** * Handle an incoming funding_locked message from the given peer. */ - void (*handle_funding_locked)(const void *this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg); + void (*handle_funding_locked)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingLocked *msg); /** * Handle an incoming shutdown message from the given peer. */ - void (*handle_shutdown)(const void *this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg); + void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKShutdown *msg); /** * Handle an incoming closing_signed message from the given peer. */ - void (*handle_closing_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg); + void (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *msg); /** * Handle an incoming update_add_htlc message from the given peer. */ - void (*handle_update_add_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg); + void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *msg); /** * Handle an incoming update_fulfill_htlc message from the given peer. */ - void (*handle_update_fulfill_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg); + void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *msg); /** * Handle an incoming update_fail_htlc message from the given peer. */ - void (*handle_update_fail_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg); + void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *msg); /** * Handle an incoming update_fail_malformed_htlc message from the given peer. */ - void (*handle_update_fail_malformed_htlc)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg); + void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *msg); /** * Handle an incoming commitment_signed message from the given peer. */ - void (*handle_commitment_signed)(const void *this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg); + void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *msg); /** * Handle an incoming revoke_and_ack message from the given peer. */ - void (*handle_revoke_and_ack)(const void *this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg); + void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *msg); /** * Handle an incoming update_fee message from the given peer. */ - void (*handle_update_fee)(const void *this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg); + void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *msg); /** * Handle an incoming announcement_signatures message from the given peer. */ - void (*handle_announcement_signatures)(const void *this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg); + void (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *msg); /** * Indicates a connection to the peer failed/an existing connection was lost. If no connection * is believed to be possible in the future (eg they're sending us messages we don't * understand or indicate they require unknown feature bits), no_connection_possible is set * and any outstanding channels should be failed. */ - void (*peer_disconnected)(const void *this_arg, LDKPublicKey their_node_id, bool no_connection_possible); + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id, bool no_connection_possible); /** * Handle a peer reconnecting, possibly generating channel_reestablish message(s). */ - void (*peer_connected)(const void *this_arg, LDKPublicKey their_node_id, const LDKInit *msg); + void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *msg); /** * Handle an incoming channel_reestablish message from the given peer. */ - void (*handle_channel_reestablish)(const void *this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg); + void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *msg); /** * Handle an incoming error message from the given peer. */ - void (*handle_error)(const void *this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg); - LDKMessageSendEventsProvider MessageSendEventsProvider; + void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *msg); + struct LDKMessageSendEventsProvider MessageSendEventsProvider; void (*free)(void *this_arg); } LDKChannelMessageHandler; @@ -2448,25 +2584,11 @@ typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { } LDKChannelManagerReadArgs; typedef struct LDKCVecTempl_ChannelMonitor { - LDKChannelMonitor *data; + struct LDKChannelMonitor *data; uintptr_t datalen; } LDKCVecTempl_ChannelMonitor; -typedef LDKCVecTempl_ChannelMonitor LDKCVec_ChannelMonitorZ; - - - -/** - * An error in decoding a message or struct. - */ -typedef struct MUST_USE_STRUCT LDKDecodeError { - /** - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeDecodeError *inner; - bool is_owned; -} LDKDecodeError; +typedef struct LDKCVecTempl_ChannelMonitor LDKCVec_ChannelMonitorZ; @@ -2571,23 +2693,6 @@ 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 everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeQueryChannelRange *inner; - 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 @@ -2611,28 +2716,7 @@ typedef struct LDKCVecTempl_u64 { 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 everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeQueryShortChannelIds *inner; - bool is_owned; -} LDKQueryShortChannelIds; +typedef struct LDKCVecTempl_u64 LDKCVec_u64Z; @@ -2668,61 +2752,67 @@ typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { } LDKGossipTimestampFilter; typedef struct LDKCVecTempl_UpdateAddHTLC { - LDKUpdateAddHTLC *data; + struct LDKUpdateAddHTLC *data; uintptr_t datalen; } LDKCVecTempl_UpdateAddHTLC; -typedef LDKCVecTempl_UpdateAddHTLC LDKCVec_UpdateAddHTLCZ; +typedef struct LDKCVecTempl_UpdateAddHTLC LDKCVec_UpdateAddHTLCZ; typedef struct LDKCVecTempl_UpdateFulfillHTLC { - LDKUpdateFulfillHTLC *data; + struct LDKUpdateFulfillHTLC *data; uintptr_t datalen; } LDKCVecTempl_UpdateFulfillHTLC; -typedef LDKCVecTempl_UpdateFulfillHTLC LDKCVec_UpdateFulfillHTLCZ; +typedef struct LDKCVecTempl_UpdateFulfillHTLC LDKCVec_UpdateFulfillHTLCZ; typedef struct LDKCVecTempl_UpdateFailHTLC { - LDKUpdateFailHTLC *data; + struct LDKUpdateFailHTLC *data; uintptr_t datalen; } LDKCVecTempl_UpdateFailHTLC; -typedef LDKCVecTempl_UpdateFailHTLC LDKCVec_UpdateFailHTLCZ; +typedef struct LDKCVecTempl_UpdateFailHTLC LDKCVec_UpdateFailHTLCZ; typedef struct LDKCVecTempl_UpdateFailMalformedHTLC { - LDKUpdateFailMalformedHTLC *data; + struct LDKUpdateFailMalformedHTLC *data; uintptr_t datalen; } LDKCVecTempl_UpdateFailMalformedHTLC; -typedef LDKCVecTempl_UpdateFailMalformedHTLC LDKCVec_UpdateFailMalformedHTLCZ; +typedef struct LDKCVecTempl_UpdateFailMalformedHTLC LDKCVec_UpdateFailMalformedHTLCZ; typedef union LDKCResultPtr_bool__LightningError { bool *result; - LDKLightningError *err; + struct LDKLightningError *err; } LDKCResultPtr_bool__LightningError; typedef struct LDKCResultTempl_bool__LightningError { - LDKCResultPtr_bool__LightningError contents; + union LDKCResultPtr_bool__LightningError contents; bool result_ok; } LDKCResultTempl_bool__LightningError; -typedef LDKCResultTempl_bool__LightningError LDKCResult_boolLightningErrorZ; +typedef struct LDKCResultTempl_bool__LightningError LDKCResult_boolLightningErrorZ; typedef struct LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate { - LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *data; + struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate *data; uintptr_t datalen; } LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate; -typedef LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; +typedef struct LDKCVecTempl_C3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; typedef struct LDKCVecTempl_NodeAnnouncement { - LDKNodeAnnouncement *data; + struct LDKNodeAnnouncement *data; uintptr_t datalen; } LDKCVecTempl_NodeAnnouncement; -typedef LDKCVecTempl_NodeAnnouncement LDKCVec_NodeAnnouncementZ; +typedef struct LDKCVecTempl_NodeAnnouncement LDKCVec_NodeAnnouncementZ; /** * A trait to describe an object which can receive routing messages. + * + * # Implementor DoS Warnings + * + * For `gossip_queries` messages there are potential DoS vectors when handling + * inbound queries. Implementors using an on-disk network graph should be aware of + * repeated disk I/O for queries accessing different parts of the network graph. */ typedef struct LDKRoutingMessageHandler { void *this_arg; @@ -2730,21 +2820,21 @@ typedef struct LDKRoutingMessageHandler { * Handle an incoming node_announcement message, returning true if it should be forwarded on, * false or returning an Err otherwise. */ - LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const LDKNodeAnnouncement *msg); + LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *msg); /** * Handle a channel_announcement message, returning true if it should be forwarded on, false * or returning an Err otherwise. */ - LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const LDKChannelAnnouncement *msg); + LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *msg); /** * Handle an incoming channel_update message, returning true if it should be forwarded on, * false or returning an Err otherwise. */ - LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const LDKChannelUpdate *msg); + LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *msg); /** * Handle some updates to the route graph that we learned due to an outbound failed payment. */ - void (*handle_htlc_fail_channel_update)(const void *this_arg, const LDKHTLCFailChannelUpdate *update); + void (*handle_htlc_fail_channel_update)(const void *this_arg, const struct LDKHTLCFailChannelUpdate *update); /** * Gets a subset of the channel announcements and updates required to dump our routing table * to a remote node, starting at the short_channel_id indicated by starting_point and @@ -2757,11 +2847,37 @@ typedef struct LDKRoutingMessageHandler { * immediately higher (as defined by ::cmp) than starting_point. * If None is provided for starting_point, we start at the first node. */ - LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, LDKPublicKey starting_point, uint8_t batch_amount); + LDKCVec_NodeAnnouncementZ (*get_next_node_announcements)(const void *this_arg, struct LDKPublicKey starting_point, uint8_t batch_amount); + /** + * Called when a connection is established with a peer. This can be used to + * perform routing table synchronization using a strategy defined by the + * implementor. + */ + void (*sync_routing_table)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *init); + /** + * Handles the reply of a query we initiated to learn about channels + * for a given range of blocks. We can expect to receive one or more + * replies to a single query. + */ + LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); + /** + * Handles the reply of a query we initiated asking for routing gossip + * messages for a list of channels. We should receive this message when + * a node has completed its best effort to send us the pertaining routing + * gossip messages. + */ + LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); /** - * Returns whether a full sync should be requested from a peer. + * Handles when a peer asks us to send a list of short_channel_ids + * for the requested range of blocks. */ - bool (*should_request_full_sync)(const void *this_arg, LDKPublicKey node_id); + LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + /** + * Handles when a peer asks us to send routing gossip messages for a + * list of short_channel_ids. + */ + LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + struct LDKMessageSendEventsProvider MessageSendEventsProvider; void (*free)(void *this_arg); } LDKRoutingMessageHandler; @@ -2810,7 +2926,7 @@ typedef struct LDKSocketDescriptor { * indicating that read events on this descriptor should resume. A resume_read of false does * *not* imply that further read events should be paused. */ - uintptr_t (*send_data)(void *this_arg, LDKu8slice data, bool resume_read); + uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); /** * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with @@ -2819,7 +2935,7 @@ typedef struct LDKSocketDescriptor { * socket_disconnected but prior to socket_disconnected returning. */ void (*disconnect_socket)(void *this_arg); - bool (*eq)(const void *this_arg, const LDKSocketDescriptor *other_arg); + bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *other_arg); uint64_t (*hash)(const void *this_arg); void *(*clone)(const void *this_arg); void (*free)(void *this_arg); @@ -2847,59 +2963,59 @@ typedef struct MUST_USE_STRUCT LDKPeerManager { } LDKPeerManager; typedef struct LDKCVecTempl_PublicKey { - LDKPublicKey *data; + struct LDKPublicKey *data; uintptr_t datalen; } LDKCVecTempl_PublicKey; -typedef LDKCVecTempl_PublicKey LDKCVec_PublicKeyZ; +typedef struct LDKCVecTempl_PublicKey LDKCVec_PublicKeyZ; typedef union LDKCResultPtr_CVecTempl_u8_____PeerHandleError { - LDKCVecTempl_u8 *result; - LDKPeerHandleError *err; + struct LDKCVecTempl_u8 *result; + struct LDKPeerHandleError *err; } LDKCResultPtr_CVecTempl_u8_____PeerHandleError; typedef struct LDKCResultTempl_CVecTempl_u8_____PeerHandleError { - LDKCResultPtr_CVecTempl_u8_____PeerHandleError contents; + union LDKCResultPtr_CVecTempl_u8_____PeerHandleError contents; bool result_ok; } LDKCResultTempl_CVecTempl_u8_____PeerHandleError; -typedef LDKCResultTempl_CVecTempl_u8_____PeerHandleError LDKCResult_CVec_u8ZPeerHandleErrorZ; +typedef struct LDKCResultTempl_CVecTempl_u8_____PeerHandleError LDKCResult_CVec_u8ZPeerHandleErrorZ; typedef union LDKCResultPtr_bool__PeerHandleError { bool *result; - LDKPeerHandleError *err; + struct LDKPeerHandleError *err; } LDKCResultPtr_bool__PeerHandleError; typedef struct LDKCResultTempl_bool__PeerHandleError { - LDKCResultPtr_bool__PeerHandleError contents; + union LDKCResultPtr_bool__PeerHandleError contents; bool result_ok; } LDKCResultTempl_bool__PeerHandleError; -typedef LDKCResultTempl_bool__PeerHandleError LDKCResult_boolPeerHandleErrorZ; +typedef struct LDKCResultTempl_bool__PeerHandleError LDKCResult_boolPeerHandleErrorZ; typedef union LDKCResultPtr_SecretKey__Secp256k1Error { - LDKSecretKey *result; - LDKSecp256k1Error *err; + struct LDKSecretKey *result; + enum LDKSecp256k1Error *err; } LDKCResultPtr_SecretKey__Secp256k1Error; typedef struct LDKCResultTempl_SecretKey__Secp256k1Error { - LDKCResultPtr_SecretKey__Secp256k1Error contents; + union LDKCResultPtr_SecretKey__Secp256k1Error contents; bool result_ok; } LDKCResultTempl_SecretKey__Secp256k1Error; -typedef LDKCResultTempl_SecretKey__Secp256k1Error LDKCResult_SecretKeySecpErrorZ; +typedef struct LDKCResultTempl_SecretKey__Secp256k1Error LDKCResult_SecretKeySecpErrorZ; typedef union LDKCResultPtr_PublicKey__Secp256k1Error { - LDKPublicKey *result; - LDKSecp256k1Error *err; + struct LDKPublicKey *result; + enum LDKSecp256k1Error *err; } LDKCResultPtr_PublicKey__Secp256k1Error; typedef struct LDKCResultTempl_PublicKey__Secp256k1Error { - LDKCResultPtr_PublicKey__Secp256k1Error contents; + union LDKCResultPtr_PublicKey__Secp256k1Error contents; bool result_ok; } LDKCResultTempl_PublicKey__Secp256k1Error; -typedef LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ; +typedef struct LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ; @@ -2913,7 +3029,7 @@ typedef LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ * * 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 + * CommitmentTransaction.trust().keys() because we trusted the source of the * pre-calculated keys. */ typedef struct MUST_USE_STRUCT LDKTxCreationKeys { @@ -2926,23 +3042,62 @@ typedef struct MUST_USE_STRUCT LDKTxCreationKeys { } LDKTxCreationKeys; typedef union LDKCResultPtr_TxCreationKeys__Secp256k1Error { - LDKTxCreationKeys *result; - LDKSecp256k1Error *err; + struct LDKTxCreationKeys *result; + enum LDKSecp256k1Error *err; } LDKCResultPtr_TxCreationKeys__Secp256k1Error; typedef struct LDKCResultTempl_TxCreationKeys__Secp256k1Error { - LDKCResultPtr_TxCreationKeys__Secp256k1Error contents; + union LDKCResultPtr_TxCreationKeys__Secp256k1Error contents; bool result_ok; } LDKCResultTempl_TxCreationKeys__Secp256k1Error; -typedef LDKCResultTempl_TxCreationKeys__Secp256k1Error LDKCResult_TxCreationKeysSecpErrorZ; +typedef struct LDKCResultTempl_TxCreationKeys__Secp256k1Error LDKCResult_TxCreationKeysSecpErrorZ; + + + +/** + * Late-bound per-channel counterparty data used to build transactions. + */ +typedef struct MUST_USE_STRUCT LDKCounterpartyChannelTransactionParameters { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCounterpartyChannelTransactionParameters *inner; + bool is_owned; +} LDKCounterpartyChannelTransactionParameters; + + + +/** + * Static channel fields used to build transactions given per-commitment fields, organized by + * broadcaster/countersignatory. + * + * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the + * as_holder_broadcastable and as_counterparty_broadcastable functions. + */ +typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDirectedChannelTransactionParameters *inner; + bool is_owned; +} LDKDirectedChannelTransactionParameters; -typedef struct LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature { - LDKC2TupleTempl_HTLCOutputInCommitment__Signature *data; - uintptr_t datalen; -} LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature; -typedef LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ; + +/** + * A pre-built Bitcoin commitment transaction and its txid. + */ +typedef struct MUST_USE_STRUCT LDKBuiltCommitmentTransaction { + /** + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBuiltCommitmentTransaction *inner; + bool is_owned; +} LDKBuiltCommitmentTransaction; @@ -2959,16 +3114,16 @@ typedef struct MUST_USE_STRUCT LDKRouteHop { } LDKRouteHop; typedef struct LDKCVecTempl_RouteHop { - LDKRouteHop *data; + struct LDKRouteHop *data; uintptr_t datalen; } LDKCVecTempl_RouteHop; typedef struct LDKCVecTempl_CVecTempl_RouteHop { - LDKCVecTempl_RouteHop *data; + struct LDKCVecTempl_RouteHop *data; uintptr_t datalen; } LDKCVecTempl_CVecTempl_RouteHop; -typedef LDKCVecTempl_CVecTempl_RouteHop LDKCVec_CVec_RouteHopZZ; +typedef struct LDKCVecTempl_CVecTempl_RouteHop LDKCVec_CVec_RouteHopZZ; @@ -2999,16 +3154,16 @@ typedef struct MUST_USE_STRUCT LDKRoutingFees { } LDKRoutingFees; typedef union LDKCResultPtr_Route__LightningError { - LDKRoute *result; - LDKLightningError *err; + struct LDKRoute *result; + struct LDKLightningError *err; } LDKCResultPtr_Route__LightningError; typedef struct LDKCResultTempl_Route__LightningError { - LDKCResultPtr_Route__LightningError contents; + union LDKCResultPtr_Route__LightningError contents; bool result_ok; } LDKCResultTempl_Route__LightningError; -typedef LDKCResultTempl_Route__LightningError LDKCResult_RouteLightningErrorZ; +typedef struct LDKCResultTempl_Route__LightningError LDKCResult_RouteLightningErrorZ; @@ -3025,11 +3180,11 @@ typedef struct MUST_USE_STRUCT LDKNetworkGraph { } LDKNetworkGraph; typedef struct LDKCVecTempl_RouteHint { - LDKRouteHint *data; + struct LDKRouteHint *data; uintptr_t datalen; } LDKCVecTempl_RouteHint; -typedef LDKCVecTempl_RouteHint LDKCVec_RouteHintZ; +typedef struct LDKCVecTempl_RouteHint LDKCVec_RouteHintZ; @@ -3123,239 +3278,245 @@ typedef struct MUST_USE_STRUCT LDKNodeInfo { bool is_owned; } LDKNodeInfo; -typedef LDKCVecTempl_RouteHop LDKCVec_RouteHopZ; +typedef struct LDKCVecTempl_RouteHop LDKCVec_RouteHopZ; -extern const void (*C2Tuple_HTLCOutputInCommitmentSignatureZ_free)(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ); +extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ); + +extern const void (*CVec_MessageSendEventZ_free)(LDKCVec_MessageSendEventZ); + +extern const void (*CVec_EventZ_free)(LDKCVec_EventZ); + +extern const void (*C2Tuple_usizeTransactionZ_free)(LDKC2Tuple_usizeTransactionZ); + +extern const void (*CVec_C2Tuple_usizeTransactionZZ_free)(LDKCVec_C2Tuple_usizeTransactionZZ); + +extern const void (*CResult_NoneChannelMonitorUpdateErrZ_free)(LDKCResult_NoneChannelMonitorUpdateErrZ); + +extern const LDKCResult_NoneChannelMonitorUpdateErrZ (*CResult_NoneChannelMonitorUpdateErrZ_err)(enum LDKChannelMonitorUpdateErr); + +extern const void (*CVec_MonitorEventZ_free)(LDKCVec_MonitorEventZ); + +extern const void (*CResult_NoneMonitorUpdateErrorZ_free)(LDKCResult_NoneMonitorUpdateErrorZ); + +extern const LDKCResult_NoneMonitorUpdateErrorZ (*CResult_NoneMonitorUpdateErrorZ_err)(struct LDKMonitorUpdateError); extern const void (*C2Tuple_OutPointScriptZ_free)(LDKC2Tuple_OutPointScriptZ); -extern const void (*C2Tuple_SignatureCVec_SignatureZZ_free)(LDKC2Tuple_SignatureCVec_SignatureZZ); +extern const void (*CVec_TransactionZ_free)(LDKCVec_TransactionZ); + +extern const void (*C2Tuple_u32TxOutZ_free)(LDKC2Tuple_u32TxOutZ); + +extern const void (*CVec_C2Tuple_u32TxOutZZ_free)(LDKCVec_C2Tuple_u32TxOutZZ); extern const void (*C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free)(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ); -extern const void (*C2Tuple_u32TxOutZ_free)(LDKC2Tuple_u32TxOutZ); +extern const void (*CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free)(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ); extern const void (*C2Tuple_u64u64Z_free)(LDKC2Tuple_u64u64Z); -extern const void (*C2Tuple_usizeTransactionZ_free)(LDKC2Tuple_usizeTransactionZ); - -extern const void (*C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free)(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ); +extern const void (*CVec_SignatureZ_free)(LDKCVec_SignatureZ); -extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; +extern const void (*C2Tuple_SignatureCVec_SignatureZZ_free)(LDKC2Tuple_SignatureCVec_SignatureZZ); extern const void (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free)(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ); extern const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok)(LDKC2Tuple_SignatureCVec_SignatureZZ); -extern const void (*CResult_CVec_SignatureZNoneZ_free)(LDKCResult_CVec_SignatureZNoneZ); - -extern const LDKCResult_CVec_SignatureZNoneZ (*CResult_CVec_SignatureZNoneZ_ok)(LDKCVec_SignatureZ); - -extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_err)(LDKPeerHandleError); - -extern const void (*CResult_CVec_u8ZPeerHandleErrorZ_free)(LDKCResult_CVec_u8ZPeerHandleErrorZ); +extern const void (*CResult_SignatureNoneZ_free)(LDKCResult_SignatureNoneZ); -extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_ok)(LDKCVec_u8Z); +extern const LDKCResult_SignatureNoneZ (*CResult_SignatureNoneZ_ok)(struct LDKSignature); -extern const LDKCResult_NoneAPIErrorZ (*CResult_NoneAPIErrorZ_err)(LDKAPIError); +extern const void (*CResult_ChanKeySignerDecodeErrorZ_free)(LDKCResult_ChanKeySignerDecodeErrorZ); -extern const void (*CResult_NoneAPIErrorZ_free)(LDKCResult_NoneAPIErrorZ); +extern const LDKCResult_ChanKeySignerDecodeErrorZ (*CResult_ChanKeySignerDecodeErrorZ_ok)(struct LDKChannelKeys); -extern const LDKCResult_NoneChannelMonitorUpdateErrZ (*CResult_NoneChannelMonitorUpdateErrZ_err)(LDKChannelMonitorUpdateErr); +extern const LDKCResult_ChanKeySignerDecodeErrorZ (*CResult_ChanKeySignerDecodeErrorZ_err)(struct LDKDecodeError); -extern const void (*CResult_NoneChannelMonitorUpdateErrZ_free)(LDKCResult_NoneChannelMonitorUpdateErrZ); +extern const void (*CResult_TxOutAccessErrorZ_free)(LDKCResult_TxOutAccessErrorZ); -extern const LDKCResult_NoneLightningErrorZ (*CResult_NoneLightningErrorZ_err)(LDKLightningError); +extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_ok)(struct LDKTxOut); -extern const void (*CResult_NoneLightningErrorZ_free)(LDKCResult_NoneLightningErrorZ); +extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_err)(enum LDKAccessError); -extern const LDKCResult_NoneMonitorUpdateErrorZ (*CResult_NoneMonitorUpdateErrorZ_err)(LDKMonitorUpdateError); +extern const void (*CResult_NoneAPIErrorZ_free)(LDKCResult_NoneAPIErrorZ); -extern const void (*CResult_NoneMonitorUpdateErrorZ_free)(LDKCResult_NoneMonitorUpdateErrorZ); +extern const LDKCResult_NoneAPIErrorZ (*CResult_NoneAPIErrorZ_err)(struct LDKAPIError); -extern const LDKCResult_NonePaymentSendFailureZ (*CResult_NonePaymentSendFailureZ_err)(LDKPaymentSendFailure); +extern const void (*CVec_ChannelDetailsZ_free)(LDKCVec_ChannelDetailsZ); extern const void (*CResult_NonePaymentSendFailureZ_free)(LDKCResult_NonePaymentSendFailureZ); -extern const LDKCResult_NonePeerHandleErrorZ (*CResult_NonePeerHandleErrorZ_err)(LDKPeerHandleError); +extern const LDKCResult_NonePaymentSendFailureZ (*CResult_NonePaymentSendFailureZ_err)(struct LDKPaymentSendFailure); -extern const void (*CResult_NonePeerHandleErrorZ_free)(LDKCResult_NonePeerHandleErrorZ); +extern const void (*CVec_NetAddressZ_free)(LDKCVec_NetAddressZ); -extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_err)(LDKSecp256k1Error); +extern const void (*CVec_ChannelMonitorZ_free)(LDKCVec_ChannelMonitorZ); -extern const void (*CResult_PublicKeySecpErrorZ_free)(LDKCResult_PublicKeySecpErrorZ); +extern const void (*CVec_u64Z_free)(LDKCVec_u64Z); -extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_ok)(LDKPublicKey); +extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ); -extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_err)(LDKLightningError); +extern const void (*CVec_UpdateFulfillHTLCZ_free)(LDKCVec_UpdateFulfillHTLCZ); -extern const void (*CResult_RouteLightningErrorZ_free)(LDKCResult_RouteLightningErrorZ); +extern const void (*CVec_UpdateFailHTLCZ_free)(LDKCVec_UpdateFailHTLCZ); -extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_ok)(LDKRoute); +extern const void (*CVec_UpdateFailMalformedHTLCZ_free)(LDKCVec_UpdateFailMalformedHTLCZ); -extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_err)(LDKSecp256k1Error); +extern const void (*CResult_boolLightningErrorZ_free)(LDKCResult_boolLightningErrorZ); -extern const void (*CResult_SecretKeySecpErrorZ_free)(LDKCResult_SecretKeySecpErrorZ); +extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_ok)(bool); -extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_ok)(LDKSecretKey); +extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_err)(struct LDKLightningError); -extern const void (*CResult_SignatureNoneZ_free)(LDKCResult_SignatureNoneZ); +extern const void (*C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free)(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ); -extern const LDKCResult_SignatureNoneZ (*CResult_SignatureNoneZ_ok)(LDKSignature); +extern const void (*CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free)(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ); -extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_err)(LDKSecp256k1Error); +extern const void (*CVec_NodeAnnouncementZ_free)(LDKCVec_NodeAnnouncementZ); -extern const void (*CResult_TxCreationKeysSecpErrorZ_free)(LDKCResult_TxCreationKeysSecpErrorZ); +extern const void (*CResult_NoneLightningErrorZ_free)(LDKCResult_NoneLightningErrorZ); -extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_ok)(LDKTxCreationKeys); +extern const LDKCResult_NoneLightningErrorZ (*CResult_NoneLightningErrorZ_err)(struct LDKLightningError); -extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_err)(LDKAccessError); +extern const void (*CVec_PublicKeyZ_free)(LDKCVec_PublicKeyZ); -extern const void (*CResult_TxOutAccessErrorZ_free)(LDKCResult_TxOutAccessErrorZ); +extern const void (*CVec_u8Z_free)(LDKCVec_u8Z); -extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_ok)(LDKTxOut); +extern const void (*CResult_CVec_u8ZPeerHandleErrorZ_free)(LDKCResult_CVec_u8ZPeerHandleErrorZ); -extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_err)(LDKLightningError); +extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_ok)(LDKCVec_u8Z); -extern const void (*CResult_boolLightningErrorZ_free)(LDKCResult_boolLightningErrorZ); +extern const LDKCResult_CVec_u8ZPeerHandleErrorZ (*CResult_CVec_u8ZPeerHandleErrorZ_err)(struct LDKPeerHandleError); -extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_ok)(bool); +extern const void (*CResult_NonePeerHandleErrorZ_free)(LDKCResult_NonePeerHandleErrorZ); -extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_err)(LDKPeerHandleError); +extern const LDKCResult_NonePeerHandleErrorZ (*CResult_NonePeerHandleErrorZ_err)(struct LDKPeerHandleError); extern const void (*CResult_boolPeerHandleErrorZ_free)(LDKCResult_boolPeerHandleErrorZ); extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_ok)(bool); -extern const void (*CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free)(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ); - -extern const void (*CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free)(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ); - -extern const void (*CVec_C2Tuple_u32TxOutZZ_free)(LDKCVec_C2Tuple_u32TxOutZZ); +extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_err)(struct LDKPeerHandleError); -extern const void (*CVec_C2Tuple_usizeTransactionZZ_free)(LDKCVec_C2Tuple_usizeTransactionZZ); +extern const void (*CResult_SecretKeySecpErrorZ_free)(LDKCResult_SecretKeySecpErrorZ); -extern const void (*CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free)(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ); +extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_ok)(struct LDKSecretKey); -extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ); +extern const LDKCResult_SecretKeySecpErrorZ (*CResult_SecretKeySecpErrorZ_err)(enum LDKSecp256k1Error); -extern const void (*CVec_ChannelDetailsZ_free)(LDKCVec_ChannelDetailsZ); +extern const void (*CResult_PublicKeySecpErrorZ_free)(LDKCResult_PublicKeySecpErrorZ); -extern const void (*CVec_ChannelMonitorZ_free)(LDKCVec_ChannelMonitorZ); +extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_ok)(struct LDKPublicKey); -extern const void (*CVec_EventZ_free)(LDKCVec_EventZ); +extern const LDKCResult_PublicKeySecpErrorZ (*CResult_PublicKeySecpErrorZ_err)(enum LDKSecp256k1Error); -extern const void (*CVec_HTLCOutputInCommitmentZ_free)(LDKCVec_HTLCOutputInCommitmentZ); +extern const void (*CResult_TxCreationKeysSecpErrorZ_free)(LDKCResult_TxCreationKeysSecpErrorZ); -extern const void (*CVec_MessageSendEventZ_free)(LDKCVec_MessageSendEventZ); +extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_ok)(struct LDKTxCreationKeys); -extern const void (*CVec_MonitorEventZ_free)(LDKCVec_MonitorEventZ); +extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_err)(enum LDKSecp256k1Error); -extern const void (*CVec_NetAddressZ_free)(LDKCVec_NetAddressZ); +extern const void (*CResult_TrustedCommitmentTransactionNoneZ_free)(LDKCResult_TrustedCommitmentTransactionNoneZ); -extern const void (*CVec_NodeAnnouncementZ_free)(LDKCVec_NodeAnnouncementZ); +extern const LDKCResult_TrustedCommitmentTransactionNoneZ (*CResult_TrustedCommitmentTransactionNoneZ_ok)(struct LDKTrustedCommitmentTransaction); -extern const void (*CVec_PublicKeyZ_free)(LDKCVec_PublicKeyZ); +extern const void (*CResult_CVec_SignatureZNoneZ_free)(LDKCResult_CVec_SignatureZNoneZ); -extern const void (*CVec_RouteHintZ_free)(LDKCVec_RouteHintZ); +extern const LDKCResult_CVec_SignatureZNoneZ (*CResult_CVec_SignatureZNoneZ_ok)(LDKCVec_SignatureZ); extern const void (*CVec_RouteHopZ_free)(LDKCVec_RouteHopZ); -extern const void (*CVec_SignatureZ_free)(LDKCVec_SignatureZ); - -extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutputDescriptorZ); - -extern const void (*CVec_TransactionZ_free)(LDKCVec_TransactionZ); - -extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ); +extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ); -extern const void (*CVec_UpdateFailHTLCZ_free)(LDKCVec_UpdateFailHTLCZ); +extern const void (*CVec_RouteHintZ_free)(LDKCVec_RouteHintZ); -extern const void (*CVec_UpdateFailMalformedHTLCZ_free)(LDKCVec_UpdateFailMalformedHTLCZ); +extern const void (*CResult_RouteLightningErrorZ_free)(LDKCResult_RouteLightningErrorZ); -extern const void (*CVec_UpdateFulfillHTLCZ_free)(LDKCVec_UpdateFulfillHTLCZ); +extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_ok)(struct LDKRoute); -extern const void (*CVec_u64Z_free)(LDKCVec_u64Z); +extern const LDKCResult_RouteLightningErrorZ (*CResult_RouteLightningErrorZ_err)(struct LDKLightningError); -extern const void (*CVec_u8Z_free)(LDKCVec_u8Z); +extern const uintptr_t MAX_BUF_SIZE; extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; -void Transaction_free(LDKTransaction _res); +extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; + +void Transaction_free(struct LDKTransaction _res); -void TxOut_free(LDKTxOut _res); +void TxOut_free(struct LDKTxOut _res); -LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, LDKTransaction b); +LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void); -LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(LDKOutPoint a, LDKCVec_u8Z b); +LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, LDKCVec_u8Z b); -LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, LDKTxOut b); +LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); -LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(LDKThirtyTwoBytes a, LDKCVec_C2Tuple_u32TxOutZZ b); +LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, LDKCVec_C2Tuple_u32TxOutZZ b); LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b); -LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(LDKSignature a, LDKCVec_SignatureZ b); +LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, LDKCVec_SignatureZ b); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); -LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); - LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); -LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(LDKChannelAnnouncement a, LDKChannelUpdate b, LDKChannelUpdate c); +LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); + +LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); -LDKC2Tuple_HTLCOutputInCommitmentSignatureZ C2Tuple_HTLCOutputInCommitmentSignatureZ_new(LDKHTLCOutputInCommitment a, LDKSignature b); +LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); -LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); +LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); -void Event_free(LDKEvent this_ptr); +void Event_free(struct LDKEvent this_ptr); -LDKEvent Event_clone(const LDKEvent *orig); +struct LDKEvent Event_clone(const struct LDKEvent *orig); -void MessageSendEvent_free(LDKMessageSendEvent this_ptr); +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); -LDKMessageSendEvent MessageSendEvent_clone(const LDKMessageSendEvent *orig); +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *orig); /** * Calls the free function if one is set */ -void MessageSendEventsProvider_free(LDKMessageSendEventsProvider this_ptr); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); /** * Calls the free function if one is set */ -void EventsProvider_free(LDKEventsProvider this_ptr); +void EventsProvider_free(struct LDKEventsProvider this_ptr); -void APIError_free(LDKAPIError this_ptr); +void APIError_free(struct LDKAPIError this_ptr); -LDKAPIError APIError_clone(const LDKAPIError *orig); +struct LDKAPIError APIError_clone(const struct LDKAPIError *orig); -LDKLevel Level_clone(const LDKLevel *orig); +enum LDKLevel Level_clone(const enum LDKLevel *orig); /** * Returns the most verbose logging level. */ -MUST_USE_RES LDKLevel Level_max(void); +MUST_USE_RES enum LDKLevel Level_max(void); /** * Calls the free function if one is set */ -void Logger_free(LDKLogger this_ptr); +void Logger_free(struct LDKLogger this_ptr); -void ChannelHandshakeConfig_free(LDKChannelHandshakeConfig this_ptr); +void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_ptr); -LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const LDKChannelHandshakeConfig *orig); +struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *orig); /** * Confirmations we will wait for before considering the channel locked in. @@ -3364,7 +3525,7 @@ LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const LDKChannelHandshake * * Default value: 6. */ -uint32_t ChannelHandshakeConfig_get_minimum_depth(const LDKChannelHandshakeConfig *this_ptr); +uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *this_ptr); /** * Confirmations we will wait for before considering the channel locked in. @@ -3373,7 +3534,7 @@ uint32_t ChannelHandshakeConfig_get_minimum_depth(const LDKChannelHandshakeConfi * * Default value: 6. */ -void ChannelHandshakeConfig_set_minimum_depth(LDKChannelHandshakeConfig *this_ptr, uint32_t val); +void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *this_ptr, uint32_t val); /** * Set to the amount of time we require our counterparty to wait to claim their money. @@ -3389,7 +3550,7 @@ void ChannelHandshakeConfig_set_minimum_depth(LDKChannelHandshakeConfig *this_pt * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel * opening so you can tweak config to ask for more security, not less. */ -uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const LDKChannelHandshakeConfig *this_ptr); +uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *this_ptr); /** * Set to the amount of time we require our counterparty to wait to claim their money. @@ -3405,7 +3566,7 @@ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const LDKChannelHandshakeC * Default value: BREAKDOWN_TIMEOUT (currently 144), we enforce it as a minimum at channel * opening so you can tweak config to ask for more security, not less. */ -void ChannelHandshakeConfig_set_our_to_self_delay(LDKChannelHandshakeConfig *this_ptr, uint16_t val); +void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *this_ptr, uint16_t val); /** * Set to the smallest value HTLC we will accept to process. @@ -3416,7 +3577,7 @@ void ChannelHandshakeConfig_set_our_to_self_delay(LDKChannelHandshakeConfig *thi * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required * by the protocol. */ -uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const LDKChannelHandshakeConfig *this_ptr); +uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *this_ptr); /** * Set to the smallest value HTLC we will accept to process. @@ -3427,15 +3588,15 @@ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const LDKChannelHandsh * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required * by the protocol. */ -void ChannelHandshakeConfig_set_our_htlc_minimum_msat(LDKChannelHandshakeConfig *this_ptr, uint64_t val); +void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *this_ptr, uint64_t val); -MUST_USE_RES LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg); -MUST_USE_RES LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); -void ChannelHandshakeLimits_free(LDKChannelHandshakeLimits this_ptr); +void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_ptr); -LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const LDKChannelHandshakeLimits *orig); +struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *orig); /** * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so @@ -3443,7 +3604,7 @@ LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const LDKChannelHandshake * * Default value: 0. */ -uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const LDKChannelHandshakeLimits *this_ptr); +uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *this_ptr); /** * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so @@ -3451,7 +3612,7 @@ uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const LDKChannelHandsha * * Default value: 0. */ -void ChannelHandshakeLimits_set_min_funding_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val); +void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *this_ptr, uint64_t val); /** * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows @@ -3459,7 +3620,7 @@ void ChannelHandshakeLimits_set_min_funding_satoshis(LDKChannelHandshakeLimits * * * Default value: u64::max_value. */ -uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const LDKChannelHandshakeLimits *this_ptr); +uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *this_ptr); /** * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows @@ -3467,7 +3628,7 @@ uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const LDKChannelHandsh * * Default value: u64::max_value. */ -void ChannelHandshakeLimits_set_max_htlc_minimum_msat(LDKChannelHandshakeLimits *this_ptr, uint64_t val); +void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *this_ptr, uint64_t val); /** * The remote node sets a limit on the maximum value of pending HTLCs to them at any given @@ -3475,7 +3636,7 @@ void ChannelHandshakeLimits_set_max_htlc_minimum_msat(LDKChannelHandshakeLimits * * Default value: 0. */ -uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const LDKChannelHandshakeLimits *this_ptr); +uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *this_ptr); /** * The remote node sets a limit on the maximum value of pending HTLCs to them at any given @@ -3483,7 +3644,7 @@ uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const LDKC * * Default value: 0. */ -void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(LDKChannelHandshakeLimits *this_ptr, uint64_t val); +void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *this_ptr, uint64_t val); /** * The remote node will require we keep a certain amount in direct payment to ourselves at all @@ -3492,7 +3653,7 @@ void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(LDKChannelHand * * Default value: u64::max_value. */ -uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const LDKChannelHandshakeLimits *this_ptr); +uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *this_ptr); /** * The remote node will require we keep a certain amount in direct payment to ourselves at all @@ -3501,7 +3662,7 @@ uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const LDKChanne * * Default value: u64::max_value. */ -void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val); +void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *this_ptr, uint64_t val); /** * The remote node sets a limit on the maximum number of pending HTLCs to them at any given @@ -3509,7 +3670,7 @@ void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(LDKChannelHandshake * * Default value: 0. */ -uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const LDKChannelHandshakeLimits *this_ptr); +uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *this_ptr); /** * The remote node sets a limit on the maximum number of pending HTLCs to them at any given @@ -3517,7 +3678,7 @@ uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const LDKChannelHands * * Default value: 0. */ -void ChannelHandshakeLimits_set_min_max_accepted_htlcs(LDKChannelHandshakeLimits *this_ptr, uint16_t val); +void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *this_ptr, uint16_t val); /** * Outputs below a certain value will not be added to on-chain transactions. The dust value is @@ -3530,7 +3691,7 @@ void ChannelHandshakeLimits_set_min_max_accepted_htlcs(LDKChannelHandshakeLimits * * Default value: 546, the current dust limit on the Bitcoin network. */ -uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const LDKChannelHandshakeLimits *this_ptr); +uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *this_ptr); /** * Outputs below a certain value will not be added to on-chain transactions. The dust value is @@ -3543,7 +3704,7 @@ uint64_t ChannelHandshakeLimits_get_min_dust_limit_satoshis(const LDKChannelHand * * Default value: 546, the current dust limit on the Bitcoin network. */ -void ChannelHandshakeLimits_set_min_dust_limit_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val); +void ChannelHandshakeLimits_set_min_dust_limit_satoshis(struct LDKChannelHandshakeLimits *this_ptr, uint64_t val); /** * Maximum allowed threshold above which outputs will not be generated in their commitment @@ -3552,7 +3713,7 @@ void ChannelHandshakeLimits_set_min_dust_limit_satoshis(LDKChannelHandshakeLimit * * Default value: u64::max_value. */ -uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const LDKChannelHandshakeLimits *this_ptr); +uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const struct LDKChannelHandshakeLimits *this_ptr); /** * Maximum allowed threshold above which outputs will not be generated in their commitment @@ -3561,7 +3722,7 @@ uint64_t ChannelHandshakeLimits_get_max_dust_limit_satoshis(const LDKChannelHand * * Default value: u64::max_value. */ -void ChannelHandshakeLimits_set_max_dust_limit_satoshis(LDKChannelHandshakeLimits *this_ptr, uint64_t val); +void ChannelHandshakeLimits_set_max_dust_limit_satoshis(struct LDKChannelHandshakeLimits *this_ptr, uint64_t val); /** * Before a channel is usable the funding transaction will need to be confirmed by at least a @@ -3571,7 +3732,7 @@ void ChannelHandshakeLimits_set_max_dust_limit_satoshis(LDKChannelHandshakeLimit * * Default value: 144, or roughly one day and only applies to outbound channels. */ -uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const LDKChannelHandshakeLimits *this_ptr); +uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *this_ptr); /** * Before a channel is usable the funding transaction will need to be confirmed by at least a @@ -3581,7 +3742,7 @@ uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const LDKChannelHandshakeL * * Default value: 144, or roughly one day and only applies to outbound channels. */ -void ChannelHandshakeLimits_set_max_minimum_depth(LDKChannelHandshakeLimits *this_ptr, uint32_t val); +void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *this_ptr, uint32_t val); /** * Set to force the incoming channel to match our announced channel preference in @@ -3590,7 +3751,7 @@ void ChannelHandshakeLimits_set_max_minimum_depth(LDKChannelHandshakeLimits *thi * Default value: true, to make the default that no announced channels are possible (which is * appropriate for any nodes which are not online very reliably). */ -bool ChannelHandshakeLimits_get_force_announced_channel_preference(const LDKChannelHandshakeLimits *this_ptr); +bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *this_ptr); /** * Set to force the incoming channel to match our announced channel preference in @@ -3599,7 +3760,7 @@ bool ChannelHandshakeLimits_get_force_announced_channel_preference(const LDKChan * Default value: true, to make the default that no announced channels are possible (which is * appropriate for any nodes which are not online very reliably). */ -void ChannelHandshakeLimits_set_force_announced_channel_preference(LDKChannelHandshakeLimits *this_ptr, bool val); +void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *this_ptr, bool val); /** * Set to the amount of time we're willing to wait to claim money back to us. @@ -3610,7 +3771,7 @@ void ChannelHandshakeLimits_set_force_announced_channel_preference(LDKChannelHan * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) */ -uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const LDKChannelHandshakeLimits *this_ptr); +uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *this_ptr); /** * Set to the amount of time we're willing to wait to claim money back to us. @@ -3621,15 +3782,15 @@ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const LDKChannelHandshak * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) */ -void ChannelHandshakeLimits_set_their_to_self_delay(LDKChannelHandshakeLimits *this_ptr, uint16_t val); +void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *this_ptr, uint16_t val); -MUST_USE_RES LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint64_t min_dust_limit_satoshis_arg, uint64_t max_dust_limit_satoshis_arg, uint32_t max_minimum_depth_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); -MUST_USE_RES LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); -void ChannelConfig_free(LDKChannelConfig this_ptr); +void ChannelConfig_free(struct LDKChannelConfig this_ptr); -LDKChannelConfig ChannelConfig_clone(const LDKChannelConfig *orig); +struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *orig); /** * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. @@ -3638,7 +3799,7 @@ LDKChannelConfig ChannelConfig_clone(const LDKChannelConfig *orig); * * Default value: 0. */ -uint32_t ChannelConfig_get_fee_proportional_millionths(const LDKChannelConfig *this_ptr); +uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelConfig *this_ptr); /** * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. @@ -3647,7 +3808,7 @@ uint32_t ChannelConfig_get_fee_proportional_millionths(const LDKChannelConfig *t * * Default value: 0. */ -void ChannelConfig_set_fee_proportional_millionths(LDKChannelConfig *this_ptr, uint32_t val); +void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *this_ptr, uint32_t val); /** * Set to announce the channel publicly and notify all nodes that they can route via this @@ -3662,7 +3823,7 @@ void ChannelConfig_set_fee_proportional_millionths(LDKChannelConfig *this_ptr, u * * Default value: false. */ -bool ChannelConfig_get_announced_channel(const LDKChannelConfig *this_ptr); +bool ChannelConfig_get_announced_channel(const struct LDKChannelConfig *this_ptr); /** * Set to announce the channel publicly and notify all nodes that they can route via this @@ -3677,7 +3838,7 @@ bool ChannelConfig_get_announced_channel(const LDKChannelConfig *this_ptr); * * Default value: false. */ -void ChannelConfig_set_announced_channel(LDKChannelConfig *this_ptr, bool val); +void ChannelConfig_set_announced_channel(struct LDKChannelConfig *this_ptr, bool val); /** * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty @@ -3692,7 +3853,7 @@ void ChannelConfig_set_announced_channel(LDKChannelConfig *this_ptr, bool val); * * Default value: true. */ -bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const LDKChannelConfig *this_ptr); +bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelConfig *this_ptr); /** * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty @@ -3707,84 +3868,84 @@ bool ChannelConfig_get_commit_upfront_shutdown_pubkey(const LDKChannelConfig *th * * Default value: true. */ -void ChannelConfig_set_commit_upfront_shutdown_pubkey(LDKChannelConfig *this_ptr, bool val); +void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *this_ptr, bool val); -MUST_USE_RES LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); -MUST_USE_RES LDKChannelConfig ChannelConfig_default(void); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); -LDKCVec_u8Z ChannelConfig_write(const LDKChannelConfig *obj); +LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *obj); -LDKChannelConfig ChannelConfig_read(LDKu8slice ser); +struct LDKChannelConfig ChannelConfig_read(struct LDKu8slice ser); -void UserConfig_free(LDKUserConfig this_ptr); +void UserConfig_free(struct LDKUserConfig this_ptr); -LDKUserConfig UserConfig_clone(const LDKUserConfig *orig); +struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *orig); /** * Channel config that we propose to our counterparty. */ -LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const LDKUserConfig *this_ptr); +struct LDKChannelHandshakeConfig UserConfig_get_own_channel_config(const struct LDKUserConfig *this_ptr); /** * Channel config that we propose to our counterparty. */ -void UserConfig_set_own_channel_config(LDKUserConfig *this_ptr, LDKChannelHandshakeConfig val); +void UserConfig_set_own_channel_config(struct LDKUserConfig *this_ptr, struct LDKChannelHandshakeConfig val); /** * Limits applied to our counterparty's proposed channel config settings. */ -LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const LDKUserConfig *this_ptr); +struct LDKChannelHandshakeLimits UserConfig_get_peer_channel_config_limits(const struct LDKUserConfig *this_ptr); /** * Limits applied to our counterparty's proposed channel config settings. */ -void UserConfig_set_peer_channel_config_limits(LDKUserConfig *this_ptr, LDKChannelHandshakeLimits val); +void UserConfig_set_peer_channel_config_limits(struct LDKUserConfig *this_ptr, struct LDKChannelHandshakeLimits val); /** * Channel config which affects behavior during channel lifetime. */ -LDKChannelConfig UserConfig_get_channel_options(const LDKUserConfig *this_ptr); +struct LDKChannelConfig UserConfig_get_channel_options(const struct LDKUserConfig *this_ptr); /** * Channel config which affects behavior during channel lifetime. */ -void UserConfig_set_channel_options(LDKUserConfig *this_ptr, LDKChannelConfig val); +void UserConfig_set_channel_options(struct LDKUserConfig *this_ptr, struct LDKChannelConfig val); -MUST_USE_RES LDKUserConfig UserConfig_new(LDKChannelHandshakeConfig own_channel_config_arg, LDKChannelHandshakeLimits peer_channel_config_limits_arg, LDKChannelConfig channel_options_arg); +MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg); -MUST_USE_RES LDKUserConfig UserConfig_default(void); +MUST_USE_RES struct LDKUserConfig UserConfig_default(void); -LDKAccessError AccessError_clone(const LDKAccessError *orig); +enum LDKAccessError AccessError_clone(const enum LDKAccessError *orig); /** * Calls the free function if one is set */ -void Access_free(LDKAccess this_ptr); +void Access_free(struct LDKAccess this_ptr); /** * Calls the free function if one is set */ -void Watch_free(LDKWatch this_ptr); +void Watch_free(struct LDKWatch this_ptr); /** * Calls the free function if one is set */ -void Filter_free(LDKFilter this_ptr); +void Filter_free(struct LDKFilter this_ptr); /** * Calls the free function if one is set */ -void BroadcasterInterface_free(LDKBroadcasterInterface this_ptr); +void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); -LDKConfirmationTarget ConfirmationTarget_clone(const LDKConfirmationTarget *orig); +enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *orig); /** * Calls the free function if one is set */ -void FeeEstimator_free(LDKFeeEstimator this_ptr); +void FeeEstimator_free(struct LDKFeeEstimator this_ptr); -void ChainMonitor_free(LDKChainMonitor this_ptr); +void ChainMonitor_free(struct LDKChainMonitor this_ptr); /** * Dispatches to per-channel monitors, which are responsible for updating their on-chain view @@ -3801,7 +3962,7 @@ void ChainMonitor_free(LDKChainMonitor this_ptr); * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events * [`chain::Filter`]: ../trait.Filter.html */ -void ChainMonitor_block_connected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); +void ChainMonitor_block_connected(const struct LDKChainMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); /** * Dispatches to per-channel monitors, which are responsible for updating their on-chain view @@ -3810,7 +3971,7 @@ void ChainMonitor_block_connected(const LDKChainMonitor *this_arg, const uint8_t * * [`ChannelMonitor::block_disconnected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_disconnected */ -void ChainMonitor_block_disconnected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height); +void ChainMonitor_block_disconnected(const struct LDKChainMonitor *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height); /** * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. @@ -3823,15 +3984,15 @@ void ChainMonitor_block_disconnected(const LDKChainMonitor *this_arg, const uint * * [`chain::Filter`]: ../trait.Filter.html */ -MUST_USE_RES LDKChainMonitor ChainMonitor_new(LDKFilter *chain_source, LDKBroadcasterInterface broadcaster, LDKLogger logger, LDKFeeEstimator feeest, LDKPersist persister); +MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); -LDKWatch ChainMonitor_as_Watch(const LDKChainMonitor *this_arg); +struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *this_arg); -LDKEventsProvider ChainMonitor_as_EventsProvider(const LDKChainMonitor *this_arg); +struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *this_arg); -void ChannelMonitorUpdate_free(LDKChannelMonitorUpdate this_ptr); +void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_ptr); -LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const LDKChannelMonitorUpdate *orig); +struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *orig); /** * The sequence number of this update. Updates *must* be replayed in-order according to this @@ -3848,7 +4009,7 @@ LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const LDKChannelMonitorUpdate * * [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html */ -uint64_t ChannelMonitorUpdate_get_update_id(const LDKChannelMonitorUpdate *this_ptr); +uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *this_ptr); /** * The sequence number of this update. Updates *must* be replayed in-order according to this @@ -3865,29 +4026,29 @@ uint64_t ChannelMonitorUpdate_get_update_id(const LDKChannelMonitorUpdate *this_ * * [`CLOSED_CHANNEL_UPDATE_ID`]: constant.CLOSED_CHANNEL_UPDATE_ID.html */ -void ChannelMonitorUpdate_set_update_id(LDKChannelMonitorUpdate *this_ptr, uint64_t val); +void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *this_ptr, uint64_t val); -LDKCVec_u8Z ChannelMonitorUpdate_write(const LDKChannelMonitorUpdate *obj); +LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *obj); -LDKChannelMonitorUpdate ChannelMonitorUpdate_read(LDKu8slice ser); +struct LDKChannelMonitorUpdate ChannelMonitorUpdate_read(struct LDKu8slice ser); -LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const LDKChannelMonitorUpdateErr *orig); +enum LDKChannelMonitorUpdateErr ChannelMonitorUpdateErr_clone(const enum LDKChannelMonitorUpdateErr *orig); -void MonitorUpdateError_free(LDKMonitorUpdateError this_ptr); +void MonitorUpdateError_free(struct LDKMonitorUpdateError this_ptr); -void MonitorEvent_free(LDKMonitorEvent this_ptr); +void MonitorEvent_free(struct LDKMonitorEvent this_ptr); -LDKMonitorEvent MonitorEvent_clone(const LDKMonitorEvent *orig); +struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *orig); -void HTLCUpdate_free(LDKHTLCUpdate this_ptr); +void HTLCUpdate_free(struct LDKHTLCUpdate this_ptr); -LDKHTLCUpdate HTLCUpdate_clone(const LDKHTLCUpdate *orig); +struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *orig); -LDKCVec_u8Z HTLCUpdate_write(const LDKHTLCUpdate *obj); +LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *obj); -LDKHTLCUpdate HTLCUpdate_read(LDKu8slice ser); +struct LDKHTLCUpdate HTLCUpdate_read(struct LDKu8slice ser); -void ChannelMonitor_free(LDKChannelMonitor this_ptr); +void ChannelMonitor_free(struct LDKChannelMonitor this_ptr); /** * Updates a ChannelMonitor on the basis of some new information provided by the Channel @@ -3895,18 +4056,18 @@ void ChannelMonitor_free(LDKChannelMonitor this_ptr); * * panics if the given update is not the next update by update_id. */ -MUST_USE_RES LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(LDKChannelMonitor *this_arg, const LDKChannelMonitorUpdate *updates, const LDKBroadcasterInterface *broadcaster, const LDKFeeEstimator *fee_estimator, const LDKLogger *logger); +MUST_USE_RES LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(struct LDKChannelMonitor *this_arg, const struct LDKChannelMonitorUpdate *updates, const struct LDKBroadcasterInterface *broadcaster, const struct LDKFeeEstimator *fee_estimator, const struct LDKLogger *logger); /** * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this * ChannelMonitor. */ -MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const LDKChannelMonitor *this_arg); +MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *this_arg); /** * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. */ -MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDKChannelMonitor *this_arg); +MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *this_arg); /** * Get the list of HTLCs who's status has been updated on chain. This should be called by @@ -3914,7 +4075,7 @@ MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDK * * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events */ -MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(LDKChannelMonitor *this_arg); +MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(struct LDKChannelMonitor *this_arg); /** * Gets the list of pending events which were generated by previous actions, clearing the list @@ -3924,7 +4085,7 @@ MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_ * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do * no internal locking in ChannelMonitors. */ -MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg); +MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(struct LDKChannelMonitor *this_arg); /** * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of @@ -3937,7 +4098,7 @@ MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChann * 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_holder_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger); +MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(struct LDKChannelMonitor *this_arg, const struct LDKLogger *logger); /** * Processes transactions in a newly connected block, which may result in any of the following: @@ -3952,169 +4113,188 @@ MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_tx * * [`get_outputs_to_watch`]: #method.get_outputs_to_watch */ -MUST_USE_RES LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ChannelMonitor_block_connected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger); +MUST_USE_RES LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ChannelMonitor_block_connected(struct LDKChannelMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** * Determines if the disconnected block contained any transactions of interest and updates * appropriately. */ -void ChannelMonitor_block_disconnected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger); +void ChannelMonitor_block_disconnected(struct LDKChannelMonitor *this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** * Calls the free function if one is set */ -void Persist_free(LDKPersist this_ptr); +void Persist_free(struct LDKPersist this_ptr); -void OutPoint_free(LDKOutPoint this_ptr); +void OutPoint_free(struct LDKOutPoint this_ptr); -LDKOutPoint OutPoint_clone(const LDKOutPoint *orig); +struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *orig); /** * The referenced transaction's txid. */ -const uint8_t (*OutPoint_get_txid(const LDKOutPoint *this_ptr))[32]; +const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *this_ptr))[32]; /** * The referenced transaction's txid. */ -void OutPoint_set_txid(LDKOutPoint *this_ptr, LDKThirtyTwoBytes val); +void OutPoint_set_txid(struct LDKOutPoint *this_ptr, struct LDKThirtyTwoBytes val); /** * The index of the referenced output in its transaction's vout. */ -uint16_t OutPoint_get_index(const LDKOutPoint *this_ptr); +uint16_t OutPoint_get_index(const struct LDKOutPoint *this_ptr); /** * The index of the referenced output in its transaction's vout. */ -void OutPoint_set_index(LDKOutPoint *this_ptr, uint16_t val); +void OutPoint_set_index(struct LDKOutPoint *this_ptr, uint16_t val); -MUST_USE_RES LDKOutPoint OutPoint_new(LDKThirtyTwoBytes txid_arg, uint16_t index_arg); +MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); /** * Convert an `OutPoint` to a lightning channel id. */ -MUST_USE_RES LDKThirtyTwoBytes OutPoint_to_channel_id(const LDKOutPoint *this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *this_arg); -LDKCVec_u8Z OutPoint_write(const LDKOutPoint *obj); +LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *obj); -LDKOutPoint OutPoint_read(LDKu8slice ser); +struct LDKOutPoint OutPoint_read(struct LDKu8slice ser); -void SpendableOutputDescriptor_free(LDKSpendableOutputDescriptor this_ptr); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); -LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const LDKSpendableOutputDescriptor *orig); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *orig); -LDKChannelKeys ChannelKeys_clone(const LDKChannelKeys *orig); +struct LDKChannelKeys ChannelKeys_clone(const struct LDKChannelKeys *orig); /** * Calls the free function if one is set */ -void ChannelKeys_free(LDKChannelKeys this_ptr); +void ChannelKeys_free(struct LDKChannelKeys this_ptr); /** * Calls the free function if one is set */ -void KeysInterface_free(LDKKeysInterface this_ptr); +void KeysInterface_free(struct LDKKeysInterface this_ptr); -void InMemoryChannelKeys_free(LDKInMemoryChannelKeys this_ptr); +void InMemoryChannelKeys_free(struct LDKInMemoryChannelKeys this_ptr); -LDKInMemoryChannelKeys InMemoryChannelKeys_clone(const LDKInMemoryChannelKeys *orig); +struct LDKInMemoryChannelKeys InMemoryChannelKeys_clone(const struct LDKInMemoryChannelKeys *orig); /** * Private key of anchor tx */ -const uint8_t (*InMemoryChannelKeys_get_funding_key(const LDKInMemoryChannelKeys *this_ptr))[32]; +const uint8_t (*InMemoryChannelKeys_get_funding_key(const struct LDKInMemoryChannelKeys *this_ptr))[32]; /** * Private key of anchor tx */ -void InMemoryChannelKeys_set_funding_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); +void InMemoryChannelKeys_set_funding_key(struct LDKInMemoryChannelKeys *this_ptr, struct LDKSecretKey val); /** * Holder secret key for blinded revocation pubkey */ -const uint8_t (*InMemoryChannelKeys_get_revocation_base_key(const LDKInMemoryChannelKeys *this_ptr))[32]; +const uint8_t (*InMemoryChannelKeys_get_revocation_base_key(const struct LDKInMemoryChannelKeys *this_ptr))[32]; /** * Holder secret key for blinded revocation pubkey */ -void InMemoryChannelKeys_set_revocation_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); +void InMemoryChannelKeys_set_revocation_base_key(struct LDKInMemoryChannelKeys *this_ptr, struct LDKSecretKey val); /** * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -const uint8_t (*InMemoryChannelKeys_get_payment_key(const LDKInMemoryChannelKeys *this_ptr))[32]; +const uint8_t (*InMemoryChannelKeys_get_payment_key(const struct LDKInMemoryChannelKeys *this_ptr))[32]; /** * Holder secret key used for our balance in counterparty-broadcasted commitment transactions */ -void InMemoryChannelKeys_set_payment_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); +void InMemoryChannelKeys_set_payment_key(struct LDKInMemoryChannelKeys *this_ptr, struct LDKSecretKey val); /** * Holder secret key used in HTLC tx */ -const uint8_t (*InMemoryChannelKeys_get_delayed_payment_base_key(const LDKInMemoryChannelKeys *this_ptr))[32]; +const uint8_t (*InMemoryChannelKeys_get_delayed_payment_base_key(const struct LDKInMemoryChannelKeys *this_ptr))[32]; /** * Holder secret key used in HTLC tx */ -void InMemoryChannelKeys_set_delayed_payment_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); +void InMemoryChannelKeys_set_delayed_payment_base_key(struct LDKInMemoryChannelKeys *this_ptr, struct LDKSecretKey val); /** * Holder htlc secret key used in commitment tx htlc outputs */ -const uint8_t (*InMemoryChannelKeys_get_htlc_base_key(const LDKInMemoryChannelKeys *this_ptr))[32]; +const uint8_t (*InMemoryChannelKeys_get_htlc_base_key(const struct LDKInMemoryChannelKeys *this_ptr))[32]; /** * Holder htlc secret key used in commitment tx htlc outputs */ -void InMemoryChannelKeys_set_htlc_base_key(LDKInMemoryChannelKeys *this_ptr, LDKSecretKey val); +void InMemoryChannelKeys_set_htlc_base_key(struct LDKInMemoryChannelKeys *this_ptr, struct LDKSecretKey val); /** * Commitment seed */ -const uint8_t (*InMemoryChannelKeys_get_commitment_seed(const LDKInMemoryChannelKeys *this_ptr))[32]; +const uint8_t (*InMemoryChannelKeys_get_commitment_seed(const struct LDKInMemoryChannelKeys *this_ptr))[32]; /** * Commitment seed */ -void InMemoryChannelKeys_set_commitment_seed(LDKInMemoryChannelKeys *this_ptr, LDKThirtyTwoBytes val); +void InMemoryChannelKeys_set_commitment_seed(struct LDKInMemoryChannelKeys *this_ptr, struct LDKThirtyTwoBytes val); /** * Create a new InMemoryChannelKeys */ -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); +MUST_USE_RES struct LDKInMemoryChannelKeys InMemoryChannelKeys_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, LDKC2Tuple_u64u64Z key_derivation_params); /** * Counterparty pubkeys. - * Will panic if on_accept wasn't called. + * Will panic if ready_channel wasn't called. */ -MUST_USE_RES LDKChannelPublicKeys InMemoryChannelKeys_counterparty_pubkeys(const LDKInMemoryChannelKeys *this_arg); +MUST_USE_RES struct LDKChannelPublicKeys InMemoryChannelKeys_counterparty_pubkeys(const struct LDKInMemoryChannelKeys *this_arg); /** * 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's transactions. - * Will panic if on_accept wasn't called. + * broadcast a transaction. + * Will panic if ready_channel wasn't called. */ -MUST_USE_RES uint16_t InMemoryChannelKeys_counterparty_selected_contest_delay(const LDKInMemoryChannelKeys *this_arg); +MUST_USE_RES uint16_t InMemoryChannelKeys_counterparty_selected_contest_delay(const struct LDKInMemoryChannelKeys *this_arg); /** * 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. + * Will panic if ready_channel wasn't called. + */ +MUST_USE_RES uint16_t InMemoryChannelKeys_holder_selected_contest_delay(const struct LDKInMemoryChannelKeys *this_arg); + +/** + * Whether the holder is the initiator + * Will panic if ready_channel wasn't called. */ -MUST_USE_RES uint16_t InMemoryChannelKeys_holder_selected_contest_delay(const LDKInMemoryChannelKeys *this_arg); +MUST_USE_RES bool InMemoryChannelKeys_is_outbound(const struct LDKInMemoryChannelKeys *this_arg); -LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const LDKInMemoryChannelKeys *this_arg); +/** + * Funding outpoint + * Will panic if ready_channel wasn't called. + */ +MUST_USE_RES struct LDKOutPoint InMemoryChannelKeys_funding_outpoint(const struct LDKInMemoryChannelKeys *this_arg); + +/** + * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or + * building transactions. + * + * Will panic if ready_channel wasn't called. + */ +MUST_USE_RES struct LDKChannelTransactionParameters InMemoryChannelKeys_get_channel_parameters(const struct LDKInMemoryChannelKeys *this_arg); -LDKCVec_u8Z InMemoryChannelKeys_write(const LDKInMemoryChannelKeys *obj); +struct LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const struct LDKInMemoryChannelKeys *this_arg); -LDKInMemoryChannelKeys InMemoryChannelKeys_read(LDKu8slice ser); +LDKCVec_u8Z InMemoryChannelKeys_write(const struct LDKInMemoryChannelKeys *obj); -void KeysManager_free(LDKKeysManager this_ptr); +struct LDKInMemoryChannelKeys InMemoryChannelKeys_read(struct LDKu8slice ser); + +void KeysManager_free(struct LDKKeysManager this_ptr); /** * Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your @@ -4137,7 +4317,7 @@ void KeysManager_free(LDKKeysManager this_ptr); * versions. Once the library is more fully supported, the docs will be updated to include a * detailed description of the guarantee. */ -MUST_USE_RES LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], LDKNetwork network, uint64_t starting_time_secs, uint32_t starting_time_nanos); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], enum LDKNetwork network, uint64_t starting_time_secs, uint32_t starting_time_nanos); /** * Derive an old set of ChannelKeys for per-channel secrets based on a key derivation @@ -4146,15 +4326,15 @@ MUST_USE_RES LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], LDKNetwor * ChannelKeys::key_derivation_params and is provided inside DynamicOuputP2WSH in case of * onchain output detection for which a corresponding delayed_payment_key must be derived. */ -MUST_USE_RES LDKInMemoryChannelKeys KeysManager_derive_channel_keys(const LDKKeysManager *this_arg, uint64_t channel_value_satoshis, uint64_t params_1, uint64_t params_2); +MUST_USE_RES struct LDKInMemoryChannelKeys KeysManager_derive_channel_keys(const struct LDKKeysManager *this_arg, uint64_t channel_value_satoshis, uint64_t params_1, uint64_t params_2); -LDKKeysInterface KeysManager_as_KeysInterface(const LDKKeysManager *this_arg); +struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *this_arg); -void ChannelManager_free(LDKChannelManager this_ptr); +void ChannelManager_free(struct LDKChannelManager this_ptr); -void ChannelDetails_free(LDKChannelDetails this_ptr); +void ChannelDetails_free(struct LDKChannelDetails this_ptr); -LDKChannelDetails ChannelDetails_clone(const LDKChannelDetails *orig); +struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *orig); /** * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, @@ -4162,7 +4342,7 @@ LDKChannelDetails ChannelDetails_clone(const LDKChannelDetails *orig); * Note that this means this value is *not* persistent - it can change once during the * lifetime of the channel. */ -const uint8_t (*ChannelDetails_get_channel_id(const LDKChannelDetails *this_ptr))[32]; +const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *this_ptr))[32]; /** * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, @@ -4170,51 +4350,51 @@ const uint8_t (*ChannelDetails_get_channel_id(const LDKChannelDetails *this_ptr) * Note that this means this value is *not* persistent - it can change once during the * lifetime of the channel. */ -void ChannelDetails_set_channel_id(LDKChannelDetails *this_ptr, LDKThirtyTwoBytes val); +void ChannelDetails_set_channel_id(struct LDKChannelDetails *this_ptr, struct LDKThirtyTwoBytes val); /** * The node_id of our counterparty */ -LDKPublicKey ChannelDetails_get_remote_network_id(const LDKChannelDetails *this_ptr); +struct LDKPublicKey ChannelDetails_get_remote_network_id(const struct LDKChannelDetails *this_ptr); /** * The node_id of our counterparty */ -void ChannelDetails_set_remote_network_id(LDKChannelDetails *this_ptr, LDKPublicKey val); +void ChannelDetails_set_remote_network_id(struct LDKChannelDetails *this_ptr, struct LDKPublicKey val); /** * The Features the channel counterparty provided upon last connection. * Useful for routing as it is the most up-to-date copy of the counterparty's features and * many routing-relevant features are present in the init context. */ -LDKInitFeatures ChannelDetails_get_counterparty_features(const LDKChannelDetails *this_ptr); +struct LDKInitFeatures ChannelDetails_get_counterparty_features(const struct LDKChannelDetails *this_ptr); /** * The Features the channel counterparty provided upon last connection. * Useful for routing as it is the most up-to-date copy of the counterparty's features and * many routing-relevant features are present in the init context. */ -void ChannelDetails_set_counterparty_features(LDKChannelDetails *this_ptr, LDKInitFeatures val); +void ChannelDetails_set_counterparty_features(struct LDKChannelDetails *this_ptr, struct LDKInitFeatures val); /** * The value, in satoshis, of this channel as appears in the funding output */ -uint64_t ChannelDetails_get_channel_value_satoshis(const LDKChannelDetails *this_ptr); +uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *this_ptr); /** * The value, in satoshis, of this channel as appears in the funding output */ -void ChannelDetails_set_channel_value_satoshis(LDKChannelDetails *this_ptr, uint64_t val); +void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *this_ptr, uint64_t val); /** * The user_id passed in to create_channel, or 0 if the channel was inbound. */ -uint64_t ChannelDetails_get_user_id(const LDKChannelDetails *this_ptr); +uint64_t ChannelDetails_get_user_id(const struct LDKChannelDetails *this_ptr); /** * The user_id passed in to create_channel, or 0 if the channel was inbound. */ -void ChannelDetails_set_user_id(LDKChannelDetails *this_ptr, uint64_t val); +void ChannelDetails_set_user_id(struct LDKChannelDetails *this_ptr, uint64_t val); /** * The available outbound capacity for sending HTLCs to the remote peer. This does not include @@ -4222,7 +4402,7 @@ void ChannelDetails_set_user_id(LDKChannelDetails *this_ptr, uint64_t val); * available for inclusion in new outbound HTLCs). This further does not include any pending * outgoing HTLCs which are awaiting some other resolution to be sent. */ -uint64_t ChannelDetails_get_outbound_capacity_msat(const LDKChannelDetails *this_ptr); +uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *this_ptr); /** * The available outbound capacity for sending HTLCs to the remote peer. This does not include @@ -4230,7 +4410,7 @@ uint64_t ChannelDetails_get_outbound_capacity_msat(const LDKChannelDetails *this * available for inclusion in new outbound HTLCs). This further does not include any pending * outgoing HTLCs which are awaiting some other resolution to be sent. */ -void ChannelDetails_set_outbound_capacity_msat(LDKChannelDetails *this_ptr, uint64_t val); +void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *this_ptr, uint64_t val); /** * The available inbound capacity for the remote peer to send HTLCs to us. This does not @@ -4239,7 +4419,7 @@ void ChannelDetails_set_outbound_capacity_msat(LDKChannelDetails *this_ptr, uint * Note that there are some corner cases not fully handled here, so the actual available * inbound capacity may be slightly higher than this. */ -uint64_t ChannelDetails_get_inbound_capacity_msat(const LDKChannelDetails *this_ptr); +uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *this_ptr); /** * The available inbound capacity for the remote peer to send HTLCs to us. This does not @@ -4248,21 +4428,21 @@ uint64_t ChannelDetails_get_inbound_capacity_msat(const LDKChannelDetails *this_ * Note that there are some corner cases not fully handled here, so the actual available * inbound capacity may be slightly higher than this. */ -void ChannelDetails_set_inbound_capacity_msat(LDKChannelDetails *this_ptr, uint64_t val); +void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *this_ptr, uint64_t val); /** * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) * the peer is connected, and (c) no monitor update failure is pending resolution. */ -bool ChannelDetails_get_is_live(const LDKChannelDetails *this_ptr); +bool ChannelDetails_get_is_live(const struct LDKChannelDetails *this_ptr); /** * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) * the peer is connected, and (c) no monitor update failure is pending resolution. */ -void ChannelDetails_set_is_live(LDKChannelDetails *this_ptr, bool val); +void ChannelDetails_set_is_live(struct LDKChannelDetails *this_ptr, bool val); -void PaymentSendFailure_free(LDKPaymentSendFailure this_ptr); +void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); /** * Constructs a new ChannelManager to hold several channels and route between them. @@ -4280,7 +4460,7 @@ void PaymentSendFailure_free(LDKPaymentSendFailure this_ptr); * Users need to notify the new ChannelManager when a new block is connected or * disconnected using its `block_connected` and `block_disconnected` methods. */ -MUST_USE_RES LDKChannelManager ChannelManager_new(LDKNetwork network, LDKFeeEstimator fee_est, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKKeysInterface keys_manager, LDKUserConfig config, uintptr_t current_blockchain_height); +MUST_USE_RES struct LDKChannelManager ChannelManager_new(enum LDKNetwork network, struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKKeysInterface keys_manager, struct LDKUserConfig config, uintptr_t current_blockchain_height); /** * Creates a new outbound channel to the given remote node and with the given value. @@ -4296,13 +4476,13 @@ MUST_USE_RES LDKChannelManager ChannelManager_new(LDKNetwork network, LDKFeeEsti * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000. */ -MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const LDKChannelManager *this_arg, LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, LDKUserConfig override_config); +MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, uint64_t user_id, struct LDKUserConfig override_config); /** * Gets the list of open channels, in random order. See ChannelDetail field documentation for * more information. */ -MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const LDKChannelManager *this_arg); +MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *this_arg); /** * Gets the list of usable channels, in random order. Useful as an argument to @@ -4311,7 +4491,7 @@ MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const LDKChann * These are guaranteed to have their is_live value set to true, see the documentation for * ChannelDetails::is_live for more info on exactly what the criteria are. */ -MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const LDKChannelManager *this_arg); +MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *this_arg); /** * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs @@ -4320,19 +4500,19 @@ MUST_USE_RES LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const L * * May generate a SendShutdown message event on success, which should be relayed. */ -MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]); +MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]); /** * Force closes a channel, immediately broadcasting the latest local commitment transaction to - * the chain and rejecting new HTLCs on the given channel. + * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. */ -void ChannelManager_force_close_channel(const LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]); +MUST_USE_RES LDKCResult_NoneAPIErrorZ ChannelManager_force_close_channel(const struct LDKChannelManager *this_arg, const uint8_t (*channel_id)[32]); /** * Force close all channels, immediately broadcasting the latest local commitment transaction * for each to the chain and rejecting new HTLCs on each. */ -void ChannelManager_force_close_all_channels(const LDKChannelManager *this_arg); +void ChannelManager_force_close_all_channels(const struct LDKChannelManager *this_arg); /** * Sends a payment along a given route. @@ -4375,7 +4555,7 @@ void ChannelManager_force_close_all_channels(const LDKChannelManager *this_arg); * bit set (either as required or as available). If multiple paths are present in the Route, * we assume the invoice had the basic_mpp feature set. */ -MUST_USE_RES LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const LDKChannelManager *this_arg, const LDKRoute *route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret); +MUST_USE_RES LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *this_arg, const struct LDKRoute *route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); /** * Call this upon creation of a funding transaction for the given channel. @@ -4388,7 +4568,7 @@ MUST_USE_RES LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(cons * May panic if the funding_txo is duplicative with some other channel (note that this should * be trivially prevented by using unique funding transaction keys per-channel). */ -void ChannelManager_funding_transaction_generated(const LDKChannelManager *this_arg, const uint8_t (*temporary_channel_id)[32], LDKOutPoint funding_txo); +void ChannelManager_funding_transaction_generated(const struct LDKChannelManager *this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKOutPoint funding_txo); /** * Generates a signed node_announcement from the given arguments and creates a @@ -4405,7 +4585,7 @@ void ChannelManager_funding_transaction_generated(const LDKChannelManager *this_ * * Panics if addresses is absurdly large (more than 500). */ -void ChannelManager_broadcast_node_announcement(const LDKChannelManager *this_arg, LDKThreeBytes rgb, LDKThirtyTwoBytes alias, LDKCVec_NetAddressZ addresses); +void ChannelManager_broadcast_node_announcement(const struct LDKChannelManager *this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, LDKCVec_NetAddressZ addresses); /** * Processes HTLCs which are pending waiting on random forward delay. @@ -4413,7 +4593,7 @@ void ChannelManager_broadcast_node_announcement(const LDKChannelManager *this_ar * Should only really ever be called in response to a PendingHTLCsForwardable event. * Will likely generate further events. */ -void ChannelManager_process_pending_htlc_forwards(const LDKChannelManager *this_arg); +void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *this_arg); /** * If a peer is disconnected we mark any channels with that peer as 'disabled'. @@ -4422,7 +4602,7 @@ void ChannelManager_process_pending_htlc_forwards(const LDKChannelManager *this_ * * This method handles all the details, and must be called roughly once per minute. */ -void ChannelManager_timer_chan_freshness_every_min(const LDKChannelManager *this_arg); +void ChannelManager_timer_chan_freshness_every_min(const struct LDKChannelManager *this_arg); /** * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect @@ -4431,7 +4611,7 @@ void ChannelManager_timer_chan_freshness_every_min(const LDKChannelManager *this * Returns false if no payment was found to fail backwards, true if the process of failing the * HTLC backwards has been started. */ -MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const LDKChannelManager *this_arg, const uint8_t (*payment_hash)[32], LDKThirtyTwoBytes payment_secret); +MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *this_arg, const uint8_t (*payment_hash)[32], struct LDKThirtyTwoBytes payment_secret); /** * Provides a payment preimage in response to a PaymentReceived event, returning true and @@ -4450,12 +4630,12 @@ MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const LDKChannelManager *th * * May panic if called except in response to a PaymentReceived event. */ -MUST_USE_RES bool ChannelManager_claim_funds(const LDKChannelManager *this_arg, LDKThirtyTwoBytes payment_preimage, LDKThirtyTwoBytes payment_secret, uint64_t expected_amount); +MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *this_arg, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret, uint64_t expected_amount); /** * Gets the node_id held by this ChannelManager */ -MUST_USE_RES LDKPublicKey ChannelManager_get_our_node_id(const LDKChannelManager *this_arg); +MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *this_arg); /** * Restores a single, given channel to normal operation after a @@ -4479,16 +4659,16 @@ MUST_USE_RES LDKPublicKey ChannelManager_get_our_node_id(const LDKChannelManager * 4) once all remote copies are updated, you call this function with the update_id that * completed, and once it is the latest the Channel will be re-enabled. */ -void ChannelManager_channel_monitor_updated(const LDKChannelManager *this_arg, const LDKOutPoint *funding_txo, uint64_t highest_applied_update_id); +void ChannelManager_channel_monitor_updated(const struct LDKChannelManager *this_arg, const struct LDKOutPoint *funding_txo, uint64_t highest_applied_update_id); -LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const LDKChannelManager *this_arg); +struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *this_arg); -LDKEventsProvider ChannelManager_as_EventsProvider(const LDKChannelManager *this_arg); +struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *this_arg); /** * Updates channel state based on transactions seen in a connected block. */ -void ChannelManager_block_connected(const LDKChannelManager *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); +void ChannelManager_block_connected(const struct LDKChannelManager *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); /** * Updates channel state based on a disconnected block. @@ -4496,37 +4676,39 @@ void ChannelManager_block_connected(const LDKChannelManager *this_arg, const uin * If necessary, the channel may be force-closed without letting the counterparty participate * in the shutdown. */ -void ChannelManager_block_disconnected(const LDKChannelManager *this_arg, const uint8_t (*header)[80]); +void ChannelManager_block_disconnected(const struct LDKChannelManager *this_arg, const uint8_t (*header)[80]); -LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const LDKChannelManager *this_arg); +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *this_arg); -void ChannelManagerReadArgs_free(LDKChannelManagerReadArgs this_ptr); +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_ptr); /** * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization. + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -const LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const LDKChannelManagerReadArgs *this_ptr); +const struct LDKKeysInterface *ChannelManagerReadArgs_get_keys_manager(const struct LDKChannelManagerReadArgs *this_ptr); /** * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization. + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -void ChannelManagerReadArgs_set_keys_manager(LDKChannelManagerReadArgs *this_ptr, LDKKeysInterface val); +void ChannelManagerReadArgs_set_keys_manager(struct LDKChannelManagerReadArgs *this_ptr, struct LDKKeysInterface val); /** * The fee_estimator for use in the ChannelManager in the future. * * No calls to the FeeEstimator will be made during deserialization. */ -const LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const LDKChannelManagerReadArgs *this_ptr); +const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *this_ptr); /** * The fee_estimator for use in the ChannelManager in the future. * * No calls to the FeeEstimator will be made during deserialization. */ -void ChannelManagerReadArgs_set_fee_estimator(LDKChannelManagerReadArgs *this_ptr, LDKFeeEstimator val); +void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *this_ptr, struct LDKFeeEstimator val); /** * The chain::Watch for use in the ChannelManager in the future. @@ -4535,7 +4717,7 @@ void ChannelManagerReadArgs_set_fee_estimator(LDKChannelManagerReadArgs *this_pt * you have deserialized ChannelMonitors separately and will add them to your * chain::Watch after deserializing this ChannelManager. */ -const LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const LDKChannelManagerReadArgs *this_ptr); +const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *this_ptr); /** * The chain::Watch for use in the ChannelManager in the future. @@ -4544,72 +4726,72 @@ const LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const LDKChannelManager * you have deserialized ChannelMonitors separately and will add them to your * chain::Watch after deserializing this ChannelManager. */ -void ChannelManagerReadArgs_set_chain_monitor(LDKChannelManagerReadArgs *this_ptr, LDKWatch val); +void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *this_ptr, struct LDKWatch val); /** * The BroadcasterInterface which will be used in the ChannelManager in the future and may be * used to broadcast the latest local commitment transactions of channels which must be * force-closed during deserialization. */ -const LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const LDKChannelManagerReadArgs *this_ptr); +const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *this_ptr); /** * The BroadcasterInterface which will be used in the ChannelManager in the future and may be * used to broadcast the latest local commitment transactions of channels which must be * force-closed during deserialization. */ -void ChannelManagerReadArgs_set_tx_broadcaster(LDKChannelManagerReadArgs *this_ptr, LDKBroadcasterInterface val); +void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *this_ptr, struct LDKBroadcasterInterface val); /** * The Logger for use in the ChannelManager and which may be used to log information during * deserialization. */ -const LDKLogger *ChannelManagerReadArgs_get_logger(const LDKChannelManagerReadArgs *this_ptr); +const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *this_ptr); /** * The Logger for use in the ChannelManager and which may be used to log information during * deserialization. */ -void ChannelManagerReadArgs_set_logger(LDKChannelManagerReadArgs *this_ptr, LDKLogger val); +void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *this_ptr, struct LDKLogger val); /** * Default settings used for new channels. Any existing channels will continue to use the * runtime settings which were stored when the ChannelManager was serialized. */ -LDKUserConfig ChannelManagerReadArgs_get_default_config(const LDKChannelManagerReadArgs *this_ptr); +struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *this_ptr); /** * Default settings used for new channels. Any existing channels will continue to use the * runtime settings which were stored when the ChannelManager was serialized. */ -void ChannelManagerReadArgs_set_default_config(LDKChannelManagerReadArgs *this_ptr, LDKUserConfig val); +void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *this_ptr, struct LDKUserConfig val); /** * Simple utility function to create a ChannelManagerReadArgs which creates the monitor * HashMap for you. This is primarily useful for C bindings where it is not practical to * populate a HashMap directly from C. */ -MUST_USE_RES LDKChannelManagerReadArgs ChannelManagerReadArgs_new(LDKKeysInterface keys_manager, LDKFeeEstimator fee_estimator, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors); +MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKKeysInterface keys_manager, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKLogger logger, struct LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors); -void DecodeError_free(LDKDecodeError this_ptr); +void DecodeError_free(struct LDKDecodeError this_ptr); -void Init_free(LDKInit this_ptr); +void Init_free(struct LDKInit this_ptr); -LDKInit Init_clone(const LDKInit *orig); +struct LDKInit Init_clone(const struct LDKInit *orig); -void ErrorMessage_free(LDKErrorMessage this_ptr); +void ErrorMessage_free(struct LDKErrorMessage this_ptr); -LDKErrorMessage ErrorMessage_clone(const LDKErrorMessage *orig); +struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *orig); /** * The channel ID involved in the error */ -const uint8_t (*ErrorMessage_get_channel_id(const LDKErrorMessage *this_ptr))[32]; +const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *this_ptr))[32]; /** * The channel ID involved in the error */ -void ErrorMessage_set_channel_id(LDKErrorMessage *this_ptr, LDKThirtyTwoBytes val); +void ErrorMessage_set_channel_id(struct LDKErrorMessage *this_ptr, struct LDKThirtyTwoBytes val); /** * A possibly human-readable error description. @@ -4617,7 +4799,7 @@ void ErrorMessage_set_channel_id(LDKErrorMessage *this_ptr, LDKThirtyTwoBytes va * or printed to stdout). Otherwise, a well crafted error message may trigger a security * vulnerability in the terminal emulator or the logging subsystem. */ -LDKStr ErrorMessage_get_data(const LDKErrorMessage *this_ptr); +struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *this_ptr); /** * A possibly human-readable error description. @@ -4625,1673 +4807,1673 @@ LDKStr ErrorMessage_get_data(const LDKErrorMessage *this_ptr); * or printed to stdout). Otherwise, a well crafted error message may trigger a security * vulnerability in the terminal emulator or the logging subsystem. */ -void ErrorMessage_set_data(LDKErrorMessage *this_ptr, LDKCVec_u8Z val); +void ErrorMessage_set_data(struct LDKErrorMessage *this_ptr, LDKCVec_u8Z val); -MUST_USE_RES LDKErrorMessage ErrorMessage_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z data_arg); +MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z data_arg); -void Ping_free(LDKPing this_ptr); +void Ping_free(struct LDKPing this_ptr); -LDKPing Ping_clone(const LDKPing *orig); +struct LDKPing Ping_clone(const struct LDKPing *orig); /** * The desired response length */ -uint16_t Ping_get_ponglen(const LDKPing *this_ptr); +uint16_t Ping_get_ponglen(const struct LDKPing *this_ptr); /** * The desired response length */ -void Ping_set_ponglen(LDKPing *this_ptr, uint16_t val); +void Ping_set_ponglen(struct LDKPing *this_ptr, uint16_t val); /** * The ping packet size. * This field is not sent on the wire. byteslen zeros are sent. */ -uint16_t Ping_get_byteslen(const LDKPing *this_ptr); +uint16_t Ping_get_byteslen(const struct LDKPing *this_ptr); /** * The ping packet size. * This field is not sent on the wire. byteslen zeros are sent. */ -void Ping_set_byteslen(LDKPing *this_ptr, uint16_t val); +void Ping_set_byteslen(struct LDKPing *this_ptr, uint16_t val); -MUST_USE_RES LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); -void Pong_free(LDKPong this_ptr); +void Pong_free(struct LDKPong this_ptr); -LDKPong Pong_clone(const LDKPong *orig); +struct LDKPong Pong_clone(const struct LDKPong *orig); /** * The pong packet size. * This field is not sent on the wire. byteslen zeros are sent. */ -uint16_t Pong_get_byteslen(const LDKPong *this_ptr); +uint16_t Pong_get_byteslen(const struct LDKPong *this_ptr); /** * The pong packet size. * This field is not sent on the wire. byteslen zeros are sent. */ -void Pong_set_byteslen(LDKPong *this_ptr, uint16_t val); +void Pong_set_byteslen(struct LDKPong *this_ptr, uint16_t val); -MUST_USE_RES LDKPong Pong_new(uint16_t byteslen_arg); +MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); -void OpenChannel_free(LDKOpenChannel this_ptr); +void OpenChannel_free(struct LDKOpenChannel this_ptr); -LDKOpenChannel OpenChannel_clone(const LDKOpenChannel *orig); +struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *orig); /** * The genesis hash of the blockchain where the channel is to be opened */ -const uint8_t (*OpenChannel_get_chain_hash(const LDKOpenChannel *this_ptr))[32]; +const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *this_ptr))[32]; /** * The genesis hash of the blockchain where the channel is to be opened */ -void OpenChannel_set_chain_hash(LDKOpenChannel *this_ptr, LDKThirtyTwoBytes val); +void OpenChannel_set_chain_hash(struct LDKOpenChannel *this_ptr, struct LDKThirtyTwoBytes val); /** * A temporary channel ID, until the funding outpoint is announced */ -const uint8_t (*OpenChannel_get_temporary_channel_id(const LDKOpenChannel *this_ptr))[32]; +const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *this_ptr))[32]; /** * A temporary channel ID, until the funding outpoint is announced */ -void OpenChannel_set_temporary_channel_id(LDKOpenChannel *this_ptr, LDKThirtyTwoBytes val); +void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *this_ptr, struct LDKThirtyTwoBytes val); /** * The channel value */ -uint64_t OpenChannel_get_funding_satoshis(const LDKOpenChannel *this_ptr); +uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *this_ptr); /** * The channel value */ -void OpenChannel_set_funding_satoshis(LDKOpenChannel *this_ptr, uint64_t val); +void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *this_ptr, uint64_t val); /** * The amount to push to the counterparty as part of the open, in milli-satoshi */ -uint64_t OpenChannel_get_push_msat(const LDKOpenChannel *this_ptr); +uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *this_ptr); /** * The amount to push to the counterparty as part of the open, in milli-satoshi */ -void OpenChannel_set_push_msat(LDKOpenChannel *this_ptr, uint64_t val); +void OpenChannel_set_push_msat(struct LDKOpenChannel *this_ptr, uint64_t val); /** * The threshold below which outputs on transactions broadcast by sender will be omitted */ -uint64_t OpenChannel_get_dust_limit_satoshis(const LDKOpenChannel *this_ptr); +uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *this_ptr); /** * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void OpenChannel_set_dust_limit_satoshis(LDKOpenChannel *this_ptr, uint64_t val); +void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *this_ptr, uint64_t val); /** * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const LDKOpenChannel *this_ptr); +uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *this_ptr); /** * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -void OpenChannel_set_max_htlc_value_in_flight_msat(LDKOpenChannel *this_ptr, uint64_t val); +void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *this_ptr, uint64_t val); /** * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -uint64_t OpenChannel_get_channel_reserve_satoshis(const LDKOpenChannel *this_ptr); +uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *this_ptr); /** * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void OpenChannel_set_channel_reserve_satoshis(LDKOpenChannel *this_ptr, uint64_t val); +void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *this_ptr, uint64_t val); /** * The minimum HTLC size incoming to sender, in milli-satoshi */ -uint64_t OpenChannel_get_htlc_minimum_msat(const LDKOpenChannel *this_ptr); +uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *this_ptr); /** * The minimum HTLC size incoming to sender, in milli-satoshi */ -void OpenChannel_set_htlc_minimum_msat(LDKOpenChannel *this_ptr, uint64_t val); +void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *this_ptr, uint64_t val); /** * The feerate per 1000-weight of sender generated transactions, until updated by update_fee */ -uint32_t OpenChannel_get_feerate_per_kw(const LDKOpenChannel *this_ptr); +uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *this_ptr); /** * The feerate per 1000-weight of sender generated transactions, until updated by update_fee */ -void OpenChannel_set_feerate_per_kw(LDKOpenChannel *this_ptr, uint32_t val); +void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *this_ptr, uint32_t val); /** * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -uint16_t OpenChannel_get_to_self_delay(const LDKOpenChannel *this_ptr); +uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *this_ptr); /** * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void OpenChannel_set_to_self_delay(LDKOpenChannel *this_ptr, uint16_t val); +void OpenChannel_set_to_self_delay(struct LDKOpenChannel *this_ptr, uint16_t val); /** * The maximum number of inbound HTLCs towards sender */ -uint16_t OpenChannel_get_max_accepted_htlcs(const LDKOpenChannel *this_ptr); +uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *this_ptr); /** * The maximum number of inbound HTLCs towards sender */ -void OpenChannel_set_max_accepted_htlcs(LDKOpenChannel *this_ptr, uint16_t val); +void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *this_ptr, uint16_t val); /** * The sender's key controlling the funding transaction */ -LDKPublicKey OpenChannel_get_funding_pubkey(const LDKOpenChannel *this_ptr); +struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *this_ptr); /** * The sender's key controlling the funding transaction */ -void OpenChannel_set_funding_pubkey(LDKOpenChannel *this_ptr, LDKPublicKey val); +void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *this_ptr, struct LDKPublicKey val); /** * Used to derive a revocation key for transactions broadcast by counterparty */ -LDKPublicKey OpenChannel_get_revocation_basepoint(const LDKOpenChannel *this_ptr); +struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *this_ptr); /** * Used to derive a revocation key for transactions broadcast by counterparty */ -void OpenChannel_set_revocation_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val); +void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *this_ptr, struct LDKPublicKey val); /** * A payment key to sender for transactions broadcast by counterparty */ -LDKPublicKey OpenChannel_get_payment_point(const LDKOpenChannel *this_ptr); +struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *this_ptr); /** * A payment key to sender for transactions broadcast by counterparty */ -void OpenChannel_set_payment_point(LDKOpenChannel *this_ptr, LDKPublicKey val); +void OpenChannel_set_payment_point(struct LDKOpenChannel *this_ptr, struct LDKPublicKey val); /** * Used to derive a payment key to sender for transactions broadcast by sender */ -LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const LDKOpenChannel *this_ptr); +struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *this_ptr); /** * Used to derive a payment key to sender for transactions broadcast by sender */ -void OpenChannel_set_delayed_payment_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val); +void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *this_ptr, struct LDKPublicKey val); /** * Used to derive an HTLC payment key to sender */ -LDKPublicKey OpenChannel_get_htlc_basepoint(const LDKOpenChannel *this_ptr); +struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *this_ptr); /** * Used to derive an HTLC payment key to sender */ -void OpenChannel_set_htlc_basepoint(LDKOpenChannel *this_ptr, LDKPublicKey val); +void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *this_ptr, struct LDKPublicKey val); /** * The first to-be-broadcast-by-sender transaction's per commitment point */ -LDKPublicKey OpenChannel_get_first_per_commitment_point(const LDKOpenChannel *this_ptr); +struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *this_ptr); /** * The first to-be-broadcast-by-sender transaction's per commitment point */ -void OpenChannel_set_first_per_commitment_point(LDKOpenChannel *this_ptr, LDKPublicKey val); +void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *this_ptr, struct LDKPublicKey val); /** * Channel flags */ -uint8_t OpenChannel_get_channel_flags(const LDKOpenChannel *this_ptr); +uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *this_ptr); /** * Channel flags */ -void OpenChannel_set_channel_flags(LDKOpenChannel *this_ptr, uint8_t val); +void OpenChannel_set_channel_flags(struct LDKOpenChannel *this_ptr, uint8_t val); -void AcceptChannel_free(LDKAcceptChannel this_ptr); +void AcceptChannel_free(struct LDKAcceptChannel this_ptr); -LDKAcceptChannel AcceptChannel_clone(const LDKAcceptChannel *orig); +struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *orig); /** * A temporary channel ID, until the funding outpoint is announced */ -const uint8_t (*AcceptChannel_get_temporary_channel_id(const LDKAcceptChannel *this_ptr))[32]; +const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *this_ptr))[32]; /** * A temporary channel ID, until the funding outpoint is announced */ -void AcceptChannel_set_temporary_channel_id(LDKAcceptChannel *this_ptr, LDKThirtyTwoBytes val); +void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *this_ptr, struct LDKThirtyTwoBytes val); /** * The threshold below which outputs on transactions broadcast by sender will be omitted */ -uint64_t AcceptChannel_get_dust_limit_satoshis(const LDKAcceptChannel *this_ptr); +uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *this_ptr); /** * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void AcceptChannel_set_dust_limit_satoshis(LDKAcceptChannel *this_ptr, uint64_t val); +void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *this_ptr, uint64_t val); /** * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const LDKAcceptChannel *this_ptr); +uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *this_ptr); /** * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -void AcceptChannel_set_max_htlc_value_in_flight_msat(LDKAcceptChannel *this_ptr, uint64_t val); +void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *this_ptr, uint64_t val); /** * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -uint64_t AcceptChannel_get_channel_reserve_satoshis(const LDKAcceptChannel *this_ptr); +uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *this_ptr); /** * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void AcceptChannel_set_channel_reserve_satoshis(LDKAcceptChannel *this_ptr, uint64_t val); +void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *this_ptr, uint64_t val); /** * The minimum HTLC size incoming to sender, in milli-satoshi */ -uint64_t AcceptChannel_get_htlc_minimum_msat(const LDKAcceptChannel *this_ptr); +uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *this_ptr); /** * The minimum HTLC size incoming to sender, in milli-satoshi */ -void AcceptChannel_set_htlc_minimum_msat(LDKAcceptChannel *this_ptr, uint64_t val); +void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *this_ptr, uint64_t val); /** * Minimum depth of the funding transaction before the channel is considered open */ -uint32_t AcceptChannel_get_minimum_depth(const LDKAcceptChannel *this_ptr); +uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *this_ptr); /** * Minimum depth of the funding transaction before the channel is considered open */ -void AcceptChannel_set_minimum_depth(LDKAcceptChannel *this_ptr, uint32_t val); +void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *this_ptr, uint32_t val); /** * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -uint16_t AcceptChannel_get_to_self_delay(const LDKAcceptChannel *this_ptr); +uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *this_ptr); /** * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void AcceptChannel_set_to_self_delay(LDKAcceptChannel *this_ptr, uint16_t val); +void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *this_ptr, uint16_t val); /** * The maximum number of inbound HTLCs towards sender */ -uint16_t AcceptChannel_get_max_accepted_htlcs(const LDKAcceptChannel *this_ptr); +uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *this_ptr); /** * The maximum number of inbound HTLCs towards sender */ -void AcceptChannel_set_max_accepted_htlcs(LDKAcceptChannel *this_ptr, uint16_t val); +void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *this_ptr, uint16_t val); /** * The sender's key controlling the funding transaction */ -LDKPublicKey AcceptChannel_get_funding_pubkey(const LDKAcceptChannel *this_ptr); +struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *this_ptr); /** * The sender's key controlling the funding transaction */ -void AcceptChannel_set_funding_pubkey(LDKAcceptChannel *this_ptr, LDKPublicKey val); +void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *this_ptr, struct LDKPublicKey val); /** * Used to derive a revocation key for transactions broadcast by counterparty */ -LDKPublicKey AcceptChannel_get_revocation_basepoint(const LDKAcceptChannel *this_ptr); +struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *this_ptr); /** * Used to derive a revocation key for transactions broadcast by counterparty */ -void AcceptChannel_set_revocation_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val); +void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *this_ptr, struct LDKPublicKey val); /** * A payment key to sender for transactions broadcast by counterparty */ -LDKPublicKey AcceptChannel_get_payment_point(const LDKAcceptChannel *this_ptr); +struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *this_ptr); /** * A payment key to sender for transactions broadcast by counterparty */ -void AcceptChannel_set_payment_point(LDKAcceptChannel *this_ptr, LDKPublicKey val); +void AcceptChannel_set_payment_point(struct LDKAcceptChannel *this_ptr, struct LDKPublicKey val); /** * Used to derive a payment key to sender for transactions broadcast by sender */ -LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const LDKAcceptChannel *this_ptr); +struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *this_ptr); /** * Used to derive a payment key to sender for transactions broadcast by sender */ -void AcceptChannel_set_delayed_payment_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val); +void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *this_ptr, struct LDKPublicKey val); /** * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -LDKPublicKey AcceptChannel_get_htlc_basepoint(const LDKAcceptChannel *this_ptr); +struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *this_ptr); /** * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -void AcceptChannel_set_htlc_basepoint(LDKAcceptChannel *this_ptr, LDKPublicKey val); +void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *this_ptr, struct LDKPublicKey val); /** * The first to-be-broadcast-by-sender transaction's per commitment point */ -LDKPublicKey AcceptChannel_get_first_per_commitment_point(const LDKAcceptChannel *this_ptr); +struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *this_ptr); /** * The first to-be-broadcast-by-sender transaction's per commitment point */ -void AcceptChannel_set_first_per_commitment_point(LDKAcceptChannel *this_ptr, LDKPublicKey val); +void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *this_ptr, struct LDKPublicKey val); -void FundingCreated_free(LDKFundingCreated this_ptr); +void FundingCreated_free(struct LDKFundingCreated this_ptr); -LDKFundingCreated FundingCreated_clone(const LDKFundingCreated *orig); +struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *orig); /** * A temporary channel ID, until the funding is established */ -const uint8_t (*FundingCreated_get_temporary_channel_id(const LDKFundingCreated *this_ptr))[32]; +const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *this_ptr))[32]; /** * A temporary channel ID, until the funding is established */ -void FundingCreated_set_temporary_channel_id(LDKFundingCreated *this_ptr, LDKThirtyTwoBytes val); +void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *this_ptr, struct LDKThirtyTwoBytes val); /** * The funding transaction ID */ -const uint8_t (*FundingCreated_get_funding_txid(const LDKFundingCreated *this_ptr))[32]; +const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *this_ptr))[32]; /** * The funding transaction ID */ -void FundingCreated_set_funding_txid(LDKFundingCreated *this_ptr, LDKThirtyTwoBytes val); +void FundingCreated_set_funding_txid(struct LDKFundingCreated *this_ptr, struct LDKThirtyTwoBytes val); /** * The specific output index funding this channel */ -uint16_t FundingCreated_get_funding_output_index(const LDKFundingCreated *this_ptr); +uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *this_ptr); /** * The specific output index funding this channel */ -void FundingCreated_set_funding_output_index(LDKFundingCreated *this_ptr, uint16_t val); +void FundingCreated_set_funding_output_index(struct LDKFundingCreated *this_ptr, uint16_t val); /** * The signature of the channel initiator (funder) on the funding transaction */ -LDKSignature FundingCreated_get_signature(const LDKFundingCreated *this_ptr); +struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *this_ptr); /** * The signature of the channel initiator (funder) on the funding transaction */ -void FundingCreated_set_signature(LDKFundingCreated *this_ptr, LDKSignature val); +void FundingCreated_set_signature(struct LDKFundingCreated *this_ptr, struct LDKSignature val); -MUST_USE_RES LDKFundingCreated FundingCreated_new(LDKThirtyTwoBytes temporary_channel_id_arg, LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, LDKSignature signature_arg); +MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); -void FundingSigned_free(LDKFundingSigned this_ptr); +void FundingSigned_free(struct LDKFundingSigned this_ptr); -LDKFundingSigned FundingSigned_clone(const LDKFundingSigned *orig); +struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *orig); /** * The channel ID */ -const uint8_t (*FundingSigned_get_channel_id(const LDKFundingSigned *this_ptr))[32]; +const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *this_ptr))[32]; /** * The channel ID */ -void FundingSigned_set_channel_id(LDKFundingSigned *this_ptr, LDKThirtyTwoBytes val); +void FundingSigned_set_channel_id(struct LDKFundingSigned *this_ptr, struct LDKThirtyTwoBytes val); /** * The signature of the channel acceptor (fundee) on the funding transaction */ -LDKSignature FundingSigned_get_signature(const LDKFundingSigned *this_ptr); +struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *this_ptr); /** * The signature of the channel acceptor (fundee) on the funding transaction */ -void FundingSigned_set_signature(LDKFundingSigned *this_ptr, LDKSignature val); +void FundingSigned_set_signature(struct LDKFundingSigned *this_ptr, struct LDKSignature val); -MUST_USE_RES LDKFundingSigned FundingSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg); +MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); -void FundingLocked_free(LDKFundingLocked this_ptr); +void FundingLocked_free(struct LDKFundingLocked this_ptr); -LDKFundingLocked FundingLocked_clone(const LDKFundingLocked *orig); +struct LDKFundingLocked FundingLocked_clone(const struct LDKFundingLocked *orig); /** * The channel ID */ -const uint8_t (*FundingLocked_get_channel_id(const LDKFundingLocked *this_ptr))[32]; +const uint8_t (*FundingLocked_get_channel_id(const struct LDKFundingLocked *this_ptr))[32]; /** * The channel ID */ -void FundingLocked_set_channel_id(LDKFundingLocked *this_ptr, LDKThirtyTwoBytes val); +void FundingLocked_set_channel_id(struct LDKFundingLocked *this_ptr, struct LDKThirtyTwoBytes val); /** * The per-commitment point of the second commitment transaction */ -LDKPublicKey FundingLocked_get_next_per_commitment_point(const LDKFundingLocked *this_ptr); +struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDKFundingLocked *this_ptr); /** * The per-commitment point of the second commitment transaction */ -void FundingLocked_set_next_per_commitment_point(LDKFundingLocked *this_ptr, LDKPublicKey val); +void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *this_ptr, struct LDKPublicKey val); -MUST_USE_RES LDKFundingLocked FundingLocked_new(LDKThirtyTwoBytes channel_id_arg, LDKPublicKey next_per_commitment_point_arg); +MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg); -void Shutdown_free(LDKShutdown this_ptr); +void Shutdown_free(struct LDKShutdown this_ptr); -LDKShutdown Shutdown_clone(const LDKShutdown *orig); +struct LDKShutdown Shutdown_clone(const struct LDKShutdown *orig); /** * The channel ID */ -const uint8_t (*Shutdown_get_channel_id(const LDKShutdown *this_ptr))[32]; +const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *this_ptr))[32]; /** * The channel ID */ -void Shutdown_set_channel_id(LDKShutdown *this_ptr, LDKThirtyTwoBytes val); +void Shutdown_set_channel_id(struct LDKShutdown *this_ptr, struct LDKThirtyTwoBytes val); /** * The destination of this peer's funds on closing. * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. */ -LDKu8slice Shutdown_get_scriptpubkey(const LDKShutdown *this_ptr); +struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *this_ptr); /** * The destination of this peer's funds on closing. * Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. */ -void Shutdown_set_scriptpubkey(LDKShutdown *this_ptr, LDKCVec_u8Z val); +void Shutdown_set_scriptpubkey(struct LDKShutdown *this_ptr, LDKCVec_u8Z val); -MUST_USE_RES LDKShutdown Shutdown_new(LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z scriptpubkey_arg); +MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, LDKCVec_u8Z scriptpubkey_arg); -void ClosingSigned_free(LDKClosingSigned this_ptr); +void ClosingSigned_free(struct LDKClosingSigned this_ptr); -LDKClosingSigned ClosingSigned_clone(const LDKClosingSigned *orig); +struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *orig); /** * The channel ID */ -const uint8_t (*ClosingSigned_get_channel_id(const LDKClosingSigned *this_ptr))[32]; +const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *this_ptr))[32]; /** * The channel ID */ -void ClosingSigned_set_channel_id(LDKClosingSigned *this_ptr, LDKThirtyTwoBytes val); +void ClosingSigned_set_channel_id(struct LDKClosingSigned *this_ptr, struct LDKThirtyTwoBytes val); /** * The proposed total fee for the closing transaction */ -uint64_t ClosingSigned_get_fee_satoshis(const LDKClosingSigned *this_ptr); +uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *this_ptr); /** * The proposed total fee for the closing transaction */ -void ClosingSigned_set_fee_satoshis(LDKClosingSigned *this_ptr, uint64_t val); +void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *this_ptr, uint64_t val); /** * A signature on the closing transaction */ -LDKSignature ClosingSigned_get_signature(const LDKClosingSigned *this_ptr); +struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *this_ptr); /** * A signature on the closing transaction */ -void ClosingSigned_set_signature(LDKClosingSigned *this_ptr, LDKSignature val); +void ClosingSigned_set_signature(struct LDKClosingSigned *this_ptr, struct LDKSignature val); -MUST_USE_RES LDKClosingSigned ClosingSigned_new(LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, LDKSignature signature_arg); +MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg); -void UpdateAddHTLC_free(LDKUpdateAddHTLC this_ptr); +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_ptr); -LDKUpdateAddHTLC UpdateAddHTLC_clone(const LDKUpdateAddHTLC *orig); +struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *orig); /** * The channel ID */ -const uint8_t (*UpdateAddHTLC_get_channel_id(const LDKUpdateAddHTLC *this_ptr))[32]; +const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *this_ptr))[32]; /** * The channel ID */ -void UpdateAddHTLC_set_channel_id(LDKUpdateAddHTLC *this_ptr, LDKThirtyTwoBytes val); +void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *this_ptr, struct LDKThirtyTwoBytes val); /** * The HTLC ID */ -uint64_t UpdateAddHTLC_get_htlc_id(const LDKUpdateAddHTLC *this_ptr); +uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *this_ptr); /** * The HTLC ID */ -void UpdateAddHTLC_set_htlc_id(LDKUpdateAddHTLC *this_ptr, uint64_t val); +void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *this_ptr, uint64_t val); /** * The HTLC value in milli-satoshi */ -uint64_t UpdateAddHTLC_get_amount_msat(const LDKUpdateAddHTLC *this_ptr); +uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *this_ptr); /** * The HTLC value in milli-satoshi */ -void UpdateAddHTLC_set_amount_msat(LDKUpdateAddHTLC *this_ptr, uint64_t val); +void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *this_ptr, uint64_t val); /** * The payment hash, the pre-image of which controls HTLC redemption */ -const uint8_t (*UpdateAddHTLC_get_payment_hash(const LDKUpdateAddHTLC *this_ptr))[32]; +const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *this_ptr))[32]; /** * The payment hash, the pre-image of which controls HTLC redemption */ -void UpdateAddHTLC_set_payment_hash(LDKUpdateAddHTLC *this_ptr, LDKThirtyTwoBytes val); +void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *this_ptr, struct LDKThirtyTwoBytes val); /** * The expiry height of the HTLC */ -uint32_t UpdateAddHTLC_get_cltv_expiry(const LDKUpdateAddHTLC *this_ptr); +uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *this_ptr); /** * The expiry height of the HTLC */ -void UpdateAddHTLC_set_cltv_expiry(LDKUpdateAddHTLC *this_ptr, uint32_t val); +void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *this_ptr, uint32_t val); -void UpdateFulfillHTLC_free(LDKUpdateFulfillHTLC this_ptr); +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_ptr); -LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const LDKUpdateFulfillHTLC *orig); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *orig); /** * The channel ID */ -const uint8_t (*UpdateFulfillHTLC_get_channel_id(const LDKUpdateFulfillHTLC *this_ptr))[32]; +const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *this_ptr))[32]; /** * The channel ID */ -void UpdateFulfillHTLC_set_channel_id(LDKUpdateFulfillHTLC *this_ptr, LDKThirtyTwoBytes val); +void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *this_ptr, struct LDKThirtyTwoBytes val); /** * The HTLC ID */ -uint64_t UpdateFulfillHTLC_get_htlc_id(const LDKUpdateFulfillHTLC *this_ptr); +uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *this_ptr); /** * The HTLC ID */ -void UpdateFulfillHTLC_set_htlc_id(LDKUpdateFulfillHTLC *this_ptr, uint64_t val); +void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *this_ptr, uint64_t val); /** * The pre-image of the payment hash, allowing HTLC redemption */ -const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const LDKUpdateFulfillHTLC *this_ptr))[32]; +const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *this_ptr))[32]; /** * The pre-image of the payment hash, allowing HTLC redemption */ -void UpdateFulfillHTLC_set_payment_preimage(LDKUpdateFulfillHTLC *this_ptr, LDKThirtyTwoBytes val); +void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *this_ptr, struct LDKThirtyTwoBytes val); -MUST_USE_RES LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, LDKThirtyTwoBytes payment_preimage_arg); +MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); -void UpdateFailHTLC_free(LDKUpdateFailHTLC this_ptr); +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_ptr); -LDKUpdateFailHTLC UpdateFailHTLC_clone(const LDKUpdateFailHTLC *orig); +struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *orig); /** * The channel ID */ -const uint8_t (*UpdateFailHTLC_get_channel_id(const LDKUpdateFailHTLC *this_ptr))[32]; +const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *this_ptr))[32]; /** * The channel ID */ -void UpdateFailHTLC_set_channel_id(LDKUpdateFailHTLC *this_ptr, LDKThirtyTwoBytes val); +void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *this_ptr, struct LDKThirtyTwoBytes val); /** * The HTLC ID */ -uint64_t UpdateFailHTLC_get_htlc_id(const LDKUpdateFailHTLC *this_ptr); +uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *this_ptr); /** * The HTLC ID */ -void UpdateFailHTLC_set_htlc_id(LDKUpdateFailHTLC *this_ptr, uint64_t val); +void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *this_ptr, uint64_t val); -void UpdateFailMalformedHTLC_free(LDKUpdateFailMalformedHTLC this_ptr); +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_ptr); -LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const LDKUpdateFailMalformedHTLC *orig); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *orig); /** * The channel ID */ -const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const LDKUpdateFailMalformedHTLC *this_ptr))[32]; +const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *this_ptr))[32]; /** * The channel ID */ -void UpdateFailMalformedHTLC_set_channel_id(LDKUpdateFailMalformedHTLC *this_ptr, LDKThirtyTwoBytes val); +void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *this_ptr, struct LDKThirtyTwoBytes val); /** * The HTLC ID */ -uint64_t UpdateFailMalformedHTLC_get_htlc_id(const LDKUpdateFailMalformedHTLC *this_ptr); +uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *this_ptr); /** * The HTLC ID */ -void UpdateFailMalformedHTLC_set_htlc_id(LDKUpdateFailMalformedHTLC *this_ptr, uint64_t val); +void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *this_ptr, uint64_t val); /** * The failure code */ -uint16_t UpdateFailMalformedHTLC_get_failure_code(const LDKUpdateFailMalformedHTLC *this_ptr); +uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *this_ptr); /** * The failure code */ -void UpdateFailMalformedHTLC_set_failure_code(LDKUpdateFailMalformedHTLC *this_ptr, uint16_t val); +void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *this_ptr, uint16_t val); -void CommitmentSigned_free(LDKCommitmentSigned this_ptr); +void CommitmentSigned_free(struct LDKCommitmentSigned this_ptr); -LDKCommitmentSigned CommitmentSigned_clone(const LDKCommitmentSigned *orig); +struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *orig); /** * The channel ID */ -const uint8_t (*CommitmentSigned_get_channel_id(const LDKCommitmentSigned *this_ptr))[32]; +const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *this_ptr))[32]; /** * The channel ID */ -void CommitmentSigned_set_channel_id(LDKCommitmentSigned *this_ptr, LDKThirtyTwoBytes val); +void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *this_ptr, struct LDKThirtyTwoBytes val); /** * A signature on the commitment transaction */ -LDKSignature CommitmentSigned_get_signature(const LDKCommitmentSigned *this_ptr); +struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *this_ptr); /** * A signature on the commitment transaction */ -void CommitmentSigned_set_signature(LDKCommitmentSigned *this_ptr, LDKSignature val); +void CommitmentSigned_set_signature(struct LDKCommitmentSigned *this_ptr, struct LDKSignature val); /** * Signatures on the HTLC transactions */ -void CommitmentSigned_set_htlc_signatures(LDKCommitmentSigned *this_ptr, LDKCVec_SignatureZ val); +void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *this_ptr, LDKCVec_SignatureZ val); -MUST_USE_RES LDKCommitmentSigned CommitmentSigned_new(LDKThirtyTwoBytes channel_id_arg, LDKSignature signature_arg, LDKCVec_SignatureZ htlc_signatures_arg); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, LDKCVec_SignatureZ htlc_signatures_arg); -void RevokeAndACK_free(LDKRevokeAndACK this_ptr); +void RevokeAndACK_free(struct LDKRevokeAndACK this_ptr); -LDKRevokeAndACK RevokeAndACK_clone(const LDKRevokeAndACK *orig); +struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *orig); /** * The channel ID */ -const uint8_t (*RevokeAndACK_get_channel_id(const LDKRevokeAndACK *this_ptr))[32]; +const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *this_ptr))[32]; /** * The channel ID */ -void RevokeAndACK_set_channel_id(LDKRevokeAndACK *this_ptr, LDKThirtyTwoBytes val); +void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *this_ptr, struct LDKThirtyTwoBytes val); /** * The secret corresponding to the per-commitment point */ -const uint8_t (*RevokeAndACK_get_per_commitment_secret(const LDKRevokeAndACK *this_ptr))[32]; +const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *this_ptr))[32]; /** * The secret corresponding to the per-commitment point */ -void RevokeAndACK_set_per_commitment_secret(LDKRevokeAndACK *this_ptr, LDKThirtyTwoBytes val); +void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *this_ptr, struct LDKThirtyTwoBytes val); /** * The next sender-broadcast commitment transaction's per-commitment point */ -LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const LDKRevokeAndACK *this_ptr); +struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *this_ptr); /** * The next sender-broadcast commitment transaction's per-commitment point */ -void RevokeAndACK_set_next_per_commitment_point(LDKRevokeAndACK *this_ptr, LDKPublicKey val); +void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *this_ptr, struct LDKPublicKey val); -MUST_USE_RES LDKRevokeAndACK RevokeAndACK_new(LDKThirtyTwoBytes channel_id_arg, LDKThirtyTwoBytes per_commitment_secret_arg, LDKPublicKey next_per_commitment_point_arg); +MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); -void UpdateFee_free(LDKUpdateFee this_ptr); +void UpdateFee_free(struct LDKUpdateFee this_ptr); -LDKUpdateFee UpdateFee_clone(const LDKUpdateFee *orig); +struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *orig); /** * The channel ID */ -const uint8_t (*UpdateFee_get_channel_id(const LDKUpdateFee *this_ptr))[32]; +const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *this_ptr))[32]; /** * The channel ID */ -void UpdateFee_set_channel_id(LDKUpdateFee *this_ptr, LDKThirtyTwoBytes val); +void UpdateFee_set_channel_id(struct LDKUpdateFee *this_ptr, struct LDKThirtyTwoBytes val); /** * Fee rate per 1000-weight of the transaction */ -uint32_t UpdateFee_get_feerate_per_kw(const LDKUpdateFee *this_ptr); +uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *this_ptr); /** * Fee rate per 1000-weight of the transaction */ -void UpdateFee_set_feerate_per_kw(LDKUpdateFee *this_ptr, uint32_t val); +void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *this_ptr, uint32_t val); -MUST_USE_RES LDKUpdateFee UpdateFee_new(LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); +MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); -void DataLossProtect_free(LDKDataLossProtect this_ptr); +void DataLossProtect_free(struct LDKDataLossProtect this_ptr); -LDKDataLossProtect DataLossProtect_clone(const LDKDataLossProtect *orig); +struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *orig); /** * Proof that the sender knows the per-commitment secret of a specific commitment transaction * belonging to the recipient */ -const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const LDKDataLossProtect *this_ptr))[32]; +const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const struct LDKDataLossProtect *this_ptr))[32]; /** * Proof that the sender knows the per-commitment secret of a specific commitment transaction * belonging to the recipient */ -void DataLossProtect_set_your_last_per_commitment_secret(LDKDataLossProtect *this_ptr, LDKThirtyTwoBytes val); +void DataLossProtect_set_your_last_per_commitment_secret(struct LDKDataLossProtect *this_ptr, struct LDKThirtyTwoBytes val); /** * The sender's per-commitment point for their current commitment transaction */ -LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const LDKDataLossProtect *this_ptr); +struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const struct LDKDataLossProtect *this_ptr); /** * The sender's per-commitment point for their current commitment transaction */ -void DataLossProtect_set_my_current_per_commitment_point(LDKDataLossProtect *this_ptr, LDKPublicKey val); +void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *this_ptr, struct LDKPublicKey val); -MUST_USE_RES LDKDataLossProtect DataLossProtect_new(LDKThirtyTwoBytes your_last_per_commitment_secret_arg, LDKPublicKey my_current_per_commitment_point_arg); +MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); -void ChannelReestablish_free(LDKChannelReestablish this_ptr); +void ChannelReestablish_free(struct LDKChannelReestablish this_ptr); -LDKChannelReestablish ChannelReestablish_clone(const LDKChannelReestablish *orig); +struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *orig); /** * The channel ID */ -const uint8_t (*ChannelReestablish_get_channel_id(const LDKChannelReestablish *this_ptr))[32]; +const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *this_ptr))[32]; /** * The channel ID */ -void ChannelReestablish_set_channel_id(LDKChannelReestablish *this_ptr, LDKThirtyTwoBytes val); +void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *this_ptr, struct LDKThirtyTwoBytes val); /** * The next commitment number for the sender */ -uint64_t ChannelReestablish_get_next_local_commitment_number(const LDKChannelReestablish *this_ptr); +uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *this_ptr); /** * The next commitment number for the sender */ -void ChannelReestablish_set_next_local_commitment_number(LDKChannelReestablish *this_ptr, uint64_t val); +void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *this_ptr, uint64_t val); /** * The next commitment number for the recipient */ -uint64_t ChannelReestablish_get_next_remote_commitment_number(const LDKChannelReestablish *this_ptr); +uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *this_ptr); /** * The next commitment number for the recipient */ -void ChannelReestablish_set_next_remote_commitment_number(LDKChannelReestablish *this_ptr, uint64_t val); +void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *this_ptr, uint64_t val); -void AnnouncementSignatures_free(LDKAnnouncementSignatures this_ptr); +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_ptr); -LDKAnnouncementSignatures AnnouncementSignatures_clone(const LDKAnnouncementSignatures *orig); +struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *orig); /** * The channel ID */ -const uint8_t (*AnnouncementSignatures_get_channel_id(const LDKAnnouncementSignatures *this_ptr))[32]; +const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *this_ptr))[32]; /** * The channel ID */ -void AnnouncementSignatures_set_channel_id(LDKAnnouncementSignatures *this_ptr, LDKThirtyTwoBytes val); +void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *this_ptr, struct LDKThirtyTwoBytes val); /** * The short channel ID */ -uint64_t AnnouncementSignatures_get_short_channel_id(const LDKAnnouncementSignatures *this_ptr); +uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *this_ptr); /** * The short channel ID */ -void AnnouncementSignatures_set_short_channel_id(LDKAnnouncementSignatures *this_ptr, uint64_t val); +void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *this_ptr, uint64_t val); /** * A signature by the node key */ -LDKSignature AnnouncementSignatures_get_node_signature(const LDKAnnouncementSignatures *this_ptr); +struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *this_ptr); /** * A signature by the node key */ -void AnnouncementSignatures_set_node_signature(LDKAnnouncementSignatures *this_ptr, LDKSignature val); +void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *this_ptr, struct LDKSignature val); /** * A signature by the funding key */ -LDKSignature AnnouncementSignatures_get_bitcoin_signature(const LDKAnnouncementSignatures *this_ptr); +struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *this_ptr); /** * A signature by the funding key */ -void AnnouncementSignatures_set_bitcoin_signature(LDKAnnouncementSignatures *this_ptr, LDKSignature val); +void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *this_ptr, struct LDKSignature val); -MUST_USE_RES LDKAnnouncementSignatures AnnouncementSignatures_new(LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, LDKSignature node_signature_arg, LDKSignature bitcoin_signature_arg); +MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); -void NetAddress_free(LDKNetAddress this_ptr); +void NetAddress_free(struct LDKNetAddress this_ptr); -LDKNetAddress NetAddress_clone(const LDKNetAddress *orig); +struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *orig); -void UnsignedNodeAnnouncement_free(LDKUnsignedNodeAnnouncement this_ptr); +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_ptr); -LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const LDKUnsignedNodeAnnouncement *orig); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *orig); /** * The advertised features */ -LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const LDKUnsignedNodeAnnouncement *this_ptr); +struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *this_ptr); /** * The advertised features */ -void UnsignedNodeAnnouncement_set_features(LDKUnsignedNodeAnnouncement *this_ptr, LDKNodeFeatures val); +void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *this_ptr, struct LDKNodeFeatures val); /** * A strictly monotonic announcement counter, with gaps allowed */ -uint32_t UnsignedNodeAnnouncement_get_timestamp(const LDKUnsignedNodeAnnouncement *this_ptr); +uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *this_ptr); /** * A strictly monotonic announcement counter, with gaps allowed */ -void UnsignedNodeAnnouncement_set_timestamp(LDKUnsignedNodeAnnouncement *this_ptr, uint32_t val); +void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *this_ptr, uint32_t val); /** * The node_id this announcement originated from (don't rebroadcast the node_announcement back * to this node). */ -LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const LDKUnsignedNodeAnnouncement *this_ptr); +struct LDKPublicKey UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *this_ptr); /** * The node_id this announcement originated from (don't rebroadcast the node_announcement back * to this node). */ -void UnsignedNodeAnnouncement_set_node_id(LDKUnsignedNodeAnnouncement *this_ptr, LDKPublicKey val); +void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *this_ptr, struct LDKPublicKey val); /** * An RGB color for UI purposes */ -const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const LDKUnsignedNodeAnnouncement *this_ptr))[3]; +const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *this_ptr))[3]; /** * An RGB color for UI purposes */ -void UnsignedNodeAnnouncement_set_rgb(LDKUnsignedNodeAnnouncement *this_ptr, LDKThreeBytes val); +void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *this_ptr, struct LDKThreeBytes val); /** * An alias, for UI purposes. This should be sanitized before use. There is no guarantee * of uniqueness. */ -const uint8_t (*UnsignedNodeAnnouncement_get_alias(const LDKUnsignedNodeAnnouncement *this_ptr))[32]; +const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *this_ptr))[32]; /** * An alias, for UI purposes. This should be sanitized before use. There is no guarantee * of uniqueness. */ -void UnsignedNodeAnnouncement_set_alias(LDKUnsignedNodeAnnouncement *this_ptr, LDKThirtyTwoBytes val); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *this_ptr, struct LDKThirtyTwoBytes val); /** * List of addresses on which this node is reachable */ -void UnsignedNodeAnnouncement_set_addresses(LDKUnsignedNodeAnnouncement *this_ptr, LDKCVec_NetAddressZ val); +void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *this_ptr, LDKCVec_NetAddressZ val); -void NodeAnnouncement_free(LDKNodeAnnouncement this_ptr); +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_ptr); -LDKNodeAnnouncement NodeAnnouncement_clone(const LDKNodeAnnouncement *orig); +struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *orig); /** * The signature by the node key */ -LDKSignature NodeAnnouncement_get_signature(const LDKNodeAnnouncement *this_ptr); +struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *this_ptr); /** * The signature by the node key */ -void NodeAnnouncement_set_signature(LDKNodeAnnouncement *this_ptr, LDKSignature val); +void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *this_ptr, struct LDKSignature val); /** * The actual content of the announcement */ -LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const LDKNodeAnnouncement *this_ptr); +struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *this_ptr); /** * The actual content of the announcement */ -void NodeAnnouncement_set_contents(LDKNodeAnnouncement *this_ptr, LDKUnsignedNodeAnnouncement val); +void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *this_ptr, struct LDKUnsignedNodeAnnouncement val); -MUST_USE_RES LDKNodeAnnouncement NodeAnnouncement_new(LDKSignature signature_arg, LDKUnsignedNodeAnnouncement contents_arg); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); -void UnsignedChannelAnnouncement_free(LDKUnsignedChannelAnnouncement this_ptr); +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_ptr); -LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const LDKUnsignedChannelAnnouncement *orig); +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *orig); /** * The advertised channel features */ -LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const LDKUnsignedChannelAnnouncement *this_ptr); +struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *this_ptr); /** * The advertised channel features */ -void UnsignedChannelAnnouncement_set_features(LDKUnsignedChannelAnnouncement *this_ptr, LDKChannelFeatures val); +void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *this_ptr, struct LDKChannelFeatures val); /** * The genesis hash of the blockchain where the channel is to be opened */ -const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const LDKUnsignedChannelAnnouncement *this_ptr))[32]; +const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *this_ptr))[32]; /** * The genesis hash of the blockchain where the channel is to be opened */ -void UnsignedChannelAnnouncement_set_chain_hash(LDKUnsignedChannelAnnouncement *this_ptr, LDKThirtyTwoBytes val); +void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *this_ptr, struct LDKThirtyTwoBytes val); /** * The short channel ID */ -uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const LDKUnsignedChannelAnnouncement *this_ptr); +uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *this_ptr); /** * The short channel ID */ -void UnsignedChannelAnnouncement_set_short_channel_id(LDKUnsignedChannelAnnouncement *this_ptr, uint64_t val); +void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *this_ptr, uint64_t val); /** * One of the two node_ids which are endpoints of this channel */ -LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const LDKUnsignedChannelAnnouncement *this_ptr); +struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *this_ptr); /** * One of the two node_ids which are endpoints of this channel */ -void UnsignedChannelAnnouncement_set_node_id_1(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val); +void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *this_ptr, struct LDKPublicKey val); /** * The other of the two node_ids which are endpoints of this channel */ -LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const LDKUnsignedChannelAnnouncement *this_ptr); +struct LDKPublicKey UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *this_ptr); /** * The other of the two node_ids which are endpoints of this channel */ -void UnsignedChannelAnnouncement_set_node_id_2(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val); +void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *this_ptr, struct LDKPublicKey val); /** * The funding key for the first node */ -LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const LDKUnsignedChannelAnnouncement *this_ptr); +struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *this_ptr); /** * The funding key for the first node */ -void UnsignedChannelAnnouncement_set_bitcoin_key_1(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val); +void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *this_ptr, struct LDKPublicKey val); /** * The funding key for the second node */ -LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const LDKUnsignedChannelAnnouncement *this_ptr); +struct LDKPublicKey UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *this_ptr); /** * The funding key for the second node */ -void UnsignedChannelAnnouncement_set_bitcoin_key_2(LDKUnsignedChannelAnnouncement *this_ptr, LDKPublicKey val); +void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *this_ptr, struct LDKPublicKey val); -void ChannelAnnouncement_free(LDKChannelAnnouncement this_ptr); +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_ptr); -LDKChannelAnnouncement ChannelAnnouncement_clone(const LDKChannelAnnouncement *orig); +struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *orig); /** * Authentication of the announcement by the first public node */ -LDKSignature ChannelAnnouncement_get_node_signature_1(const LDKChannelAnnouncement *this_ptr); +struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *this_ptr); /** * Authentication of the announcement by the first public node */ -void ChannelAnnouncement_set_node_signature_1(LDKChannelAnnouncement *this_ptr, LDKSignature val); +void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *this_ptr, struct LDKSignature val); /** * Authentication of the announcement by the second public node */ -LDKSignature ChannelAnnouncement_get_node_signature_2(const LDKChannelAnnouncement *this_ptr); +struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *this_ptr); /** * Authentication of the announcement by the second public node */ -void ChannelAnnouncement_set_node_signature_2(LDKChannelAnnouncement *this_ptr, LDKSignature val); +void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *this_ptr, struct LDKSignature val); /** * Proof of funding UTXO ownership by the first public node */ -LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const LDKChannelAnnouncement *this_ptr); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *this_ptr); /** * Proof of funding UTXO ownership by the first public node */ -void ChannelAnnouncement_set_bitcoin_signature_1(LDKChannelAnnouncement *this_ptr, LDKSignature val); +void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *this_ptr, struct LDKSignature val); /** * Proof of funding UTXO ownership by the second public node */ -LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const LDKChannelAnnouncement *this_ptr); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *this_ptr); /** * Proof of funding UTXO ownership by the second public node */ -void ChannelAnnouncement_set_bitcoin_signature_2(LDKChannelAnnouncement *this_ptr, LDKSignature val); +void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *this_ptr, struct LDKSignature val); /** * The actual announcement */ -LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const LDKChannelAnnouncement *this_ptr); +struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *this_ptr); /** * The actual announcement */ -void ChannelAnnouncement_set_contents(LDKChannelAnnouncement *this_ptr, LDKUnsignedChannelAnnouncement val); +void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *this_ptr, struct LDKUnsignedChannelAnnouncement val); -MUST_USE_RES LDKChannelAnnouncement ChannelAnnouncement_new(LDKSignature node_signature_1_arg, LDKSignature node_signature_2_arg, LDKSignature bitcoin_signature_1_arg, LDKSignature bitcoin_signature_2_arg, LDKUnsignedChannelAnnouncement contents_arg); +MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); -void UnsignedChannelUpdate_free(LDKUnsignedChannelUpdate this_ptr); +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_ptr); -LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const LDKUnsignedChannelUpdate *orig); +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *orig); /** * The genesis hash of the blockchain where the channel is to be opened */ -const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const LDKUnsignedChannelUpdate *this_ptr))[32]; +const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *this_ptr))[32]; /** * The genesis hash of the blockchain where the channel is to be opened */ -void UnsignedChannelUpdate_set_chain_hash(LDKUnsignedChannelUpdate *this_ptr, LDKThirtyTwoBytes val); +void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *this_ptr, struct LDKThirtyTwoBytes val); /** * The short channel ID */ -uint64_t UnsignedChannelUpdate_get_short_channel_id(const LDKUnsignedChannelUpdate *this_ptr); +uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *this_ptr); /** * The short channel ID */ -void UnsignedChannelUpdate_set_short_channel_id(LDKUnsignedChannelUpdate *this_ptr, uint64_t val); +void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *this_ptr, uint64_t val); /** * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -uint32_t UnsignedChannelUpdate_get_timestamp(const LDKUnsignedChannelUpdate *this_ptr); +uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *this_ptr); /** * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -void UnsignedChannelUpdate_set_timestamp(LDKUnsignedChannelUpdate *this_ptr, uint32_t val); +void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *this_ptr, uint32_t val); /** * Channel flags */ -uint8_t UnsignedChannelUpdate_get_flags(const LDKUnsignedChannelUpdate *this_ptr); +uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *this_ptr); /** * Channel flags */ -void UnsignedChannelUpdate_set_flags(LDKUnsignedChannelUpdate *this_ptr, uint8_t val); +void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *this_ptr, uint8_t val); /** * The number of blocks to subtract from incoming HTLC cltv_expiry values */ -uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const LDKUnsignedChannelUpdate *this_ptr); +uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *this_ptr); /** * The number of blocks to subtract from incoming HTLC cltv_expiry values */ -void UnsignedChannelUpdate_set_cltv_expiry_delta(LDKUnsignedChannelUpdate *this_ptr, uint16_t val); +void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *this_ptr, uint16_t val); /** * The minimum HTLC size incoming to sender, in milli-satoshi */ -uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const LDKUnsignedChannelUpdate *this_ptr); +uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *this_ptr); /** * The minimum HTLC size incoming to sender, in milli-satoshi */ -void UnsignedChannelUpdate_set_htlc_minimum_msat(LDKUnsignedChannelUpdate *this_ptr, uint64_t val); +void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *this_ptr, uint64_t val); /** * The base HTLC fee charged by sender, in milli-satoshi */ -uint32_t UnsignedChannelUpdate_get_fee_base_msat(const LDKUnsignedChannelUpdate *this_ptr); +uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *this_ptr); /** * The base HTLC fee charged by sender, in milli-satoshi */ -void UnsignedChannelUpdate_set_fee_base_msat(LDKUnsignedChannelUpdate *this_ptr, uint32_t val); +void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *this_ptr, uint32_t val); /** * The amount to fee multiplier, in micro-satoshi */ -uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const LDKUnsignedChannelUpdate *this_ptr); +uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *this_ptr); /** * The amount to fee multiplier, in micro-satoshi */ -void UnsignedChannelUpdate_set_fee_proportional_millionths(LDKUnsignedChannelUpdate *this_ptr, uint32_t val); +void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *this_ptr, uint32_t val); -void ChannelUpdate_free(LDKChannelUpdate this_ptr); +void ChannelUpdate_free(struct LDKChannelUpdate this_ptr); -LDKChannelUpdate ChannelUpdate_clone(const LDKChannelUpdate *orig); +struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *orig); /** * A signature of the channel update */ -LDKSignature ChannelUpdate_get_signature(const LDKChannelUpdate *this_ptr); +struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *this_ptr); /** * A signature of the channel update */ -void ChannelUpdate_set_signature(LDKChannelUpdate *this_ptr, LDKSignature val); +void ChannelUpdate_set_signature(struct LDKChannelUpdate *this_ptr, struct LDKSignature val); /** * The actual channel update */ -LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const LDKChannelUpdate *this_ptr); +struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *this_ptr); /** * The actual channel update */ -void ChannelUpdate_set_contents(LDKChannelUpdate *this_ptr, LDKUnsignedChannelUpdate val); +void ChannelUpdate_set_contents(struct LDKChannelUpdate *this_ptr, struct LDKUnsignedChannelUpdate val); -MUST_USE_RES LDKChannelUpdate ChannelUpdate_new(LDKSignature signature_arg, LDKUnsignedChannelUpdate contents_arg); +MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); -void QueryChannelRange_free(LDKQueryChannelRange this_ptr); +void QueryChannelRange_free(struct LDKQueryChannelRange this_ptr); -LDKQueryChannelRange QueryChannelRange_clone(const LDKQueryChannelRange *orig); +struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *orig); /** * The genesis hash of the blockchain being queried */ -const uint8_t (*QueryChannelRange_get_chain_hash(const LDKQueryChannelRange *this_ptr))[32]; +const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *this_ptr))[32]; /** * The genesis hash of the blockchain being queried */ -void QueryChannelRange_set_chain_hash(LDKQueryChannelRange *this_ptr, LDKThirtyTwoBytes val); +void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *this_ptr, struct LDKThirtyTwoBytes val); /** * The height of the first block for the channel UTXOs being queried */ -uint32_t QueryChannelRange_get_first_blocknum(const LDKQueryChannelRange *this_ptr); +uint32_t QueryChannelRange_get_first_blocknum(const struct 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); +void QueryChannelRange_set_first_blocknum(struct 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); +uint32_t QueryChannelRange_get_number_of_blocks(const struct 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); +void QueryChannelRange_set_number_of_blocks(struct 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); +MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); -void ReplyChannelRange_free(LDKReplyChannelRange this_ptr); +void ReplyChannelRange_free(struct LDKReplyChannelRange this_ptr); -LDKReplyChannelRange ReplyChannelRange_clone(const LDKReplyChannelRange *orig); +struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *orig); /** * The genesis hash of the blockchain being queried */ -const uint8_t (*ReplyChannelRange_get_chain_hash(const LDKReplyChannelRange *this_ptr))[32]; +const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *this_ptr))[32]; /** * The genesis hash of the blockchain being queried */ -void ReplyChannelRange_set_chain_hash(LDKReplyChannelRange *this_ptr, LDKThirtyTwoBytes val); +void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *this_ptr, struct LDKThirtyTwoBytes val); /** * The height of the first block in the range of the reply */ -uint32_t ReplyChannelRange_get_first_blocknum(const LDKReplyChannelRange *this_ptr); +uint32_t ReplyChannelRange_get_first_blocknum(const struct 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); +void ReplyChannelRange_set_first_blocknum(struct 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); +uint32_t ReplyChannelRange_get_number_of_blocks(const struct 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); +void ReplyChannelRange_set_number_of_blocks(struct 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); +bool ReplyChannelRange_get_full_information(const struct 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); +void ReplyChannelRange_set_full_information(struct 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); +void ReplyChannelRange_set_short_channel_ids(struct 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); +MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct 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); +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_ptr); -LDKQueryShortChannelIds QueryShortChannelIds_clone(const LDKQueryShortChannelIds *orig); +struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *orig); /** * The genesis hash of the blockchain being queried */ -const uint8_t (*QueryShortChannelIds_get_chain_hash(const LDKQueryShortChannelIds *this_ptr))[32]; +const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *this_ptr))[32]; /** * The genesis hash of the blockchain being queried */ -void QueryShortChannelIds_set_chain_hash(LDKQueryShortChannelIds *this_ptr, LDKThirtyTwoBytes val); +void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *this_ptr, struct LDKThirtyTwoBytes val); /** * The short_channel_ids that are being queried */ -void QueryShortChannelIds_set_short_channel_ids(LDKQueryShortChannelIds *this_ptr, LDKCVec_u64Z val); +void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *this_ptr, LDKCVec_u64Z val); -MUST_USE_RES LDKQueryShortChannelIds QueryShortChannelIds_new(LDKThirtyTwoBytes chain_hash_arg, LDKCVec_u64Z short_channel_ids_arg); +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, LDKCVec_u64Z short_channel_ids_arg); -void ReplyShortChannelIdsEnd_free(LDKReplyShortChannelIdsEnd this_ptr); +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_ptr); -LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const LDKReplyShortChannelIdsEnd *orig); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *orig); /** * The genesis hash of the blockchain that was queried */ -const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const LDKReplyShortChannelIdsEnd *this_ptr))[32]; +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *this_ptr))[32]; /** * The genesis hash of the blockchain that was queried */ -void ReplyShortChannelIdsEnd_set_chain_hash(LDKReplyShortChannelIdsEnd *this_ptr, LDKThirtyTwoBytes val); +void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *this_ptr, struct 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); +bool ReplyShortChannelIdsEnd_get_full_information(const struct 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); +void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *this_ptr, bool val); -MUST_USE_RES LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); -void GossipTimestampFilter_free(LDKGossipTimestampFilter this_ptr); +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_ptr); -LDKGossipTimestampFilter GossipTimestampFilter_clone(const LDKGossipTimestampFilter *orig); +struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *orig); /** * The genesis hash of the blockchain for channel and node information */ -const uint8_t (*GossipTimestampFilter_get_chain_hash(const LDKGossipTimestampFilter *this_ptr))[32]; +const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct 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); +void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *this_ptr, struct LDKThirtyTwoBytes val); /** * The starting unix timestamp */ -uint32_t GossipTimestampFilter_get_first_timestamp(const LDKGossipTimestampFilter *this_ptr); +uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *this_ptr); /** * The starting unix timestamp */ -void GossipTimestampFilter_set_first_timestamp(LDKGossipTimestampFilter *this_ptr, uint32_t val); +void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *this_ptr, uint32_t val); /** * The range of information in seconds */ -uint32_t GossipTimestampFilter_get_timestamp_range(const LDKGossipTimestampFilter *this_ptr); +uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *this_ptr); /** * The range of information in seconds */ -void GossipTimestampFilter_set_timestamp_range(LDKGossipTimestampFilter *this_ptr, uint32_t val); +void GossipTimestampFilter_set_timestamp_range(struct 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); +MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); -void ErrorAction_free(LDKErrorAction this_ptr); +void ErrorAction_free(struct LDKErrorAction this_ptr); -LDKErrorAction ErrorAction_clone(const LDKErrorAction *orig); +struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *orig); -void LightningError_free(LDKLightningError this_ptr); +void LightningError_free(struct LDKLightningError this_ptr); /** * A human-readable message describing the error */ -LDKStr LightningError_get_err(const LDKLightningError *this_ptr); +struct LDKStr LightningError_get_err(const struct LDKLightningError *this_ptr); /** * A human-readable message describing the error */ -void LightningError_set_err(LDKLightningError *this_ptr, LDKCVec_u8Z val); +void LightningError_set_err(struct LDKLightningError *this_ptr, LDKCVec_u8Z val); /** * The action which should be taken against the offending peer. */ -LDKErrorAction LightningError_get_action(const LDKLightningError *this_ptr); +struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *this_ptr); /** * The action which should be taken against the offending peer. */ -void LightningError_set_action(LDKLightningError *this_ptr, LDKErrorAction val); +void LightningError_set_action(struct LDKLightningError *this_ptr, struct LDKErrorAction val); -MUST_USE_RES LDKLightningError LightningError_new(LDKCVec_u8Z err_arg, LDKErrorAction action_arg); +MUST_USE_RES struct LDKLightningError LightningError_new(LDKCVec_u8Z err_arg, struct LDKErrorAction action_arg); -void CommitmentUpdate_free(LDKCommitmentUpdate this_ptr); +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_ptr); -LDKCommitmentUpdate CommitmentUpdate_clone(const LDKCommitmentUpdate *orig); +struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *orig); /** * update_add_htlc messages which should be sent */ -void CommitmentUpdate_set_update_add_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateAddHTLCZ val); +void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateAddHTLCZ val); /** * update_fulfill_htlc messages which should be sent */ -void CommitmentUpdate_set_update_fulfill_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFulfillHTLCZ val); +void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFulfillHTLCZ val); /** * update_fail_htlc messages which should be sent */ -void CommitmentUpdate_set_update_fail_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailHTLCZ val); +void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailHTLCZ val); /** * update_fail_malformed_htlc messages which should be sent */ -void CommitmentUpdate_set_update_fail_malformed_htlcs(LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailMalformedHTLCZ val); +void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *this_ptr, LDKCVec_UpdateFailMalformedHTLCZ val); /** * An update_fee message which should be sent */ -LDKUpdateFee CommitmentUpdate_get_update_fee(const LDKCommitmentUpdate *this_ptr); +struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *this_ptr); /** * An update_fee message which should be sent */ -void CommitmentUpdate_set_update_fee(LDKCommitmentUpdate *this_ptr, LDKUpdateFee val); +void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *this_ptr, struct LDKUpdateFee val); /** * Finally, the commitment_signed message which should be sent */ -LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const LDKCommitmentUpdate *this_ptr); +struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *this_ptr); /** * Finally, the commitment_signed message which should be sent */ -void CommitmentUpdate_set_commitment_signed(LDKCommitmentUpdate *this_ptr, LDKCommitmentSigned val); +void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *this_ptr, struct LDKCommitmentSigned val); -MUST_USE_RES LDKCommitmentUpdate CommitmentUpdate_new(LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, LDKUpdateFee update_fee_arg, LDKCommitmentSigned commitment_signed_arg); +MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); -void HTLCFailChannelUpdate_free(LDKHTLCFailChannelUpdate this_ptr); +void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr); -LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const LDKHTLCFailChannelUpdate *orig); +struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *orig); /** * Calls the free function if one is set */ -void ChannelMessageHandler_free(LDKChannelMessageHandler this_ptr); +void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); /** * Calls the free function if one is set */ -void RoutingMessageHandler_free(LDKRoutingMessageHandler this_ptr); +void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); -LDKCVec_u8Z AcceptChannel_write(const LDKAcceptChannel *obj); +LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *obj); -LDKAcceptChannel AcceptChannel_read(LDKu8slice ser); +struct LDKAcceptChannel AcceptChannel_read(struct LDKu8slice ser); -LDKCVec_u8Z AnnouncementSignatures_write(const LDKAnnouncementSignatures *obj); +LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *obj); -LDKAnnouncementSignatures AnnouncementSignatures_read(LDKu8slice ser); +struct LDKAnnouncementSignatures AnnouncementSignatures_read(struct LDKu8slice ser); -LDKCVec_u8Z ChannelReestablish_write(const LDKChannelReestablish *obj); +LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *obj); -LDKChannelReestablish ChannelReestablish_read(LDKu8slice ser); +struct LDKChannelReestablish ChannelReestablish_read(struct LDKu8slice ser); -LDKCVec_u8Z ClosingSigned_write(const LDKClosingSigned *obj); +LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *obj); -LDKClosingSigned ClosingSigned_read(LDKu8slice ser); +struct LDKClosingSigned ClosingSigned_read(struct LDKu8slice ser); -LDKCVec_u8Z CommitmentSigned_write(const LDKCommitmentSigned *obj); +LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *obj); -LDKCommitmentSigned CommitmentSigned_read(LDKu8slice ser); +struct LDKCommitmentSigned CommitmentSigned_read(struct LDKu8slice ser); -LDKCVec_u8Z FundingCreated_write(const LDKFundingCreated *obj); +LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *obj); -LDKFundingCreated FundingCreated_read(LDKu8slice ser); +struct LDKFundingCreated FundingCreated_read(struct LDKu8slice ser); -LDKCVec_u8Z FundingSigned_write(const LDKFundingSigned *obj); +LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *obj); -LDKFundingSigned FundingSigned_read(LDKu8slice ser); +struct LDKFundingSigned FundingSigned_read(struct LDKu8slice ser); -LDKCVec_u8Z FundingLocked_write(const LDKFundingLocked *obj); +LDKCVec_u8Z FundingLocked_write(const struct LDKFundingLocked *obj); -LDKFundingLocked FundingLocked_read(LDKu8slice ser); +struct LDKFundingLocked FundingLocked_read(struct LDKu8slice ser); -LDKCVec_u8Z Init_write(const LDKInit *obj); +LDKCVec_u8Z Init_write(const struct LDKInit *obj); -LDKInit Init_read(LDKu8slice ser); +struct LDKInit Init_read(struct LDKu8slice ser); -LDKCVec_u8Z OpenChannel_write(const LDKOpenChannel *obj); +LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *obj); -LDKOpenChannel OpenChannel_read(LDKu8slice ser); +struct LDKOpenChannel OpenChannel_read(struct LDKu8slice ser); -LDKCVec_u8Z RevokeAndACK_write(const LDKRevokeAndACK *obj); +LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *obj); -LDKRevokeAndACK RevokeAndACK_read(LDKu8slice ser); +struct LDKRevokeAndACK RevokeAndACK_read(struct LDKu8slice ser); -LDKCVec_u8Z Shutdown_write(const LDKShutdown *obj); +LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *obj); -LDKShutdown Shutdown_read(LDKu8slice ser); +struct LDKShutdown Shutdown_read(struct LDKu8slice ser); -LDKCVec_u8Z UpdateFailHTLC_write(const LDKUpdateFailHTLC *obj); +LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *obj); -LDKUpdateFailHTLC UpdateFailHTLC_read(LDKu8slice ser); +struct LDKUpdateFailHTLC UpdateFailHTLC_read(struct LDKu8slice ser); -LDKCVec_u8Z UpdateFailMalformedHTLC_write(const LDKUpdateFailMalformedHTLC *obj); +LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *obj); -LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_read(LDKu8slice ser); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_read(struct LDKu8slice ser); -LDKCVec_u8Z UpdateFee_write(const LDKUpdateFee *obj); +LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *obj); -LDKUpdateFee UpdateFee_read(LDKu8slice ser); +struct LDKUpdateFee UpdateFee_read(struct LDKu8slice ser); -LDKCVec_u8Z UpdateFulfillHTLC_write(const LDKUpdateFulfillHTLC *obj); +LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *obj); -LDKUpdateFulfillHTLC UpdateFulfillHTLC_read(LDKu8slice ser); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_read(struct LDKu8slice ser); -LDKCVec_u8Z UpdateAddHTLC_write(const LDKUpdateAddHTLC *obj); +LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *obj); -LDKUpdateAddHTLC UpdateAddHTLC_read(LDKu8slice ser); +struct LDKUpdateAddHTLC UpdateAddHTLC_read(struct LDKu8slice ser); -LDKCVec_u8Z Ping_write(const LDKPing *obj); +LDKCVec_u8Z Ping_write(const struct LDKPing *obj); -LDKPing Ping_read(LDKu8slice ser); +struct LDKPing Ping_read(struct LDKu8slice ser); -LDKCVec_u8Z Pong_write(const LDKPong *obj); +LDKCVec_u8Z Pong_write(const struct LDKPong *obj); -LDKPong Pong_read(LDKu8slice ser); +struct LDKPong Pong_read(struct LDKu8slice ser); -LDKCVec_u8Z UnsignedChannelAnnouncement_write(const LDKUnsignedChannelAnnouncement *obj); +LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *obj); -LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_read(LDKu8slice ser); +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_read(struct LDKu8slice ser); -LDKCVec_u8Z ChannelAnnouncement_write(const LDKChannelAnnouncement *obj); +LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *obj); -LDKChannelAnnouncement ChannelAnnouncement_read(LDKu8slice ser); +struct LDKChannelAnnouncement ChannelAnnouncement_read(struct LDKu8slice ser); -LDKCVec_u8Z UnsignedChannelUpdate_write(const LDKUnsignedChannelUpdate *obj); +LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *obj); -LDKUnsignedChannelUpdate UnsignedChannelUpdate_read(LDKu8slice ser); +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_read(struct LDKu8slice ser); -LDKCVec_u8Z ChannelUpdate_write(const LDKChannelUpdate *obj); +LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *obj); -LDKChannelUpdate ChannelUpdate_read(LDKu8slice ser); +struct LDKChannelUpdate ChannelUpdate_read(struct LDKu8slice ser); -LDKCVec_u8Z ErrorMessage_write(const LDKErrorMessage *obj); +LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *obj); -LDKErrorMessage ErrorMessage_read(LDKu8slice ser); +struct LDKErrorMessage ErrorMessage_read(struct LDKu8slice ser); -LDKCVec_u8Z UnsignedNodeAnnouncement_write(const LDKUnsignedNodeAnnouncement *obj); +LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *obj); -LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_read(LDKu8slice ser); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_read(struct LDKu8slice ser); -LDKCVec_u8Z NodeAnnouncement_write(const LDKNodeAnnouncement *obj); +LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *obj); -LDKNodeAnnouncement NodeAnnouncement_read(LDKu8slice ser); +struct LDKNodeAnnouncement NodeAnnouncement_read(struct LDKu8slice ser); -LDKQueryShortChannelIds QueryShortChannelIds_read(LDKu8slice ser); +struct LDKQueryShortChannelIds QueryShortChannelIds_read(struct LDKu8slice ser); -LDKCVec_u8Z QueryShortChannelIds_write(const LDKQueryShortChannelIds *obj); +LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *obj); -LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_read(LDKu8slice ser); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); -LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const LDKReplyShortChannelIdsEnd *obj); +LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *obj); -LDKQueryChannelRange QueryChannelRange_read(LDKu8slice ser); +struct LDKQueryChannelRange QueryChannelRange_read(struct LDKu8slice ser); -LDKCVec_u8Z QueryChannelRange_write(const LDKQueryChannelRange *obj); +LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *obj); -LDKReplyChannelRange ReplyChannelRange_read(LDKu8slice ser); +struct LDKReplyChannelRange ReplyChannelRange_read(struct LDKu8slice ser); -LDKCVec_u8Z ReplyChannelRange_write(const LDKReplyChannelRange *obj); +LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *obj); -LDKGossipTimestampFilter GossipTimestampFilter_read(LDKu8slice ser); +struct LDKGossipTimestampFilter GossipTimestampFilter_read(struct LDKu8slice ser); -LDKCVec_u8Z GossipTimestampFilter_write(const LDKGossipTimestampFilter *obj); +LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *obj); -void MessageHandler_free(LDKMessageHandler this_ptr); +void MessageHandler_free(struct LDKMessageHandler this_ptr); /** * A message handler which handles messages specific to channels. Usually this is just a * ChannelManager object. */ -const LDKChannelMessageHandler *MessageHandler_get_chan_handler(const LDKMessageHandler *this_ptr); +const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *this_ptr); /** * A message handler which handles messages specific to channels. Usually this is just a * ChannelManager object. */ -void MessageHandler_set_chan_handler(LDKMessageHandler *this_ptr, LDKChannelMessageHandler val); +void MessageHandler_set_chan_handler(struct LDKMessageHandler *this_ptr, struct LDKChannelMessageHandler val); /** * A message handler which handles messages updating our knowledge of the network channel * graph. Usually this is just a NetGraphMsgHandlerMonitor object. */ -const LDKRoutingMessageHandler *MessageHandler_get_route_handler(const LDKMessageHandler *this_ptr); +const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *this_ptr); /** * A message handler which handles messages updating our knowledge of the network channel * graph. Usually this is just a NetGraphMsgHandlerMonitor object. */ -void MessageHandler_set_route_handler(LDKMessageHandler *this_ptr, LDKRoutingMessageHandler val); +void MessageHandler_set_route_handler(struct LDKMessageHandler *this_ptr, struct LDKRoutingMessageHandler val); -MUST_USE_RES LDKMessageHandler MessageHandler_new(LDKChannelMessageHandler chan_handler_arg, LDKRoutingMessageHandler route_handler_arg); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg); -LDKSocketDescriptor SocketDescriptor_clone(const LDKSocketDescriptor *orig); +struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *orig); /** * Calls the free function if one is set */ -void SocketDescriptor_free(LDKSocketDescriptor this_ptr); +void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); -void PeerHandleError_free(LDKPeerHandleError this_ptr); +void PeerHandleError_free(struct LDKPeerHandleError this_ptr); /** * Used to indicate that we probably can't make any future connections to this peer, implying * we should go ahead and force-close any channels we have with it. */ -bool PeerHandleError_get_no_connection_possible(const LDKPeerHandleError *this_ptr); +bool PeerHandleError_get_no_connection_possible(const struct LDKPeerHandleError *this_ptr); /** * Used to indicate that we probably can't make any future connections to this peer, implying * we should go ahead and force-close any channels we have with it. */ -void PeerHandleError_set_no_connection_possible(LDKPeerHandleError *this_ptr, bool val); +void PeerHandleError_set_no_connection_possible(struct LDKPeerHandleError *this_ptr, bool val); -MUST_USE_RES LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); +MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(bool no_connection_possible_arg); -void PeerManager_free(LDKPeerManager this_ptr); +void PeerManager_free(struct LDKPeerManager this_ptr); /** * Constructs a new PeerManager with the given message handlers and node_id secret key * ephemeral_random_data is used to derive per-connection ephemeral keys and must be * cryptographically secure random bytes. */ -MUST_USE_RES LDKPeerManager PeerManager_new(LDKMessageHandler message_handler, LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], LDKLogger logger); +MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger); /** * Get the list of node ids for peers which have completed the initial handshake. @@ -6300,7 +6482,7 @@ MUST_USE_RES LDKPeerManager PeerManager_new(LDKMessageHandler message_handler, L * new_outbound_connection, however entries will only appear once the initial handshake has * completed and we are sure the remote peer has the private key for the given node_id. */ -MUST_USE_RES LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const LDKPeerManager *this_arg); +MUST_USE_RES LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *this_arg); /** * Indicates a new outbound connection has been established to a node with the given node_id. @@ -6312,7 +6494,7 @@ MUST_USE_RES LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const LDKPeerManag * Panics if descriptor is duplicative with some other descriptor which has not yet had a * socket_disconnected(). */ -MUST_USE_RES LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const LDKPeerManager *this_arg, LDKPublicKey their_node_id, LDKSocketDescriptor descriptor); +MUST_USE_RES LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor); /** * Indicates a new inbound connection has been established. @@ -6325,7 +6507,7 @@ MUST_USE_RES LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connec * Panics if descriptor is duplicative with some other descriptor which has not yet had * socket_disconnected called. */ -MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const LDKPeerManager *this_arg, LDKSocketDescriptor descriptor); +MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *this_arg, struct LDKSocketDescriptor descriptor); /** * Indicates that there is room to write data to the given socket descriptor. @@ -6339,7 +6521,7 @@ MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection( * here isn't sufficient! Panics if the descriptor was not previously registered in a * new_\\*_connection event. */ -MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const LDKPeerManager *this_arg, LDKSocketDescriptor *descriptor); +MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *this_arg, struct LDKSocketDescriptor *descriptor); /** * Indicates that data was read from the given socket descriptor. @@ -6355,14 +6537,14 @@ MUST_USE_RES LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avai * * Panics if the descriptor was not previously registered in a new_*_connection event. */ -MUST_USE_RES LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const LDKPeerManager *this_arg, LDKSocketDescriptor *peer_descriptor, LDKu8slice data); +MUST_USE_RES LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *this_arg, struct LDKSocketDescriptor *peer_descriptor, struct LDKu8slice data); /** * Checks for any events generated by our handlers and processes them. Includes sending most * response messages as well as messages generated by calls to handler functions directly (eg * functions like ChannelManager::process_pending_htlc_forward or send_payment). */ -void PeerManager_process_events(const LDKPeerManager *this_arg); +void PeerManager_process_events(const struct LDKPeerManager *this_arg); /** * Indicates that the given socket descriptor's connection is now closed. @@ -6374,19 +6556,30 @@ void PeerManager_process_events(const LDKPeerManager *this_arg); * * Panics if the descriptor was not previously registered in a successful new_*_connection event. */ -void PeerManager_socket_disconnected(const LDKPeerManager *this_arg, const LDKSocketDescriptor *descriptor); +void PeerManager_socket_disconnected(const struct LDKPeerManager *this_arg, const struct LDKSocketDescriptor *descriptor); + +/** + * Disconnect a peer given its node id. + * + * Set no_connection_possible to true to prevent any further connection with this peer, + * force-closing any channels we have with it. + * + * If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, + * so be careful about reentrancy issues. + */ +void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *this_arg, struct LDKPublicKey node_id, bool no_connection_possible); /** * This function should be called roughly once every 30 seconds. * It will send pings to each peer and disconnect those which did not respond to the last round of pings. * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues! */ -void PeerManager_timer_tick_occured(const LDKPeerManager *this_arg); +void PeerManager_timer_tick_occured(const struct LDKPeerManager *this_arg); /** * Build the commitment secret from the seed and the commitment number */ -LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); +struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); /** * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) @@ -6395,7 +6588,7 @@ LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], * 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_key(LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); +LDKCResult_SecretKeySecpErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); /** * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) @@ -6405,7 +6598,7 @@ LDKCResult_SecretKeySecpErrorZ derive_private_key(LDKPublicKey per_commitment_po * 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_key(LDKPublicKey per_commitment_point, LDKPublicKey base_point); +LDKCResult_PublicKeySecpErrorZ derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); /** * Derives a per-commitment-transaction revocation key from its constituent parts. @@ -6433,107 +6626,87 @@ LDKCResult_SecretKeySecpErrorZ derive_private_revocation_key(const uint8_t (*per * 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 countersignatory_revocation_base_point); +LDKCResult_PublicKeySecpErrorZ derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); -void TxCreationKeys_free(LDKTxCreationKeys this_ptr); +void TxCreationKeys_free(struct LDKTxCreationKeys this_ptr); -LDKTxCreationKeys TxCreationKeys_clone(const LDKTxCreationKeys *orig); +struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *orig); /** * 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); +struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *this_ptr); /** * 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); +void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *this_ptr, struct LDKPublicKey val); /** * 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); +struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *this_ptr); /** * 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); +void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *this_ptr, struct LDKPublicKey val); /** * Broadcaster's HTLC Key */ -LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const LDKTxCreationKeys *this_ptr); +struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *this_ptr); /** * Broadcaster's HTLC Key */ -void TxCreationKeys_set_broadcaster_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); +void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *this_ptr, struct LDKPublicKey val); /** * Countersignatory's HTLC Key */ -LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const LDKTxCreationKeys *this_ptr); +struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *this_ptr); /** * Countersignatory's HTLC Key */ -void TxCreationKeys_set_countersignatory_htlc_key(LDKTxCreationKeys *this_ptr, LDKPublicKey val); +void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *this_ptr, struct LDKPublicKey val); /** * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const LDKTxCreationKeys *this_ptr); +struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *this_ptr); /** * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -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 broadcaster_htlc_key_arg, LDKPublicKey countersignatory_htlc_key_arg, LDKPublicKey broadcaster_delayed_payment_key_arg); - -LDKCVec_u8Z TxCreationKeys_write(const LDKTxCreationKeys *obj); +void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *this_ptr, struct LDKPublicKey val); -LDKTxCreationKeys TxCreationKeys_read(LDKu8slice ser); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); -void PreCalculatedTxCreationKeys_free(LDKPreCalculatedTxCreationKeys this_ptr); +LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *obj); -LDKPreCalculatedTxCreationKeys PreCalculatedTxCreationKeys_clone(const LDKPreCalculatedTxCreationKeys *orig); +struct LDKTxCreationKeys TxCreationKeys_read(struct LDKu8slice ser); -/** - * Create a new PreCalculatedTxCreationKeys from TxCreationKeys - */ -MUST_USE_RES LDKPreCalculatedTxCreationKeys PreCalculatedTxCreationKeys_new(LDKTxCreationKeys keys); - -/** - * The pre-calculated transaction creation public keys. - * An external validating signer should not trust these keys. - */ -MUST_USE_RES LDKTxCreationKeys PreCalculatedTxCreationKeys_trust_key_derivation(const LDKPreCalculatedTxCreationKeys *this_arg); - -/** - * The transaction per-commitment point - */ -MUST_USE_RES LDKPublicKey PreCalculatedTxCreationKeys_per_commitment_point(const LDKPreCalculatedTxCreationKeys *this_arg); - -void ChannelPublicKeys_free(LDKChannelPublicKeys this_ptr); +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_ptr); -LDKChannelPublicKeys ChannelPublicKeys_clone(const LDKChannelPublicKeys *orig); +struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *orig); /** * The public key which is used to sign all commitment transactions, as it appears in the * on-chain channel lock-in 2-of-2 multisig output. */ -LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const LDKChannelPublicKeys *this_ptr); +struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *this_ptr); /** * The public key which is used to sign all commitment transactions, as it appears in the * on-chain channel lock-in 2-of-2 multisig output. */ -void ChannelPublicKeys_set_funding_pubkey(LDKChannelPublicKeys *this_ptr, LDKPublicKey val); +void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *this_ptr, struct LDKPublicKey val); /** * The base point which is used (with derive_public_revocation_key) to derive per-commitment @@ -6541,7 +6714,7 @@ void ChannelPublicKeys_set_funding_pubkey(LDKChannelPublicKeys *this_ptr, LDKPub * counterparty to create a secret which the counterparty can reveal to revoke previous * states. */ -LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const LDKChannelPublicKeys *this_ptr); +struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *this_ptr); /** * The base point which is used (with derive_public_revocation_key) to derive per-commitment @@ -6549,69 +6722,76 @@ LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const LDKChannelPublicKe * counterparty to create a secret which the counterparty can reveal to revoke previous * states. */ -void ChannelPublicKeys_set_revocation_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val); +void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *this_ptr, struct LDKPublicKey val); /** * 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); +struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *this_ptr); /** * 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); +void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *this_ptr, struct LDKPublicKey val); /** * The base point which is used (with derive_public_key) to derive a per-commitment payment * public key which receives non-HTLC-encumbered funds which are only available for spending * after some delay (or can be claimed via the revocation path). */ -LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const LDKChannelPublicKeys *this_ptr); +struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *this_ptr); /** * The base point which is used (with derive_public_key) to derive a per-commitment payment * public key which receives non-HTLC-encumbered funds which are only available for spending * after some delay (or can be claimed via the revocation path). */ -void ChannelPublicKeys_set_delayed_payment_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val); +void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *this_ptr, struct LDKPublicKey val); /** * The base point which is used (with derive_public_key) to derive a per-commitment public key * which is used to encumber HTLC-in-flight outputs. */ -LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const LDKChannelPublicKeys *this_ptr); +struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *this_ptr); /** * The base point which is used (with derive_public_key) to derive a per-commitment public key * which is used to encumber HTLC-in-flight outputs. */ -void ChannelPublicKeys_set_htlc_basepoint(LDKChannelPublicKeys *this_ptr, LDKPublicKey val); +void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *this_ptr, struct LDKPublicKey val); -MUST_USE_RES LDKChannelPublicKeys ChannelPublicKeys_new(LDKPublicKey funding_pubkey_arg, LDKPublicKey revocation_basepoint_arg, LDKPublicKey payment_point_arg, LDKPublicKey delayed_payment_basepoint_arg, LDKPublicKey htlc_basepoint_arg); +MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); -LDKCVec_u8Z ChannelPublicKeys_write(const LDKChannelPublicKeys *obj); +LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *obj); -LDKChannelPublicKeys ChannelPublicKeys_read(LDKu8slice ser); +struct LDKChannelPublicKeys ChannelPublicKeys_read(struct LDKu8slice ser); + +/** + * Create per-state keys from channel base points and the per-commitment point. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + */ +MUST_USE_RES LDKCResult_TxCreationKeysSecpErrorZ TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); /** - * Create a new TxCreationKeys from channel base points and the per-commitment point + * Generate per-state keys from channel static keys. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -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); +MUST_USE_RES LDKCResult_TxCreationKeysSecpErrorZ TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *broadcaster_keys, const struct LDKChannelPublicKeys *countersignatory_keys); /** * A script either spendable by the revocation * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -LDKCVec_u8Z get_revokeable_redeemscript(LDKPublicKey revocation_key, uint16_t contest_delay, LDKPublicKey broadcaster_delayed_payment_key); +LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); -void HTLCOutputInCommitment_free(LDKHTLCOutputInCommitment this_ptr); +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_ptr); -LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const LDKHTLCOutputInCommitment *orig); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *orig); /** * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). @@ -6619,7 +6799,7 @@ LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const LDKHTLCOutputInComm * need to compare this value to whether the commitment transaction in question is that of * the counterparty or our own. */ -bool HTLCOutputInCommitment_get_offered(const LDKHTLCOutputInCommitment *this_ptr); +bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *this_ptr); /** * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). @@ -6627,237 +6807,444 @@ bool HTLCOutputInCommitment_get_offered(const LDKHTLCOutputInCommitment *this_pt * need to compare this value to whether the commitment transaction in question is that of * the counterparty or our own. */ -void HTLCOutputInCommitment_set_offered(LDKHTLCOutputInCommitment *this_ptr, bool val); +void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *this_ptr, bool val); /** * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is * this divided by 1000. */ -uint64_t HTLCOutputInCommitment_get_amount_msat(const LDKHTLCOutputInCommitment *this_ptr); +uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *this_ptr); /** * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is * this divided by 1000. */ -void HTLCOutputInCommitment_set_amount_msat(LDKHTLCOutputInCommitment *this_ptr, uint64_t val); +void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *this_ptr, uint64_t val); /** * The CLTV lock-time at which this HTLC expires. */ -uint32_t HTLCOutputInCommitment_get_cltv_expiry(const LDKHTLCOutputInCommitment *this_ptr); +uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *this_ptr); /** * The CLTV lock-time at which this HTLC expires. */ -void HTLCOutputInCommitment_set_cltv_expiry(LDKHTLCOutputInCommitment *this_ptr, uint32_t val); +void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *this_ptr, uint32_t val); /** * The hash of the preimage which unlocks this HTLC. */ -const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const LDKHTLCOutputInCommitment *this_ptr))[32]; +const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *this_ptr))[32]; /** * The hash of the preimage which unlocks this HTLC. */ -void HTLCOutputInCommitment_set_payment_hash(LDKHTLCOutputInCommitment *this_ptr, LDKThirtyTwoBytes val); +void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *this_ptr, struct LDKThirtyTwoBytes val); -LDKCVec_u8Z HTLCOutputInCommitment_write(const LDKHTLCOutputInCommitment *obj); +LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *obj); -LDKHTLCOutputInCommitment HTLCOutputInCommitment_read(LDKu8slice ser); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_read(struct LDKu8slice ser); /** * 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); +LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *htlc, const struct LDKTxCreationKeys *keys); /** * 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 broadcaster, LDKPublicKey countersignatory); +LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** * panics if htlc.transaction_output_index.is_none()! */ -LDKTransaction 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); +struct LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); + +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_ptr); + +struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *orig); + +/** + * Holder public keys + */ +struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *this_ptr); + +/** + * Holder public keys + */ +void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *this_ptr, struct LDKChannelPublicKeys val); + +/** + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + */ +uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *this_ptr); + +/** + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + */ +void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *this_ptr, uint16_t val); + +/** + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. + */ +bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *this_ptr); + +/** + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. + */ +void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *this_ptr, bool val); + +/** + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + */ +struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *this_ptr); -void HolderCommitmentTransaction_free(LDKHolderCommitmentTransaction this_ptr); +/** + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + */ +void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *this_ptr, struct LDKCounterpartyChannelTransactionParameters val); -LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const LDKHolderCommitmentTransaction *orig); +/** + * The late-bound funding outpoint + */ +struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *this_ptr); /** - * The commitment transaction itself, in unsigned form. + * The late-bound funding outpoint */ -LDKTransaction HolderCommitmentTransaction_get_unsigned_tx(const LDKHolderCommitmentTransaction *this_ptr); +void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *this_ptr, struct LDKOutPoint val); + +MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg); + +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_ptr); + +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *orig); /** - * The commitment transaction itself, in unsigned form. + * Counter-party public keys */ -void HolderCommitmentTransaction_set_unsigned_tx(LDKHolderCommitmentTransaction *this_ptr, LDKTransaction val); +struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *this_ptr); /** - * Our counterparty's signature for the transaction, above. + * Counter-party public keys */ -LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const LDKHolderCommitmentTransaction *this_ptr); +void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *this_ptr, struct LDKChannelPublicKeys val); /** - * Our counterparty's signature for the transaction, above. + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -void HolderCommitmentTransaction_set_counterparty_sig(LDKHolderCommitmentTransaction *this_ptr, LDKSignature val); +uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *this_ptr); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. This value is - * controlled by the channel initiator. + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -uint32_t HolderCommitmentTransaction_get_feerate_per_kw(const LDKHolderCommitmentTransaction *this_ptr); +void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *this_ptr, uint16_t val); + +MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. This value is - * controlled by the channel initiator. + * Whether the late bound parameters are populated. */ -void HolderCommitmentTransaction_set_feerate_per_kw(LDKHolderCommitmentTransaction *this_ptr, uint32_t val); +MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *this_arg); /** - * The HTLCs and counterparty htlc signatures which were included in this commitment transaction. + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the holder is the broadcaster. * - * 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_holder or to_counterparty outputs. + * self.is_populated() must be true before calling this function. + */ +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *this_arg); + +/** + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the counterparty is the broadcaster. * - * 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(). + * self.is_populated() must be true before calling this function. + */ +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *this_arg); + +LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *obj); + +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); + +LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *obj); + +struct LDKChannelTransactionParameters ChannelTransactionParameters_read(struct LDKu8slice ser); + +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_ptr); + +/** + * Get the channel pubkeys for the broadcaster + */ +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *this_arg); + +/** + * Get the channel pubkeys for the countersignatory + */ +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *this_arg); + +/** + * Get the contest delay applicable to the transactions. + * Note that the contest delay was selected by the countersignatory. */ -void HolderCommitmentTransaction_set_per_htlc(LDKHolderCommitmentTransaction *this_ptr, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ val); +MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *this_arg); /** - * Generate a new HolderCommitmentTransaction based on a raw commitment transaction, - * counterparty signature and both parties keys. + * Whether the channel is outbound from the broadcaster. * - * 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. + * The boolean representing the side that initiated the channel is + * an input to the commitment number obscure factor computation. */ -MUST_USE_RES LDKHolderCommitmentTransaction HolderCommitmentTransaction_new_missing_holder_sig(LDKTransaction 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); +MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *this_arg); /** - * The pre-calculated transaction creation public keys. - * An external validating signer should not trust these keys. + * The funding outpoint + */ +MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *this_arg); + +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_ptr); + +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *orig); + +/** + * Our counterparty's signature for the transaction + */ +struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *this_ptr); + +/** + * Our counterparty's signature for the transaction + */ +void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *this_ptr, struct LDKSignature val); + +/** + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + */ +void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *this_ptr, LDKCVec_SignatureZ val); + +LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *obj); + +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_read(struct LDKu8slice ser); + +/** + * Create a new holder transaction with the given counterparty signatures. + * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. + */ +MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); + +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_ptr); + +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *orig); + +/** + * The commitment transaction + */ +struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *this_ptr); + +/** + * The commitment transaction + */ +void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *this_ptr, struct LDKTransaction val); + +/** + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. + */ +const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *this_ptr))[32]; + +/** + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. + */ +void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *this_ptr, struct LDKThirtyTwoBytes val); + +MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); + +LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *obj); + +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_read(struct LDKu8slice ser); + +/** + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. + */ +MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + +/** + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. + */ +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_ptr); + +struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *orig); + +LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *obj); + +struct LDKCommitmentTransaction CommitmentTransaction_read(struct LDKu8slice ser); + +/** + * The backwards-counting commitment number + */ +MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *this_arg); + +/** + * The value to be sent to the broadcaster + */ +MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *this_arg); + +/** + * The value to be sent to the counterparty + */ +MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *this_arg); + +/** + * The feerate paid per 1000-weight-unit in this commitment transaction. */ -MUST_USE_RES LDKTxCreationKeys HolderCommitmentTransaction_trust_key_derivation(const LDKHolderCommitmentTransaction *this_arg); +MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *this_arg); /** - * Get the txid of the holder commitment transaction contained in this - * HolderCommitmentTransaction + * Trust our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * This should only be used if you fully trust the builder of this object. It should not + *\tbe used by an external signer - instead use the verify function. */ -MUST_USE_RES LDKThirtyTwoBytes HolderCommitmentTransaction_txid(const LDKHolderCommitmentTransaction *this_arg); +MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *this_arg); /** - * Gets holder signature for the contained commitment transaction given holder funding private key. + * Verify our pre-built transaction and derived transaction creation public keys. * - * 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_holder_commitment() calls directly. - * Channel value is amount locked in funding_outpoint. + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. + */ +MUST_USE_RES LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *this_arg, const struct LDKDirectedChannelTransactionParameters *channel_parameters, const struct LDKChannelPublicKeys *broadcaster_keys, const struct LDKChannelPublicKeys *countersignatory_keys); + +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_ptr); + +/** + * The transaction ID of the built Bitcoin transaction + */ +MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *this_arg); + +/** + * The pre-built Bitcoin commitment transaction + */ +MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *this_arg); + +/** + * The pre-calculated transaction creation public keys. */ -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); +MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *this_arg); /** * Get a signature for each HTLC which was included in the commitment transaction (ie for * which HTLCOutputInCommitment::transaction_output_index.is_some()). * - * The returned Vec has one entry for each HTLC, and in the same order. For HTLCs which were - * considered dust and not included, a None entry exists, for all others a signature is - * included. + * The returned Vec has one entry for each HTLC, and in the same order. */ -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); +MUST_USE_RES LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *channel_parameters); -LDKCVec_u8Z HolderCommitmentTransaction_write(const LDKHolderCommitmentTransaction *obj); - -LDKHolderCommitmentTransaction HolderCommitmentTransaction_read(LDKu8slice ser); +/** + * Get the transaction number obscure factor + */ +uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); -void InitFeatures_free(LDKInitFeatures this_ptr); +void InitFeatures_free(struct LDKInitFeatures this_ptr); -void NodeFeatures_free(LDKNodeFeatures this_ptr); +void NodeFeatures_free(struct LDKNodeFeatures this_ptr); -void ChannelFeatures_free(LDKChannelFeatures this_ptr); +void ChannelFeatures_free(struct LDKChannelFeatures this_ptr); -void RouteHop_free(LDKRouteHop this_ptr); +void RouteHop_free(struct LDKRouteHop this_ptr); -LDKRouteHop RouteHop_clone(const LDKRouteHop *orig); +struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *orig); /** * The node_id of the node at this hop. */ -LDKPublicKey RouteHop_get_pubkey(const LDKRouteHop *this_ptr); +struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *this_ptr); /** * The node_id of the node at this hop. */ -void RouteHop_set_pubkey(LDKRouteHop *this_ptr, LDKPublicKey val); +void RouteHop_set_pubkey(struct LDKRouteHop *this_ptr, struct LDKPublicKey val); /** * The node_announcement features of the node at this hop. For the last hop, these may be * amended to match the features present in the invoice this node generated. */ -LDKNodeFeatures RouteHop_get_node_features(const LDKRouteHop *this_ptr); +struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *this_ptr); /** * The node_announcement features of the node at this hop. For the last hop, these may be * amended to match the features present in the invoice this node generated. */ -void RouteHop_set_node_features(LDKRouteHop *this_ptr, LDKNodeFeatures val); +void RouteHop_set_node_features(struct LDKRouteHop *this_ptr, struct LDKNodeFeatures val); /** * The channel that should be used from the previous hop to reach this node. */ -uint64_t RouteHop_get_short_channel_id(const LDKRouteHop *this_ptr); +uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *this_ptr); /** * The channel that should be used from the previous hop to reach this node. */ -void RouteHop_set_short_channel_id(LDKRouteHop *this_ptr, uint64_t val); +void RouteHop_set_short_channel_id(struct LDKRouteHop *this_ptr, uint64_t val); /** * The channel_announcement features of the channel that should be used from the previous hop * to reach this node. */ -LDKChannelFeatures RouteHop_get_channel_features(const LDKRouteHop *this_ptr); +struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *this_ptr); /** * The channel_announcement features of the channel that should be used from the previous hop * to reach this node. */ -void RouteHop_set_channel_features(LDKRouteHop *this_ptr, LDKChannelFeatures val); +void RouteHop_set_channel_features(struct LDKRouteHop *this_ptr, struct LDKChannelFeatures val); /** * The fee taken on this hop. For the last hop, this should be the full value of the payment. */ -uint64_t RouteHop_get_fee_msat(const LDKRouteHop *this_ptr); +uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *this_ptr); /** * The fee taken on this hop. For the last hop, this should be the full value of the payment. */ -void RouteHop_set_fee_msat(LDKRouteHop *this_ptr, uint64_t val); +void RouteHop_set_fee_msat(struct LDKRouteHop *this_ptr, uint64_t val); /** * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value * expected at the destination, in excess of the current block height. */ -uint32_t RouteHop_get_cltv_expiry_delta(const LDKRouteHop *this_ptr); +uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *this_ptr); /** * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value * expected at the destination, in excess of the current block height. */ -void RouteHop_set_cltv_expiry_delta(LDKRouteHop *this_ptr, uint32_t val); +void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *this_ptr, uint32_t val); -MUST_USE_RES LDKRouteHop RouteHop_new(LDKPublicKey pubkey_arg, LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); +MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); -void Route_free(LDKRoute this_ptr); +void Route_free(struct LDKRoute this_ptr); -LDKRoute Route_clone(const LDKRoute *orig); +struct LDKRoute Route_clone(const struct LDKRoute *orig); /** * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the @@ -6867,69 +7254,69 @@ LDKRoute Route_clone(const LDKRoute *orig); * given path is variable, keeping the length of any path to less than 20 should currently * ensure it is viable. */ -void Route_set_paths(LDKRoute *this_ptr, LDKCVec_CVec_RouteHopZZ val); +void Route_set_paths(struct LDKRoute *this_ptr, LDKCVec_CVec_RouteHopZZ val); -MUST_USE_RES LDKRoute Route_new(LDKCVec_CVec_RouteHopZZ paths_arg); +MUST_USE_RES struct LDKRoute Route_new(LDKCVec_CVec_RouteHopZZ paths_arg); -LDKCVec_u8Z Route_write(const LDKRoute *obj); +LDKCVec_u8Z Route_write(const struct LDKRoute *obj); -LDKRoute Route_read(LDKu8slice ser); +struct LDKRoute Route_read(struct LDKu8slice ser); -void RouteHint_free(LDKRouteHint this_ptr); +void RouteHint_free(struct LDKRouteHint this_ptr); -LDKRouteHint RouteHint_clone(const LDKRouteHint *orig); +struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *orig); /** * The node_id of the non-target end of the route */ -LDKPublicKey RouteHint_get_src_node_id(const LDKRouteHint *this_ptr); +struct LDKPublicKey RouteHint_get_src_node_id(const struct LDKRouteHint *this_ptr); /** * The node_id of the non-target end of the route */ -void RouteHint_set_src_node_id(LDKRouteHint *this_ptr, LDKPublicKey val); +void RouteHint_set_src_node_id(struct LDKRouteHint *this_ptr, struct LDKPublicKey val); /** * The short_channel_id of this channel */ -uint64_t RouteHint_get_short_channel_id(const LDKRouteHint *this_ptr); +uint64_t RouteHint_get_short_channel_id(const struct LDKRouteHint *this_ptr); /** * The short_channel_id of this channel */ -void RouteHint_set_short_channel_id(LDKRouteHint *this_ptr, uint64_t val); +void RouteHint_set_short_channel_id(struct LDKRouteHint *this_ptr, uint64_t val); /** * The fees which must be paid to use this channel */ -LDKRoutingFees RouteHint_get_fees(const LDKRouteHint *this_ptr); +struct LDKRoutingFees RouteHint_get_fees(const struct LDKRouteHint *this_ptr); /** * The fees which must be paid to use this channel */ -void RouteHint_set_fees(LDKRouteHint *this_ptr, LDKRoutingFees val); +void RouteHint_set_fees(struct LDKRouteHint *this_ptr, struct LDKRoutingFees val); /** * The difference in CLTV values between this node and the next node. */ -uint16_t RouteHint_get_cltv_expiry_delta(const LDKRouteHint *this_ptr); +uint16_t RouteHint_get_cltv_expiry_delta(const struct LDKRouteHint *this_ptr); /** * The difference in CLTV values between this node and the next node. */ -void RouteHint_set_cltv_expiry_delta(LDKRouteHint *this_ptr, uint16_t val); +void RouteHint_set_cltv_expiry_delta(struct LDKRouteHint *this_ptr, uint16_t val); /** * The minimum value, in msat, which must be relayed to the next hop. */ -uint64_t RouteHint_get_htlc_minimum_msat(const LDKRouteHint *this_ptr); +uint64_t RouteHint_get_htlc_minimum_msat(const struct LDKRouteHint *this_ptr); /** * The minimum value, in msat, which must be relayed to the next hop. */ -void RouteHint_set_htlc_minimum_msat(LDKRouteHint *this_ptr, uint64_t val); +void RouteHint_set_htlc_minimum_msat(struct LDKRouteHint *this_ptr, uint64_t val); -MUST_USE_RES LDKRouteHint RouteHint_new(LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg); +MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg); /** * Gets a route from us to the given target node. @@ -6949,13 +7336,13 @@ MUST_USE_RES LDKRouteHint RouteHint_new(LDKPublicKey src_node_id_arg, uint64_t s * equal), however the enabled/disabled bit on such channels as well as the htlc_minimum_msat * *is* checked as they may change based on the receiving node. */ -LDKCResult_RouteLightningErrorZ get_route(LDKPublicKey our_node_id, const LDKNetworkGraph *network, LDKPublicKey target, LDKCVec_ChannelDetailsZ *first_hops, LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, LDKLogger logger); +LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *network, struct LDKPublicKey target, LDKCVec_ChannelDetailsZ *first_hops, LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); -void NetworkGraph_free(LDKNetworkGraph this_ptr); +void NetworkGraph_free(struct LDKNetworkGraph this_ptr); -void LockedNetworkGraph_free(LDKLockedNetworkGraph this_ptr); +void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_ptr); -void NetGraphMsgHandler_free(LDKNetGraphMsgHandler this_ptr); +void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_ptr); /** * Creates a new tracker of the actual state of the network of channels and nodes, @@ -6964,13 +7351,13 @@ void NetGraphMsgHandler_free(LDKNetGraphMsgHandler this_ptr); * channel data is correct, and that the announcement is signed with * channel owners' keys. */ -MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_new(LDKAccess *chain_access, LDKLogger logger); +MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger); /** * Creates a new tracker of the actual state of the network of channels and nodes, * assuming an existing Network Graph. */ -MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(LDKAccess *chain_access, LDKLogger logger, LDKNetworkGraph network_graph); +MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph); /** * Take a read lock on the network_graph and return it in the C-bindings @@ -6978,58 +7365,70 @@ MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(LDKAccess * * bindings as you can call `self.network_graph.read().unwrap()` in Rust * yourself. */ -MUST_USE_RES LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const LDKNetGraphMsgHandler *this_arg); +MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const struct LDKNetGraphMsgHandler *this_arg); /** * Get a reference to the NetworkGraph which this read-lock contains. */ -MUST_USE_RES LDKNetworkGraph LockedNetworkGraph_graph(const LDKLockedNetworkGraph *this_arg); +MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *this_arg); + +struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const struct LDKNetGraphMsgHandler *this_arg); -LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(const LDKNetGraphMsgHandler *this_arg); +struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *this_arg); -void DirectionalChannelInfo_free(LDKDirectionalChannelInfo this_ptr); +void DirectionalChannelInfo_free(struct LDKDirectionalChannelInfo this_ptr); /** * When the last update to the channel direction was issued. * Value is opaque, as set in the announcement. */ -uint32_t DirectionalChannelInfo_get_last_update(const LDKDirectionalChannelInfo *this_ptr); +uint32_t DirectionalChannelInfo_get_last_update(const struct LDKDirectionalChannelInfo *this_ptr); /** * When the last update to the channel direction was issued. * Value is opaque, as set in the announcement. */ -void DirectionalChannelInfo_set_last_update(LDKDirectionalChannelInfo *this_ptr, uint32_t val); +void DirectionalChannelInfo_set_last_update(struct LDKDirectionalChannelInfo *this_ptr, uint32_t val); /** * Whether the channel can be currently used for payments (in this one direction). */ -bool DirectionalChannelInfo_get_enabled(const LDKDirectionalChannelInfo *this_ptr); +bool DirectionalChannelInfo_get_enabled(const struct LDKDirectionalChannelInfo *this_ptr); /** * Whether the channel can be currently used for payments (in this one direction). */ -void DirectionalChannelInfo_set_enabled(LDKDirectionalChannelInfo *this_ptr, bool val); +void DirectionalChannelInfo_set_enabled(struct LDKDirectionalChannelInfo *this_ptr, bool val); /** * The difference in CLTV values that you must have when routing through this channel. */ -uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const LDKDirectionalChannelInfo *this_ptr); +uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const struct LDKDirectionalChannelInfo *this_ptr); /** * The difference in CLTV values that you must have when routing through this channel. */ -void DirectionalChannelInfo_set_cltv_expiry_delta(LDKDirectionalChannelInfo *this_ptr, uint16_t val); +void DirectionalChannelInfo_set_cltv_expiry_delta(struct LDKDirectionalChannelInfo *this_ptr, uint16_t val); /** * The minimum value, which must be relayed to the next hop via the channel */ -uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const LDKDirectionalChannelInfo *this_ptr); +uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const struct LDKDirectionalChannelInfo *this_ptr); /** * The minimum value, which must be relayed to the next hop via the channel */ -void DirectionalChannelInfo_set_htlc_minimum_msat(LDKDirectionalChannelInfo *this_ptr, uint64_t val); +void DirectionalChannelInfo_set_htlc_minimum_msat(struct LDKDirectionalChannelInfo *this_ptr, uint64_t val); + +/** + * Fees charged when the channel is used for routing + */ +struct LDKRoutingFees DirectionalChannelInfo_get_fees(const struct LDKDirectionalChannelInfo *this_ptr); + +/** + * Fees charged when the channel is used for routing + */ +void DirectionalChannelInfo_set_fees(struct LDKDirectionalChannelInfo *this_ptr, struct LDKRoutingFees val); /** * Most recent update for the channel received from the network @@ -7037,7 +7436,7 @@ void DirectionalChannelInfo_set_htlc_minimum_msat(LDKDirectionalChannelInfo *thi * Everything else is useful only for sending out for initial routing sync. * Not stored if contains excess data to prevent DoS. */ -LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const LDKDirectionalChannelInfo *this_ptr); +struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const struct LDKDirectionalChannelInfo *this_ptr); /** * Most recent update for the channel received from the network @@ -7045,63 +7444,63 @@ LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const LDKDirecti * Everything else is useful only for sending out for initial routing sync. * Not stored if contains excess data to prevent DoS. */ -void DirectionalChannelInfo_set_last_update_message(LDKDirectionalChannelInfo *this_ptr, LDKChannelUpdate val); +void DirectionalChannelInfo_set_last_update_message(struct LDKDirectionalChannelInfo *this_ptr, struct LDKChannelUpdate val); -LDKCVec_u8Z DirectionalChannelInfo_write(const LDKDirectionalChannelInfo *obj); +LDKCVec_u8Z DirectionalChannelInfo_write(const struct LDKDirectionalChannelInfo *obj); -LDKDirectionalChannelInfo DirectionalChannelInfo_read(LDKu8slice ser); +struct LDKDirectionalChannelInfo DirectionalChannelInfo_read(struct LDKu8slice ser); -void ChannelInfo_free(LDKChannelInfo this_ptr); +void ChannelInfo_free(struct LDKChannelInfo this_ptr); /** * Protocol features of a channel communicated during its announcement */ -LDKChannelFeatures ChannelInfo_get_features(const LDKChannelInfo *this_ptr); +struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *this_ptr); /** * Protocol features of a channel communicated during its announcement */ -void ChannelInfo_set_features(LDKChannelInfo *this_ptr, LDKChannelFeatures val); +void ChannelInfo_set_features(struct LDKChannelInfo *this_ptr, struct LDKChannelFeatures val); /** * Source node of the first direction of a channel */ -LDKPublicKey ChannelInfo_get_node_one(const LDKChannelInfo *this_ptr); +struct LDKPublicKey ChannelInfo_get_node_one(const struct LDKChannelInfo *this_ptr); /** * Source node of the first direction of a channel */ -void ChannelInfo_set_node_one(LDKChannelInfo *this_ptr, LDKPublicKey val); +void ChannelInfo_set_node_one(struct LDKChannelInfo *this_ptr, struct LDKPublicKey val); /** * Details about the first direction of a channel */ -LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const LDKChannelInfo *this_ptr); +struct LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *this_ptr); /** * Details about the first direction of a channel */ -void ChannelInfo_set_one_to_two(LDKChannelInfo *this_ptr, LDKDirectionalChannelInfo val); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *this_ptr, struct LDKDirectionalChannelInfo val); /** * Source node of the second direction of a channel */ -LDKPublicKey ChannelInfo_get_node_two(const LDKChannelInfo *this_ptr); +struct LDKPublicKey ChannelInfo_get_node_two(const struct LDKChannelInfo *this_ptr); /** * Source node of the second direction of a channel */ -void ChannelInfo_set_node_two(LDKChannelInfo *this_ptr, LDKPublicKey val); +void ChannelInfo_set_node_two(struct LDKChannelInfo *this_ptr, struct LDKPublicKey val); /** * Details about the second direction of a channel */ -LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const LDKChannelInfo *this_ptr); +struct LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *this_ptr); /** * Details about the second direction of a channel */ -void ChannelInfo_set_two_to_one(LDKChannelInfo *this_ptr, LDKDirectionalChannelInfo val); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *this_ptr, struct LDKDirectionalChannelInfo val); /** * An initial announcement of the channel @@ -7109,7 +7508,7 @@ void ChannelInfo_set_two_to_one(LDKChannelInfo *this_ptr, LDKDirectionalChannelI * Everything else is useful only for sending out for initial routing sync. * Not stored if contains excess data to prevent DoS. */ -LDKChannelAnnouncement ChannelInfo_get_announcement_message(const LDKChannelInfo *this_ptr); +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *this_ptr); /** * An initial announcement of the channel @@ -7117,96 +7516,96 @@ LDKChannelAnnouncement ChannelInfo_get_announcement_message(const LDKChannelInfo * Everything else is useful only for sending out for initial routing sync. * Not stored if contains excess data to prevent DoS. */ -void ChannelInfo_set_announcement_message(LDKChannelInfo *this_ptr, LDKChannelAnnouncement val); +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *this_ptr, struct LDKChannelAnnouncement val); -LDKCVec_u8Z ChannelInfo_write(const LDKChannelInfo *obj); +LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *obj); -LDKChannelInfo ChannelInfo_read(LDKu8slice ser); +struct LDKChannelInfo ChannelInfo_read(struct LDKu8slice ser); -void RoutingFees_free(LDKRoutingFees this_ptr); +void RoutingFees_free(struct LDKRoutingFees this_ptr); -LDKRoutingFees RoutingFees_clone(const LDKRoutingFees *orig); +struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *orig); /** * Flat routing fee in satoshis */ -uint32_t RoutingFees_get_base_msat(const LDKRoutingFees *this_ptr); +uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *this_ptr); /** * Flat routing fee in satoshis */ -void RoutingFees_set_base_msat(LDKRoutingFees *this_ptr, uint32_t val); +void RoutingFees_set_base_msat(struct LDKRoutingFees *this_ptr, uint32_t val); /** * Liquidity-based routing fee in millionths of a routed amount. * In other words, 10000 is 1%. */ -uint32_t RoutingFees_get_proportional_millionths(const LDKRoutingFees *this_ptr); +uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *this_ptr); /** * Liquidity-based routing fee in millionths of a routed amount. * In other words, 10000 is 1%. */ -void RoutingFees_set_proportional_millionths(LDKRoutingFees *this_ptr, uint32_t val); +void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *this_ptr, uint32_t val); -MUST_USE_RES LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); -LDKRoutingFees RoutingFees_read(LDKu8slice ser); +struct LDKRoutingFees RoutingFees_read(struct LDKu8slice ser); -LDKCVec_u8Z RoutingFees_write(const LDKRoutingFees *obj); +LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *obj); -void NodeAnnouncementInfo_free(LDKNodeAnnouncementInfo this_ptr); +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_ptr); /** * Protocol features the node announced support for */ -LDKNodeFeatures NodeAnnouncementInfo_get_features(const LDKNodeAnnouncementInfo *this_ptr); +struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *this_ptr); /** * Protocol features the node announced support for */ -void NodeAnnouncementInfo_set_features(LDKNodeAnnouncementInfo *this_ptr, LDKNodeFeatures val); +void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *this_ptr, struct LDKNodeFeatures val); /** * When the last known update to the node state was issued. * Value is opaque, as set in the announcement. */ -uint32_t NodeAnnouncementInfo_get_last_update(const LDKNodeAnnouncementInfo *this_ptr); +uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *this_ptr); /** * When the last known update to the node state was issued. * Value is opaque, as set in the announcement. */ -void NodeAnnouncementInfo_set_last_update(LDKNodeAnnouncementInfo *this_ptr, uint32_t val); +void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *this_ptr, uint32_t val); /** * Color assigned to the node */ -const uint8_t (*NodeAnnouncementInfo_get_rgb(const LDKNodeAnnouncementInfo *this_ptr))[3]; +const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *this_ptr))[3]; /** * Color assigned to the node */ -void NodeAnnouncementInfo_set_rgb(LDKNodeAnnouncementInfo *this_ptr, LDKThreeBytes val); +void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *this_ptr, struct LDKThreeBytes val); /** * Moniker assigned to the node. * May be invalid or malicious (eg control chars), * should not be exposed to the user. */ -const uint8_t (*NodeAnnouncementInfo_get_alias(const LDKNodeAnnouncementInfo *this_ptr))[32]; +const uint8_t (*NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *this_ptr))[32]; /** * Moniker assigned to the node. * May be invalid or malicious (eg control chars), * should not be exposed to the user. */ -void NodeAnnouncementInfo_set_alias(LDKNodeAnnouncementInfo *this_ptr, LDKThirtyTwoBytes val); +void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *this_ptr, struct LDKThirtyTwoBytes val); /** * Internet-level addresses via which one can connect to the node */ -void NodeAnnouncementInfo_set_addresses(LDKNodeAnnouncementInfo *this_ptr, LDKCVec_NetAddressZ val); +void NodeAnnouncementInfo_set_addresses(struct LDKNodeAnnouncementInfo *this_ptr, LDKCVec_NetAddressZ val); /** * An initial announcement of the node @@ -7214,7 +7613,7 @@ void NodeAnnouncementInfo_set_addresses(LDKNodeAnnouncementInfo *this_ptr, LDKCV * Everything else is useful only for sending out for initial routing sync. * Not stored if contains excess data to prevent DoS. */ -LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const LDKNodeAnnouncementInfo *this_ptr); +struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *this_ptr); /** * An initial announcement of the node @@ -7222,63 +7621,63 @@ LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const LDKNodeA * Everything else is useful only for sending out for initial routing sync. * Not stored if contains excess data to prevent DoS. */ -void NodeAnnouncementInfo_set_announcement_message(LDKNodeAnnouncementInfo *this_ptr, LDKNodeAnnouncement val); +void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *this_ptr, struct LDKNodeAnnouncement val); -MUST_USE_RES LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(LDKNodeFeatures features_arg, uint32_t last_update_arg, LDKThreeBytes rgb_arg, LDKThirtyTwoBytes alias_arg, LDKCVec_NetAddressZ addresses_arg, LDKNodeAnnouncement announcement_message_arg); +MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKThirtyTwoBytes alias_arg, LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); -LDKCVec_u8Z NodeAnnouncementInfo_write(const LDKNodeAnnouncementInfo *obj); +LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *obj); -LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(LDKu8slice ser); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(struct LDKu8slice ser); -void NodeInfo_free(LDKNodeInfo this_ptr); +void NodeInfo_free(struct LDKNodeInfo this_ptr); /** * All valid channels a node has announced */ -void NodeInfo_set_channels(LDKNodeInfo *this_ptr, LDKCVec_u64Z val); +void NodeInfo_set_channels(struct LDKNodeInfo *this_ptr, LDKCVec_u64Z val); /** * Lowest fees enabling routing via any of the enabled, known channels to a node. * The two fields (flat and proportional fee) are independent, * meaning they don't have to refer to the same channel. */ -LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const LDKNodeInfo *this_ptr); +struct LDKRoutingFees NodeInfo_get_lowest_inbound_channel_fees(const struct LDKNodeInfo *this_ptr); /** * Lowest fees enabling routing via any of the enabled, known channels to a node. * The two fields (flat and proportional fee) are independent, * meaning they don't have to refer to the same channel. */ -void NodeInfo_set_lowest_inbound_channel_fees(LDKNodeInfo *this_ptr, LDKRoutingFees val); +void NodeInfo_set_lowest_inbound_channel_fees(struct LDKNodeInfo *this_ptr, struct LDKRoutingFees val); /** * More information about a node from node_announcement. * Optional because we store a Node entry after learning about it from * a channel announcement, but before receiving a node announcement. */ -LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const LDKNodeInfo *this_ptr); +struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *this_ptr); /** * More information about a node from node_announcement. * Optional because we store a Node entry after learning about it from * a channel announcement, but before receiving a node announcement. */ -void NodeInfo_set_announcement_info(LDKNodeInfo *this_ptr, LDKNodeAnnouncementInfo val); +void NodeInfo_set_announcement_info(struct LDKNodeInfo *this_ptr, struct LDKNodeAnnouncementInfo val); -MUST_USE_RES LDKNodeInfo NodeInfo_new(LDKCVec_u64Z channels_arg, LDKRoutingFees lowest_inbound_channel_fees_arg, LDKNodeAnnouncementInfo announcement_info_arg); +MUST_USE_RES struct LDKNodeInfo NodeInfo_new(LDKCVec_u64Z channels_arg, struct LDKRoutingFees lowest_inbound_channel_fees_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); -LDKCVec_u8Z NodeInfo_write(const LDKNodeInfo *obj); +LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *obj); -LDKNodeInfo NodeInfo_read(LDKu8slice ser); +struct LDKNodeInfo NodeInfo_read(struct LDKu8slice ser); -LDKCVec_u8Z NetworkGraph_write(const LDKNetworkGraph *obj); +LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *obj); -LDKNetworkGraph NetworkGraph_read(LDKu8slice ser); +struct LDKNetworkGraph NetworkGraph_read(struct LDKu8slice ser); /** * Creates a new, empty, network graph. */ -MUST_USE_RES LDKNetworkGraph NetworkGraph_new(void); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash); /** * For an already known node (from channel announcements), update its stored properties from a @@ -7288,7 +7687,7 @@ MUST_USE_RES LDKNetworkGraph NetworkGraph_new(void); * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept * routing messages from a source using a protocol other than the lightning P2P protocol. */ -MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(LDKNetworkGraph *this_arg, const LDKNodeAnnouncement *msg); +MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(struct LDKNetworkGraph *this_arg, const struct LDKNodeAnnouncement *msg); /** * For an already known node (from channel announcements), update its stored properties from a @@ -7296,7 +7695,7 @@ MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announ * given the associated signatures here we cannot relay the node announcement to any of our * peers. */ -MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(LDKNetworkGraph *this_arg, const LDKUnsignedNodeAnnouncement *msg); +MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(struct LDKNetworkGraph *this_arg, const struct LDKUnsignedNodeAnnouncement *msg); /** * Store or update channel info from a channel announcement. @@ -7308,7 +7707,7 @@ MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsign * If a `chain::Access` object is provided via `chain_access`, it will be called to verify * the corresponding UTXO exists on chain and is correctly-formatted. */ -MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(LDKNetworkGraph *this_arg, const LDKChannelAnnouncement *msg, LDKAccess *chain_access); +MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *this_arg, const struct LDKChannelAnnouncement *msg, struct LDKAccess *chain_access); /** * Store or update channel info from a channel announcement without verifying the associated @@ -7318,7 +7717,7 @@ MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_ann * If a `chain::Access` object is provided via `chain_access`, it will be called to verify * the corresponding UTXO exists on chain and is correctly-formatted. */ -MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(LDKNetworkGraph *this_arg, const LDKUnsignedChannelAnnouncement *msg, LDKAccess *chain_access); +MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *this_arg, const struct LDKUnsignedChannelAnnouncement *msg, struct LDKAccess *chain_access); /** * Close a channel if a corresponding HTLC fail was sent. @@ -7326,7 +7725,7 @@ MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_uns * May cause the removal of nodes too, if this was their last channel. * If not permanent, makes channels unavailable for routing. */ -void NetworkGraph_close_channel_from_update(LDKNetworkGraph *this_arg, uint64_t short_channel_id, bool is_permanent); +void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *this_arg, uint64_t short_channel_id, bool is_permanent); /** * For an already known (from announcement) channel, update info about one of the directions @@ -7336,13 +7735,13 @@ void NetworkGraph_close_channel_from_update(LDKNetworkGraph *this_arg, uint64_t * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept * routing messages from a source using a protocol other than the lightning P2P protocol. */ -MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(LDKNetworkGraph *this_arg, const LDKChannelUpdate *msg); +MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(struct LDKNetworkGraph *this_arg, const struct LDKChannelUpdate *msg); /** * For an already known (from announcement) channel, update info about one of the directions * of the channel without verifying the associated signatures. Because we aren't given the * associated signatures here we cannot relay the channel update to any of our peers. */ -MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(LDKNetworkGraph *this_arg, const LDKUnsignedChannelUpdate *msg); +MUST_USE_RES LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(struct LDKNetworkGraph *this_arg, const struct LDKUnsignedChannelUpdate *msg); /* Text to put at the end of the generated file */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 5f8b77f3f..b313d1fd3 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -1130,20 +1130,6 @@ public: const LDKTxCreationKeys* operator &() const { return &self; } const LDKTxCreationKeys* operator ->() const { return &self; } }; -class PreCalculatedTxCreationKeys { -private: - LDKPreCalculatedTxCreationKeys self; -public: - PreCalculatedTxCreationKeys(const PreCalculatedTxCreationKeys&) = delete; - ~PreCalculatedTxCreationKeys() { PreCalculatedTxCreationKeys_free(self); } - PreCalculatedTxCreationKeys(PreCalculatedTxCreationKeys&& o) : self(o.self) { memset(&o, 0, sizeof(PreCalculatedTxCreationKeys)); } - PreCalculatedTxCreationKeys(LDKPreCalculatedTxCreationKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPreCalculatedTxCreationKeys)); } - operator LDKPreCalculatedTxCreationKeys() { LDKPreCalculatedTxCreationKeys res = self; memset(&self, 0, sizeof(LDKPreCalculatedTxCreationKeys)); return res; } - LDKPreCalculatedTxCreationKeys* operator &() { return &self; } - LDKPreCalculatedTxCreationKeys* operator ->() { return &self; } - const LDKPreCalculatedTxCreationKeys* operator &() const { return &self; } - const LDKPreCalculatedTxCreationKeys* operator ->() const { return &self; } -}; class ChannelPublicKeys { private: LDKChannelPublicKeys self; @@ -1172,6 +1158,48 @@ public: const LDKHTLCOutputInCommitment* operator &() const { return &self; } const LDKHTLCOutputInCommitment* operator ->() const { return &self; } }; +class ChannelTransactionParameters { +private: + LDKChannelTransactionParameters self; +public: + ChannelTransactionParameters(const ChannelTransactionParameters&) = delete; + ~ChannelTransactionParameters() { ChannelTransactionParameters_free(self); } + ChannelTransactionParameters(ChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTransactionParameters)); } + ChannelTransactionParameters(LDKChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTransactionParameters)); } + operator LDKChannelTransactionParameters() { LDKChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKChannelTransactionParameters)); return res; } + LDKChannelTransactionParameters* operator &() { return &self; } + LDKChannelTransactionParameters* operator ->() { return &self; } + const LDKChannelTransactionParameters* operator &() const { return &self; } + const LDKChannelTransactionParameters* operator ->() const { return &self; } +}; +class CounterpartyChannelTransactionParameters { +private: + LDKCounterpartyChannelTransactionParameters self; +public: + CounterpartyChannelTransactionParameters(const CounterpartyChannelTransactionParameters&) = delete; + ~CounterpartyChannelTransactionParameters() { CounterpartyChannelTransactionParameters_free(self); } + CounterpartyChannelTransactionParameters(CounterpartyChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyChannelTransactionParameters)); } + CounterpartyChannelTransactionParameters(LDKCounterpartyChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyChannelTransactionParameters)); } + operator LDKCounterpartyChannelTransactionParameters() { LDKCounterpartyChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKCounterpartyChannelTransactionParameters)); return res; } + LDKCounterpartyChannelTransactionParameters* operator &() { return &self; } + LDKCounterpartyChannelTransactionParameters* operator ->() { return &self; } + const LDKCounterpartyChannelTransactionParameters* operator &() const { return &self; } + const LDKCounterpartyChannelTransactionParameters* operator ->() const { return &self; } +}; +class DirectedChannelTransactionParameters { +private: + LDKDirectedChannelTransactionParameters self; +public: + DirectedChannelTransactionParameters(const DirectedChannelTransactionParameters&) = delete; + ~DirectedChannelTransactionParameters() { DirectedChannelTransactionParameters_free(self); } + DirectedChannelTransactionParameters(DirectedChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(DirectedChannelTransactionParameters)); } + DirectedChannelTransactionParameters(LDKDirectedChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirectedChannelTransactionParameters)); } + operator LDKDirectedChannelTransactionParameters() { LDKDirectedChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKDirectedChannelTransactionParameters)); return res; } + LDKDirectedChannelTransactionParameters* operator &() { return &self; } + LDKDirectedChannelTransactionParameters* operator ->() { return &self; } + const LDKDirectedChannelTransactionParameters* operator &() const { return &self; } + const LDKDirectedChannelTransactionParameters* operator ->() const { return &self; } +}; class HolderCommitmentTransaction { private: LDKHolderCommitmentTransaction self; @@ -1186,6 +1214,48 @@ public: const LDKHolderCommitmentTransaction* operator &() const { return &self; } const LDKHolderCommitmentTransaction* operator ->() const { return &self; } }; +class BuiltCommitmentTransaction { +private: + LDKBuiltCommitmentTransaction self; +public: + BuiltCommitmentTransaction(const BuiltCommitmentTransaction&) = delete; + ~BuiltCommitmentTransaction() { BuiltCommitmentTransaction_free(self); } + BuiltCommitmentTransaction(BuiltCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(BuiltCommitmentTransaction)); } + BuiltCommitmentTransaction(LDKBuiltCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBuiltCommitmentTransaction)); } + operator LDKBuiltCommitmentTransaction() { LDKBuiltCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKBuiltCommitmentTransaction)); return res; } + LDKBuiltCommitmentTransaction* operator &() { return &self; } + LDKBuiltCommitmentTransaction* operator ->() { return &self; } + const LDKBuiltCommitmentTransaction* operator &() const { return &self; } + const LDKBuiltCommitmentTransaction* operator ->() const { return &self; } +}; +class CommitmentTransaction { +private: + LDKCommitmentTransaction self; +public: + CommitmentTransaction(const CommitmentTransaction&) = delete; + ~CommitmentTransaction() { CommitmentTransaction_free(self); } + CommitmentTransaction(CommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentTransaction)); } + CommitmentTransaction(LDKCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentTransaction)); } + operator LDKCommitmentTransaction() { LDKCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKCommitmentTransaction)); return res; } + LDKCommitmentTransaction* operator &() { return &self; } + LDKCommitmentTransaction* operator ->() { return &self; } + const LDKCommitmentTransaction* operator &() const { return &self; } + const LDKCommitmentTransaction* operator ->() const { return &self; } +}; +class TrustedCommitmentTransaction { +private: + LDKTrustedCommitmentTransaction self; +public: + TrustedCommitmentTransaction(const TrustedCommitmentTransaction&) = delete; + ~TrustedCommitmentTransaction() { TrustedCommitmentTransaction_free(self); } + TrustedCommitmentTransaction(TrustedCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(TrustedCommitmentTransaction)); } + TrustedCommitmentTransaction(LDKTrustedCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrustedCommitmentTransaction)); } + operator LDKTrustedCommitmentTransaction() { LDKTrustedCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKTrustedCommitmentTransaction)); return res; } + LDKTrustedCommitmentTransaction* operator &() { return &self; } + LDKTrustedCommitmentTransaction* operator ->() { return &self; } + const LDKTrustedCommitmentTransaction* operator &() const { return &self; } + const LDKTrustedCommitmentTransaction* operator ->() const { return &self; } +}; class InitFeatures { private: LDKInitFeatures self; @@ -1424,20 +1494,6 @@ public: const LDKC2Tuple_u32TxOutZ* operator &() const { return &self; } const LDKC2Tuple_u32TxOutZ* operator ->() const { return &self; } }; -class CResult_NoneMonitorUpdateErrorZ { -private: - LDKCResult_NoneMonitorUpdateErrorZ self; -public: - CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete; - ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); } - CResult_NoneMonitorUpdateErrorZ(CResult_NoneMonitorUpdateErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); } - CResult_NoneMonitorUpdateErrorZ(LDKCResult_NoneMonitorUpdateErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); } - operator LDKCResult_NoneMonitorUpdateErrorZ() { LDKCResult_NoneMonitorUpdateErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); return res; } - LDKCResult_NoneMonitorUpdateErrorZ* operator &() { return &self; } - LDKCResult_NoneMonitorUpdateErrorZ* operator ->() { return &self; } - const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; } - const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; } -}; class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { private: LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self; @@ -1564,20 +1620,6 @@ public: const LDKCResult_SecretKeySecpErrorZ* operator &() const { return &self; } const LDKCResult_SecretKeySecpErrorZ* operator ->() const { return &self; } }; -class C2Tuple_HTLCOutputInCommitmentSignatureZ { -private: - LDKC2Tuple_HTLCOutputInCommitmentSignatureZ 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; } -}; class CVec_EventZ { private: LDKCVec_EventZ self; @@ -1620,6 +1662,20 @@ public: const LDKCVec_MonitorEventZ* operator &() const { return &self; } const LDKCVec_MonitorEventZ* operator ->() const { return &self; } }; +class CResult_ChanKeySignerDecodeErrorZ { +private: + LDKCResult_ChanKeySignerDecodeErrorZ self; +public: + CResult_ChanKeySignerDecodeErrorZ(const CResult_ChanKeySignerDecodeErrorZ&) = delete; + ~CResult_ChanKeySignerDecodeErrorZ() { CResult_ChanKeySignerDecodeErrorZ_free(self); } + CResult_ChanKeySignerDecodeErrorZ(CResult_ChanKeySignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChanKeySignerDecodeErrorZ)); } + CResult_ChanKeySignerDecodeErrorZ(LDKCResult_ChanKeySignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChanKeySignerDecodeErrorZ)); } + operator LDKCResult_ChanKeySignerDecodeErrorZ() { LDKCResult_ChanKeySignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChanKeySignerDecodeErrorZ)); return res; } + LDKCResult_ChanKeySignerDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChanKeySignerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChanKeySignerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChanKeySignerDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_RouteHopZ { private: LDKCVec_RouteHopZ self; @@ -1718,19 +1774,19 @@ public: const LDKCResult_PublicKeySecpErrorZ* operator &() const { return &self; } const LDKCResult_PublicKeySecpErrorZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ { +class CVec_RouteHintZ { private: - LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ self; + LDKCVec_RouteHintZ 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; } + 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 C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { private: @@ -1774,6 +1830,20 @@ public: const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; } const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; } }; +class CResult_NoneLightningErrorZ { +private: + LDKCResult_NoneLightningErrorZ self; +public: + CResult_NoneLightningErrorZ(const CResult_NoneLightningErrorZ&) = delete; + ~CResult_NoneLightningErrorZ() { CResult_NoneLightningErrorZ_free(self); } + CResult_NoneLightningErrorZ(CResult_NoneLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); } + CResult_NoneLightningErrorZ(LDKCResult_NoneLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); } + operator LDKCResult_NoneLightningErrorZ() { LDKCResult_NoneLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); return res; } + LDKCResult_NoneLightningErrorZ* operator &() { return &self; } + LDKCResult_NoneLightningErrorZ* operator ->() { return &self; } + const LDKCResult_NoneLightningErrorZ* operator &() const { return &self; } + const LDKCResult_NoneLightningErrorZ* operator ->() const { return &self; } +}; class CResult_NonePeerHandleErrorZ { private: LDKCResult_NonePeerHandleErrorZ self; @@ -1802,19 +1872,19 @@ public: const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } }; -class CVec_RouteHintZ { +class CResult_TrustedCommitmentTransactionNoneZ { private: - LDKCVec_RouteHintZ self; + LDKCResult_TrustedCommitmentTransactionNoneZ 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; } + CResult_TrustedCommitmentTransactionNoneZ(const CResult_TrustedCommitmentTransactionNoneZ&) = delete; + ~CResult_TrustedCommitmentTransactionNoneZ() { CResult_TrustedCommitmentTransactionNoneZ_free(self); } + CResult_TrustedCommitmentTransactionNoneZ(CResult_TrustedCommitmentTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); } + CResult_TrustedCommitmentTransactionNoneZ(LDKCResult_TrustedCommitmentTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); } + operator LDKCResult_TrustedCommitmentTransactionNoneZ() { LDKCResult_TrustedCommitmentTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); return res; } + LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() { return &self; } + LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() { return &self; } + const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } + const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } }; class CResult_RouteLightningErrorZ { private: @@ -1830,20 +1900,6 @@ public: const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } }; -class CResult_NoneLightningErrorZ { -private: - LDKCResult_NoneLightningErrorZ self; -public: - CResult_NoneLightningErrorZ(const CResult_NoneLightningErrorZ&) = delete; - ~CResult_NoneLightningErrorZ() { CResult_NoneLightningErrorZ_free(self); } - CResult_NoneLightningErrorZ(CResult_NoneLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); } - CResult_NoneLightningErrorZ(LDKCResult_NoneLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); } - operator LDKCResult_NoneLightningErrorZ() { LDKCResult_NoneLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); return res; } - LDKCResult_NoneLightningErrorZ* operator &() { return &self; } - LDKCResult_NoneLightningErrorZ* operator ->() { return &self; } - const LDKCResult_NoneLightningErrorZ* operator &() const { return &self; } - const LDKCResult_NoneLightningErrorZ* operator ->() const { return &self; } -}; class CResult_CVec_SignatureZNoneZ { private: LDKCResult_CVec_SignatureZNoneZ self; @@ -2082,18 +2138,18 @@ public: const LDKC2Tuple_u64u64Z* operator &() const { return &self; } const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } }; -class CVec_HTLCOutputInCommitmentZ { +class CResult_NoneMonitorUpdateErrorZ { private: - LDKCVec_HTLCOutputInCommitmentZ self; + LDKCResult_NoneMonitorUpdateErrorZ 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; } + CResult_NoneMonitorUpdateErrorZ(const CResult_NoneMonitorUpdateErrorZ&) = delete; + ~CResult_NoneMonitorUpdateErrorZ() { CResult_NoneMonitorUpdateErrorZ_free(self); } + CResult_NoneMonitorUpdateErrorZ(CResult_NoneMonitorUpdateErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneMonitorUpdateErrorZ)); } + CResult_NoneMonitorUpdateErrorZ(LDKCResult_NoneMonitorUpdateErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); } + operator LDKCResult_NoneMonitorUpdateErrorZ() { LDKCResult_NoneMonitorUpdateErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneMonitorUpdateErrorZ)); return res; } + LDKCResult_NoneMonitorUpdateErrorZ* operator &() { return &self; } + LDKCResult_NoneMonitorUpdateErrorZ* operator ->() { return &self; } + const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; } + const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; } }; } diff --git a/lightning-c-bindings/include/rust_types.h b/lightning-c-bindings/include/rust_types.h index 2e15b2a2b..2514c93e4 100644 --- a/lightning-c-bindings/include/rust_types.h +++ b/lightning-c-bindings/include/rust_types.h @@ -123,14 +123,24 @@ struct nativePeerManagerOpaque; typedef struct nativePeerManagerOpaque LDKnativePeerManager; struct nativeTxCreationKeysOpaque; typedef struct nativeTxCreationKeysOpaque LDKnativeTxCreationKeys; -struct nativePreCalculatedTxCreationKeysOpaque; -typedef struct nativePreCalculatedTxCreationKeysOpaque LDKnativePreCalculatedTxCreationKeys; struct nativeChannelPublicKeysOpaque; typedef struct nativeChannelPublicKeysOpaque LDKnativeChannelPublicKeys; struct nativeHTLCOutputInCommitmentOpaque; typedef struct nativeHTLCOutputInCommitmentOpaque LDKnativeHTLCOutputInCommitment; +struct nativeChannelTransactionParametersOpaque; +typedef struct nativeChannelTransactionParametersOpaque LDKnativeChannelTransactionParameters; +struct nativeCounterpartyChannelTransactionParametersOpaque; +typedef struct nativeCounterpartyChannelTransactionParametersOpaque LDKnativeCounterpartyChannelTransactionParameters; +struct nativeDirectedChannelTransactionParametersOpaque; +typedef struct nativeDirectedChannelTransactionParametersOpaque LDKnativeDirectedChannelTransactionParameters; struct nativeHolderCommitmentTransactionOpaque; typedef struct nativeHolderCommitmentTransactionOpaque LDKnativeHolderCommitmentTransaction; +struct nativeBuiltCommitmentTransactionOpaque; +typedef struct nativeBuiltCommitmentTransactionOpaque LDKnativeBuiltCommitmentTransaction; +struct nativeCommitmentTransactionOpaque; +typedef struct nativeCommitmentTransactionOpaque LDKnativeCommitmentTransaction; +struct nativeTrustedCommitmentTransactionOpaque; +typedef struct nativeTrustedCommitmentTransactionOpaque LDKnativeTrustedCommitmentTransaction; 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 38139e0e0..cd511dea0 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -1,19 +1,15 @@ -#[no_mangle] pub type CVec_SpendableOutputDescriptorZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_SpendableOutputDescriptorZ_free: extern "C" fn(CVec_SpendableOutputDescriptorZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_MessageSendEventZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_MessageSendEventZ_free: extern "C" fn(CVec_MessageSendEventZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_EventZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_EventZ_free: extern "C" fn(CVec_EventZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type C2Tuple_usizeTransactionZ = crate::c_types::C2TupleTempl; #[no_mangle] pub static C2Tuple_usizeTransactionZ_free: extern "C" fn(C2Tuple_usizeTransactionZ) = crate::c_types::C2TupleTempl_free::; @@ -22,12 +18,10 @@ pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Tra C2Tuple_usizeTransactionZ { a, b, } } -#[no_mangle] pub type CVec_C2Tuple_usizeTransactionZZ = crate::c_types::CVecTempl>; #[no_mangle] pub static CVec_C2Tuple_usizeTransactionZZ_free: extern "C" fn(CVec_C2Tuple_usizeTransactionZZ) = crate::c_types::CVecTempl_free::>; -#[no_mangle] pub type CResult_NoneChannelMonitorUpdateErrZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_NoneChannelMonitorUpdateErrZ_free: extern "C" fn(CResult_NoneChannelMonitorUpdateErrZ) = crate::c_types::CResultTempl_free::; @@ -40,12 +34,10 @@ pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChann pub static CResult_NoneChannelMonitorUpdateErrZ_err: extern "C" fn (crate::chain::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CVec_MonitorEventZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_MonitorEventZ_free: extern "C" fn(CVec_MonitorEventZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CResult_NoneMonitorUpdateErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_NoneMonitorUpdateErrorZ_free: extern "C" fn(CResult_NoneMonitorUpdateErrorZ) = crate::c_types::CResultTempl_free::; @@ -58,7 +50,6 @@ pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpd pub static CResult_NoneMonitorUpdateErrorZ_err: extern "C" fn (crate::chain::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type C2Tuple_OutPointScriptZ = crate::c_types::C2TupleTempl; #[no_mangle] pub static C2Tuple_OutPointScriptZ_free: extern "C" fn(C2Tuple_OutPointScriptZ) = crate::c_types::C2TupleTempl_free::; @@ -67,12 +58,10 @@ pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutP C2Tuple_OutPointScriptZ { a, b, } } -#[no_mangle] pub type CVec_TransactionZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_TransactionZ_free: extern "C" fn(CVec_TransactionZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type C2Tuple_u32TxOutZ = crate::c_types::C2TupleTempl; #[no_mangle] pub static C2Tuple_u32TxOutZ_free: extern "C" fn(C2Tuple_u32TxOutZ) = crate::c_types::C2TupleTempl_free::; @@ -81,12 +70,10 @@ pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2T C2Tuple_u32TxOutZ { a, b, } } -#[no_mangle] pub type CVec_C2Tuple_u32TxOutZZ = crate::c_types::CVecTempl>; #[no_mangle] pub static CVec_C2Tuple_u32TxOutZZ_free: extern "C" fn(CVec_C2Tuple_u32TxOutZZ) = crate::c_types::CVecTempl_free::>; -#[no_mangle] pub type C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ = crate::c_types::C2TupleTempl>>; #[no_mangle] pub static C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free: extern "C" fn(C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) = crate::c_types::C2TupleTempl_free::>>; @@ -95,12 +82,10 @@ pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::Th C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } } -#[no_mangle] pub type CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ = crate::c_types::CVecTempl>>>; #[no_mangle] pub static CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free: extern "C" fn(CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ) = crate::c_types::CVecTempl_free::>>>; -#[no_mangle] pub type C2Tuple_u64u64Z = crate::c_types::C2TupleTempl; #[no_mangle] pub static C2Tuple_u64u64Z_free: extern "C" fn(C2Tuple_u64u64Z) = crate::c_types::C2TupleTempl_free::; @@ -109,17 +94,10 @@ pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { C2Tuple_u64u64Z { a, b, } } -#[no_mangle] -pub type CVec_HTLCOutputInCommitmentZ = crate::c_types::CVecTempl; -#[no_mangle] -pub static CVec_HTLCOutputInCommitmentZ_free: extern "C" fn(CVec_HTLCOutputInCommitmentZ) = crate::c_types::CVecTempl_free::; - -#[no_mangle] pub type CVec_SignatureZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_SignatureZ_free: extern "C" fn(CVec_SignatureZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type C2Tuple_SignatureCVec_SignatureZZ = crate::c_types::C2TupleTempl>; #[no_mangle] pub static C2Tuple_SignatureCVec_SignatureZZ_free: extern "C" fn(C2Tuple_SignatureCVec_SignatureZZ) = crate::c_types::C2TupleTempl_free::>; @@ -128,7 +106,6 @@ pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signa C2Tuple_SignatureCVec_SignatureZZ { a, b, } } -#[no_mangle] pub type CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ = crate::c_types::CResultTempl>, u8>; #[no_mangle] pub static CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free: extern "C" fn(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) = crate::c_types::CResultTempl_free::>, u8>; @@ -141,7 +118,6 @@ pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResul crate::c_types::CResultTempl::err(0) } -#[no_mangle] pub type CResult_SignatureNoneZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_SignatureNoneZ_free: extern "C" fn(CResult_SignatureNoneZ) = crate::c_types::CResultTempl_free::; @@ -154,20 +130,17 @@ pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { crate::c_types::CResultTempl::err(0) } +pub type CResult_ChanKeySignerDecodeErrorZ = crate::c_types::CResultTempl; #[no_mangle] -pub type CResult_CVec_SignatureZNoneZ = crate::c_types::CResultTempl, u8>; +pub static CResult_ChanKeySignerDecodeErrorZ_free: extern "C" fn(CResult_ChanKeySignerDecodeErrorZ) = crate::c_types::CResultTempl_free::; #[no_mangle] -pub static CResult_CVec_SignatureZNoneZ_free: extern "C" fn(CResult_CVec_SignatureZNoneZ) = crate::c_types::CResultTempl_free::, u8>; -#[no_mangle] -pub static CResult_CVec_SignatureZNoneZ_ok: extern "C" fn (CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ = - crate::c_types::CResultTempl::, u8>::ok; +pub static CResult_ChanKeySignerDecodeErrorZ_ok: extern "C" fn (crate::chain::keysinterface::ChannelKeys) -> CResult_ChanKeySignerDecodeErrorZ = + crate::c_types::CResultTempl::::ok; #[no_mangle] -pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ { - crate::c_types::CResultTempl::err(0) -} +pub static CResult_ChanKeySignerDecodeErrorZ_err: extern "C" fn (crate::ln::msgs::DecodeError) -> CResult_ChanKeySignerDecodeErrorZ = + crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CResult_TxOutAccessErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_TxOutAccessErrorZ_free: extern "C" fn(CResult_TxOutAccessErrorZ) = crate::c_types::CResultTempl_free::; @@ -179,7 +152,6 @@ pub static CResult_TxOutAccessErrorZ_ok: extern "C" fn (crate::c_types::TxOut) - pub static CResult_TxOutAccessErrorZ_err: extern "C" fn (crate::chain::AccessError) -> CResult_TxOutAccessErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CResult_NoneAPIErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_NoneAPIErrorZ_free: extern "C" fn(CResult_NoneAPIErrorZ) = crate::c_types::CResultTempl_free::; @@ -192,12 +164,10 @@ pub extern "C" fn CResult_NoneAPIErrorZ_ok() -> CResult_NoneAPIErrorZ { pub static CResult_NoneAPIErrorZ_err: extern "C" fn (crate::util::errors::APIError) -> CResult_NoneAPIErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CVec_ChannelDetailsZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_ChannelDetailsZ_free: extern "C" fn(CVec_ChannelDetailsZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CResult_NonePaymentSendFailureZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_NonePaymentSendFailureZ_free: extern "C" fn(CResult_NonePaymentSendFailureZ) = crate::c_types::CResultTempl_free::; @@ -210,42 +180,34 @@ pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSen pub static CResult_NonePaymentSendFailureZ_err: extern "C" fn (crate::ln::channelmanager::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CVec_NetAddressZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_NetAddressZ_free: extern "C" fn(CVec_NetAddressZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_ChannelMonitorZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_ChannelMonitorZ_free: extern "C" fn(CVec_ChannelMonitorZ) = crate::c_types::CVecTempl_free::; -#[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] pub static CVec_UpdateAddHTLCZ_free: extern "C" fn(CVec_UpdateAddHTLCZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_UpdateFulfillHTLCZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_UpdateFulfillHTLCZ_free: extern "C" fn(CVec_UpdateFulfillHTLCZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_UpdateFailHTLCZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_UpdateFailHTLCZ_free: extern "C" fn(CVec_UpdateFailHTLCZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_UpdateFailMalformedHTLCZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_UpdateFailMalformedHTLCZ_free: extern "C" fn(CVec_UpdateFailMalformedHTLCZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CResult_boolLightningErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_boolLightningErrorZ_free: extern "C" fn(CResult_boolLightningErrorZ) = crate::c_types::CResultTempl_free::; @@ -257,7 +219,6 @@ pub static CResult_boolLightningErrorZ_ok: extern "C" fn (bool) -> CResult_boolL pub static CResult_boolLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_boolLightningErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ = crate::c_types::C3TupleTempl; #[no_mangle] pub static C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free: extern "C" fn(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) = crate::c_types::C3TupleTempl_free::; @@ -266,27 +227,34 @@ pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { a, b, c, } } -#[no_mangle] pub type CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ = crate::c_types::CVecTempl>; #[no_mangle] pub static CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free: extern "C" fn(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) = crate::c_types::CVecTempl_free::>; -#[no_mangle] pub type CVec_NodeAnnouncementZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_NodeAnnouncementZ_free: extern "C" fn(CVec_NodeAnnouncementZ) = crate::c_types::CVecTempl_free::; +pub type CResult_NoneLightningErrorZ = crate::c_types::CResultTempl; +#[no_mangle] +pub static CResult_NoneLightningErrorZ_free: extern "C" fn(CResult_NoneLightningErrorZ) = crate::c_types::CResultTempl_free::; #[no_mangle] +pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { + crate::c_types::CResultTempl::ok(0) +} + +#[no_mangle] +pub static CResult_NoneLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ = + crate::c_types::CResultTempl::::err; + pub type CVec_PublicKeyZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_PublicKeyZ_free: extern "C" fn(CVec_PublicKeyZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_u8Z = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_u8Z_free: extern "C" fn(CVec_u8Z) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CResult_CVec_u8ZPeerHandleErrorZ = crate::c_types::CResultTempl, crate::ln::peer_handler::PeerHandleError>; #[no_mangle] pub static CResult_CVec_u8ZPeerHandleErrorZ_free: extern "C" fn(CResult_CVec_u8ZPeerHandleErrorZ) = crate::c_types::CResultTempl_free::, crate::ln::peer_handler::PeerHandleError>; @@ -298,7 +266,6 @@ pub static CResult_CVec_u8ZPeerHandleErrorZ_ok: extern "C" fn (CVec_u8Z) -> CRes pub static CResult_CVec_u8ZPeerHandleErrorZ_err: extern "C" fn (crate::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ = crate::c_types::CResultTempl::, crate::ln::peer_handler::PeerHandleError>::err; -#[no_mangle] pub type CResult_NonePeerHandleErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_NonePeerHandleErrorZ_free: extern "C" fn(CResult_NonePeerHandleErrorZ) = crate::c_types::CResultTempl_free::; @@ -311,7 +278,6 @@ pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErr pub static CResult_NonePeerHandleErrorZ_err: extern "C" fn (crate::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CResult_boolPeerHandleErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_boolPeerHandleErrorZ_free: extern "C" fn(CResult_boolPeerHandleErrorZ) = crate::c_types::CResultTempl_free::; @@ -323,7 +289,6 @@ pub static CResult_boolPeerHandleErrorZ_ok: extern "C" fn (bool) -> CResult_bool pub static CResult_boolPeerHandleErrorZ_err: extern "C" fn (crate::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CResult_SecretKeySecpErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_SecretKeySecpErrorZ_free: extern "C" fn(CResult_SecretKeySecpErrorZ) = crate::c_types::CResultTempl_free::; @@ -335,7 +300,6 @@ pub static CResult_SecretKeySecpErrorZ_ok: extern "C" fn (crate::c_types::Secret pub static CResult_SecretKeySecpErrorZ_err: extern "C" fn (crate::c_types::Secp256k1Error) -> CResult_SecretKeySecpErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CResult_PublicKeySecpErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_PublicKeySecpErrorZ_free: extern "C" fn(CResult_PublicKeySecpErrorZ) = crate::c_types::CResultTempl_free::; @@ -347,7 +311,6 @@ pub static CResult_PublicKeySecpErrorZ_ok: extern "C" fn (crate::c_types::Public pub static CResult_PublicKeySecpErrorZ_err: extern "C" fn (crate::c_types::Secp256k1Error) -> CResult_PublicKeySecpErrorZ = crate::c_types::CResultTempl::::err; -#[no_mangle] pub type CResult_TxCreationKeysSecpErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_TxCreationKeysSecpErrorZ_free: extern "C" fn(CResult_TxCreationKeysSecpErrorZ) = crate::c_types::CResultTempl_free::; @@ -359,36 +322,42 @@ pub static CResult_TxCreationKeysSecpErrorZ_ok: extern "C" fn (crate::ln::chan_u pub static CResult_TxCreationKeysSecpErrorZ_err: extern "C" fn (crate::c_types::Secp256k1Error) -> CResult_TxCreationKeysSecpErrorZ = crate::c_types::CResultTempl::::err; +pub type CResult_TrustedCommitmentTransactionNoneZ = crate::c_types::CResultTempl; #[no_mangle] -pub type C2Tuple_HTLCOutputInCommitmentSignatureZ = crate::c_types::C2TupleTempl; +pub static CResult_TrustedCommitmentTransactionNoneZ_free: extern "C" fn(CResult_TrustedCommitmentTransactionNoneZ) = crate::c_types::CResultTempl_free::; #[no_mangle] -pub static C2Tuple_HTLCOutputInCommitmentSignatureZ_free: extern "C" fn(C2Tuple_HTLCOutputInCommitmentSignatureZ) = crate::c_types::C2TupleTempl_free::; +pub static CResult_TrustedCommitmentTransactionNoneZ_ok: extern "C" fn (crate::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ = + crate::c_types::CResultTempl::::ok; + #[no_mangle] -pub extern "C" fn C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a: crate::ln::chan_utils::HTLCOutputInCommitment, b: crate::c_types::Signature) -> C2Tuple_HTLCOutputInCommitmentSignatureZ { - C2Tuple_HTLCOutputInCommitmentSignatureZ { a, b, } +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { + crate::c_types::CResultTempl::err(0) } +pub type CResult_CVec_SignatureZNoneZ = crate::c_types::CResultTempl, u8>; #[no_mangle] -pub type CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ = crate::c_types::CVecTempl>; +pub static CResult_CVec_SignatureZNoneZ_free: extern "C" fn(CResult_CVec_SignatureZNoneZ) = crate::c_types::CResultTempl_free::, u8>; #[no_mangle] -pub static CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free: extern "C" fn(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) = crate::c_types::CVecTempl_free::>; +pub static CResult_CVec_SignatureZNoneZ_ok: extern "C" fn (CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ = + crate::c_types::CResultTempl::, u8>::ok; #[no_mangle] +pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ { + crate::c_types::CResultTempl::err(0) +} + pub type CVec_RouteHopZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_RouteHopZ_free: extern "C" fn(CVec_RouteHopZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CVec_CVec_RouteHopZZ = crate::c_types::CVecTempl>; #[no_mangle] pub static CVec_CVec_RouteHopZZ_free: extern "C" fn(CVec_CVec_RouteHopZZ) = crate::c_types::CVecTempl_free::>; -#[no_mangle] pub type CVec_RouteHintZ = crate::c_types::CVecTempl; #[no_mangle] pub static CVec_RouteHintZ_free: extern "C" fn(CVec_RouteHintZ) = crate::c_types::CVecTempl_free::; -#[no_mangle] pub type CResult_RouteLightningErrorZ = crate::c_types::CResultTempl; #[no_mangle] pub static CResult_RouteLightningErrorZ_free: extern "C" fn(CResult_RouteLightningErrorZ) = crate::c_types::CResultTempl_free::; @@ -400,16 +369,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 CResult_NoneLightningErrorZ = crate::c_types::CResultTempl; -#[no_mangle] -pub static CResult_NoneLightningErrorZ_free: extern "C" fn(CResult_NoneLightningErrorZ) = crate::c_types::CResultTempl_free::; -#[no_mangle] -pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { - crate::c_types::CResultTempl::ok(0) -} - -#[no_mangle] -pub static CResult_NoneLightningErrorZ_err: extern "C" fn (crate::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ = - crate::c_types::CResultTempl::::err; - diff --git a/lightning-c-bindings/src/chain/chainmonitor.rs b/lightning-c-bindings/src/chain/chainmonitor.rs index 35eb1bed2..a0a1b7621 100644 --- a/lightning-c-bindings/src/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/chain/chainmonitor.rs @@ -64,7 +64,7 @@ extern "C" fn ChainMonitor_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChainMonitor { - pub(crate) fn take_ptr(mut self) -> *mut nativeChainMonitor { + pub(crate) fn take_inner(mut self) -> *mut nativeChainMonitor { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -117,6 +117,16 @@ pub extern "C" fn ChainMonitor_new(chain_source: *mut crate::chain::Filter, mut ChainMonitor { inner: Box::into_raw(Box::new(ret)), is_owned: true } } +impl From for crate::chain::Watch { + fn from(obj: nativeChainMonitor) -> Self { + let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChainMonitor_as_Watch(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChainMonitor_free_void); + ret + } +} #[no_mangle] pub extern "C" fn ChainMonitor_as_Watch(this_arg: *const ChainMonitor) -> crate::chain::Watch { crate::chain::Watch { @@ -130,13 +140,13 @@ pub extern "C" fn ChainMonitor_as_Watch(this_arg: *const ChainMonitor) -> crate: use lightning::chain::Watch as WatchTraitImport; #[must_use] extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_outpoint: crate::chain::transaction::OutPoint, mut monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.watch_channel(*unsafe { Box::from_raw(funding_outpoint.take_ptr()) }, *unsafe { Box::from_raw(monitor.take_ptr()) }); + let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.watch_channel(*unsafe { Box::from_raw(funding_outpoint.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }) }; local_ret } #[must_use] extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::chain::transaction::OutPoint, mut update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ { - let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.update_channel(*unsafe { Box::from_raw(funding_txo.take_ptr()) }, *unsafe { Box::from_raw(update.take_ptr()) }); + let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.update_channel(*unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(update.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }) }; local_ret } @@ -147,6 +157,16 @@ extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const local_ret.into() } +impl From for crate::util::events::EventsProvider { + fn from(obj: nativeChainMonitor) -> Self { + let mut rust_obj = ChainMonitor { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChainMonitor_as_EventsProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChainMonitor_free_void); + ret + } +} #[no_mangle] pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: *const ChainMonitor) -> crate::util::events::EventsProvider { crate::util::events::EventsProvider { diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs index c64467025..886812516 100644 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/chain/channelmonitor.rs @@ -49,7 +49,7 @@ extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelMonitorUpdate { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitorUpdate { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelMonitorUpdate { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -116,6 +116,10 @@ pub extern "C" fn ChannelMonitorUpdate_write(obj: *const ChannelMonitorUpdate) - crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitorUpdate) }) +} +#[no_mangle] pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> ChannelMonitorUpdate { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelMonitorUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -255,7 +259,7 @@ extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl MonitorUpdateError { - pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorUpdateError { + pub(crate) fn take_inner(mut self) -> *mut nativeMonitorUpdateError { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -293,7 +297,7 @@ extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl MonitorEvent { - pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorEvent { + pub(crate) fn take_inner(mut self) -> *mut nativeMonitorEvent { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -352,7 +356,7 @@ extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl HTLCUpdate { - pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCUpdate { + pub(crate) fn take_inner(mut self) -> *mut nativeHTLCUpdate { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -381,6 +385,10 @@ pub extern "C" fn HTLCUpdate_write(obj: *const HTLCUpdate) -> crate::c_types::de crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) }) +} +#[no_mangle] pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> HTLCUpdate { if let Ok(res) = crate::c_types::deserialize_obj(ser) { HTLCUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -402,6 +410,12 @@ type nativeChannelMonitor = nativeChannelMonitorImport *mut nativeChannelMonitor { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelMonitor { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -600,12 +614,12 @@ use lightning::chain::channelmonitor::Persist as rustPersist; impl rustPersist for Persist { fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.persist_new_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })}; + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.update_persisted_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (update as *const _) as *mut _ }, is_owned: false }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })}; + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } } diff --git a/lightning-c-bindings/src/chain/keysinterface.rs b/lightning-c-bindings/src/chain/keysinterface.rs index afa982bc4..285d90ba0 100644 --- a/lightning-c-bindings/src/chain/keysinterface.rs +++ b/lightning-c-bindings/src/chain/keysinterface.rs @@ -45,7 +45,7 @@ pub enum SpendableOutputDescriptor { /// /// 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 + /// call to ChannelKeys::ready_channel) and the provided per_commitment point /// to chan_utils::derive_public_revocation_key. /// /// The witness script which is hashed and included in the output script_pubkey may be @@ -82,7 +82,7 @@ impl SpendableOutputDescriptor { let mut outpoint_nonref = (*outpoint).clone(); let mut output_nonref = (*output).clone(); nativeSpendableOutputDescriptor::StaticOutput { - outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) }, + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, output: output_nonref.into_rust(), } }, @@ -95,7 +95,7 @@ impl SpendableOutputDescriptor { let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref.to_rust(); let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1); let mut revocation_pubkey_nonref = (*revocation_pubkey).clone(); nativeSpendableOutputDescriptor::DynamicOutputP2WSH { - outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) }, + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, per_commitment_point: per_commitment_point_nonref.into_rust(), to_self_delay: to_self_delay_nonref, output: output_nonref.into_rust(), @@ -109,7 +109,7 @@ impl SpendableOutputDescriptor { let mut key_derivation_params_nonref = (*key_derivation_params).clone(); let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref.to_rust(); let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1); nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment { - outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) }, + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, output: output_nonref.into_rust(), key_derivation_params: local_key_derivation_params_nonref, } @@ -121,14 +121,14 @@ impl SpendableOutputDescriptor { match self { SpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { nativeSpendableOutputDescriptor::StaticOutput { - outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) }, + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, output: output.into_rust(), } }, SpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut revocation_pubkey, } => { let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1); nativeSpendableOutputDescriptor::DynamicOutputP2WSH { - outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) }, + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, per_commitment_point: per_commitment_point.into_rust(), to_self_delay: to_self_delay, output: output.into_rust(), @@ -139,7 +139,7 @@ impl SpendableOutputDescriptor { SpendableOutputDescriptor::StaticOutputCounterpartyPayment {mut outpoint, mut output, mut key_derivation_params, } => { let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1); nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment { - outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) }, + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, output: output.into_rust(), key_derivation_params: local_key_derivation_params, } @@ -280,28 +280,20 @@ pub struct ChannelKeys { /// /// 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 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's commitment transaction. + pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, + /// Create a signatures for a holder's commitment transaction and its claiming HTLC transactions. + /// This will only ever be called with a non-revoked commitment_tx. This will be called with the + /// latest commitment_tx when we initiate a force-close. + /// This will be called with the previous latest, just to get claiming HTLC signatures, if we are + /// reacting to a ChannelMonitor replica that decided to broadcast before it had been updated to + /// the latest. + /// This may be called multiple times for the same transaction. /// - /// 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. + /// An external signer implementation should check that the commitment has not been revoked. /// - /// Either an Err should be returned, or a Vec with one entry for each HTLC which exists in - /// 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. + /// May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. #[must_use] - pub sign_holder_commitment_htlc_transactions: extern "C" fn (this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ, + pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, /// Create a signature for the given input in a transaction spending an HTLC or commitment /// transaction output when our counterparty broadcasts an old state. /// @@ -355,14 +347,19 @@ 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_selected/holder_selected_contest_delay. - /// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels. + /// Set the counterparty static channel data, including basepoints, + /// counterparty_selected/holder_selected_contest_delay and funding outpoint. + /// This is done as soon as the funding outpoint is known. Since these are static channel data, + /// they MUST NOT be allowed to change to different values once set. + /// + /// channel_parameters.is_populated() MUST be true. /// /// We bind holder_selected_contest_delay late here for API convenience. /// /// Will be called before any signatures are applied. - 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 ready_channel: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters), pub clone: Option *mut c_void>, + pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, pub free: Option, } unsafe impl Send for ChannelKeys {} @@ -376,14 +373,14 @@ pub extern "C" fn ChannelKeys_clone(orig: &ChannelKeys) -> ChannelKeys { set_pubkeys: orig.set_pubkeys.clone(), key_derivation_params: orig.key_derivation_params.clone(), sign_counterparty_commitment: orig.sign_counterparty_commitment.clone(), - sign_holder_commitment: orig.sign_holder_commitment.clone(), - sign_holder_commitment_htlc_transactions: orig.sign_holder_commitment_htlc_transactions.clone(), + sign_holder_commitment_and_htlcs: orig.sign_holder_commitment_and_htlcs.clone(), sign_justice_transaction: orig.sign_justice_transaction.clone(), sign_counterparty_htlc_transaction: orig.sign_counterparty_htlc_transaction.clone(), sign_closing_transaction: orig.sign_closing_transaction.clone(), sign_channel_announcement: orig.sign_channel_announcement.clone(), - on_accept: orig.on_accept.clone(), + ready_channel: orig.ready_channel.clone(), clone: orig.clone.clone(), + write: orig.write.clone(), free: orig.free.clone(), } } @@ -392,6 +389,12 @@ impl Clone for ChannelKeys { ChannelKeys_clone(self) } } +impl lightning::util::ser::Writeable for ChannelKeys { + fn write(&self, w: &mut W) -> Result<(), ::std::io::Error> { + let vec = (self.write)(self.this_arg); + w.write_all(vec.as_slice()) + } +} use lightning::chain::keysinterface::ChannelKeys as rustChannelKeys; impl rustChannelKeys for ChannelKeys { @@ -414,49 +417,42 @@ impl rustChannelKeys for ChannelKeys { let (mut orig_ret_0, mut orig_ret_1) = ret.to_rust(); let mut local_ret = (orig_ret_0, orig_ret_1); local_ret } - fn sign_counterparty_commitment(&self, feerate_per_kw: u32, commitment_tx: &bitcoin::blockdata::transaction::Transaction, keys: &lightning::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: &[&lightning::ln::chan_utils::HTLCOutputInCommitment], _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - let mut local_commitment_tx = ::bitcoin::consensus::encode::serialize(commitment_tx); - let mut local_htlcs = Vec::new(); for item in htlcs.iter() { local_htlcs.push( { crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ( (&(**item) as *const _) as *mut _) }, is_owned: false } }); }; - let mut ret = (self.sign_counterparty_commitment)(self.this_arg, feerate_per_kw, crate::c_types::Transaction::from_vec(local_commitment_tx), &crate::ln::chan_utils::PreCalculatedTxCreationKeys { inner: unsafe { (keys as *const _) as *mut _ }, is_owned: false }, local_htlcs.into()); - 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()) })*/ })}; + fn sign_counterparty_commitment(&self, commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { + let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::ln::chan_utils::CommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); + 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - 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, 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()) })*/ })}; + fn sign_holder_commitment_and_htlcs(&self, commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { + let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { (commitment_tx as *const _) as *mut _ }, is_owned: false }); + 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(<*mut _>::take_ptr(&mut ret.contents.result)) }).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(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_justice_transaction(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut local_justice_tx = ::bitcoin::consensus::encode::serialize(justice_tx); let mut local_htlc = &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (if htlc.is_none() { std::ptr::null() } else { { (htlc.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; let mut ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc); - 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()) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_counterparty_htlc_transaction(&self, htlc_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_point: &bitcoin::secp256k1::key::PublicKey, htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx); let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc 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()) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_closing_transaction(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut local_closing_tx = ::bitcoin::consensus::encode::serialize(closing_tx); let mut ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_closing_tx)); - 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()) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_channel_announcement(&self, msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.sign_channel_announcement)(self.this_arg, &crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { (msg 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()) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - 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) + fn ready_channel(&mut self, channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.ready_channel)(self.this_arg, &crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (channel_parameters as *const _) as *mut _ }, is_owned: false }) } } @@ -500,6 +496,14 @@ pub struct KeysInterface { /// persisted anywhere, though they must be unique across restarts. #[must_use] pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, + /// Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream. + /// This is only called during deserialization of other objects which contain + /// `ChannelKeys`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). + /// The bytes are exactly those which `::write()` writes, and + /// contain no versioning scheme. You may wish to include your own version prefix and ensure + /// you've read all of the provided bytes to ensure no corruption occurred. + #[must_use] + pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChanKeySignerDecodeErrorZ, pub free: Option, } unsafe impl Send for KeysInterface {} @@ -520,7 +524,7 @@ impl rustKeysInterface for KeysInterface { let mut ret = (self.get_shutdown_pubkey)(self.this_arg); ret.into_rust() } - fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> Self::ChanKeySigner { + fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys { let mut ret = (self.get_channel_keys)(self.this_arg, inbound, channel_value_satoshis); ret } @@ -528,6 +532,12 @@ impl rustKeysInterface for KeysInterface { let mut ret = (self.get_secure_random_bytes)(self.this_arg); ret.data } + fn read_chan_signer(&self, reader: &[u8]) -> Result { + let mut local_reader = crate::c_types::u8slice::from_slice(reader); + let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used @@ -553,6 +563,9 @@ use lightning::chain::keysinterface::InMemoryChannelKeys as nativeInMemoryChanne type nativeInMemoryChannelKeys = nativeInMemoryChannelKeysImport; /// A simple implementation of ChannelKeys that just keeps the private keys in memory. +/// +/// This implementation performs no policy checks and is insufficient by itself as +/// a secure external signer. #[must_use] #[repr(C)] pub struct InMemoryChannelKeys { @@ -579,7 +592,7 @@ extern "C" fn InMemoryChannelKeys_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl InMemoryChannelKeys { - pub(crate) fn take_ptr(mut self) -> *mut nativeInMemoryChannelKeys { + pub(crate) fn take_inner(mut self) -> *mut nativeInMemoryChannelKeys { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -679,7 +692,7 @@ pub extern "C" fn InMemoryChannelKeys_new(mut funding_key: crate::c_types::Secre } /// Counterparty pubkeys. -/// Will panic if on_accept wasn't called. +/// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelPublicKeys { @@ -689,9 +702,8 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_pubkeys(this_arg: &InMemoryCh /// 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's transactions. -/// Will panic if on_accept wasn't called. +/// broadcast a transaction. +/// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 { @@ -702,7 +714,7 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_a /// 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. +/// Will panic if ready_channel wasn't called. #[must_use] #[no_mangle] pub extern "C" fn InMemoryChannelKeys_holder_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 { @@ -710,6 +722,45 @@ pub extern "C" fn InMemoryChannelKeys_holder_selected_contest_delay(this_arg: &I ret } +/// Whether the holder is the initiator +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemoryChannelKeys_is_outbound(this_arg: &InMemoryChannelKeys) -> bool { + let mut ret = unsafe { &*this_arg.inner }.is_outbound(); + ret +} + +/// Funding outpoint +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemoryChannelKeys_funding_outpoint(this_arg: &InMemoryChannelKeys) -> crate::chain::transaction::OutPoint { + let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); + crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or +/// building transactions. +/// +/// Will panic if ready_channel wasn't called. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemoryChannelKeys_get_channel_parameters(this_arg: &InMemoryChannelKeys) -> crate::ln::chan_utils::ChannelTransactionParameters { + let mut ret = unsafe { &*this_arg.inner }.get_channel_parameters(); + crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +impl From for crate::chain::keysinterface::ChannelKeys { + fn from(obj: nativeInMemoryChannelKeys) -> Self { + let mut rust_obj = InMemoryChannelKeys { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = InMemoryChannelKeys_as_ChannelKeys(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(InMemoryChannelKeys_free_void); + ret + } +} #[no_mangle] pub extern "C" fn InMemoryChannelKeys_as_ChannelKeys(this_arg: *const InMemoryChannelKeys) -> crate::chain::keysinterface::ChannelKeys { crate::chain::keysinterface::ChannelKeys { @@ -722,14 +773,14 @@ pub extern "C" fn InMemoryChannelKeys_as_ChannelKeys(this_arg: *const InMemoryCh set_pubkeys: Some(InMemoryChannelKeys_ChannelKeys_set_pubkeys), key_derivation_params: InMemoryChannelKeys_ChannelKeys_key_derivation_params, sign_counterparty_commitment: InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment, - sign_holder_commitment: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment, - sign_holder_commitment_htlc_transactions: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions, + sign_holder_commitment_and_htlcs: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs, sign_justice_transaction: InMemoryChannelKeys_ChannelKeys_sign_justice_transaction, sign_counterparty_htlc_transaction: InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction, sign_closing_transaction: InMemoryChannelKeys_ChannelKeys_sign_closing_transaction, sign_channel_announcement: InMemoryChannelKeys_ChannelKeys_sign_channel_announcement, - on_accept: InMemoryChannelKeys_ChannelKeys_on_accept, + ready_channel: InMemoryChannelKeys_ChannelKeys_ready_channel, clone: Some(InMemoryChannelKeys_clone_void), + write: InMemoryChannelKeys_write_void, } } use lightning::chain::keysinterface::ChannelKeys as ChannelKeysTraitImport; @@ -762,22 +813,15 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_key_derivation_params(this_arg: *c local_ret } #[must_use] -extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, mut feerate_per_kw: u32, mut commitment_tx: crate::c_types::Transaction, pre_keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, mut htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut local_htlcs = Vec::new(); for mut item in htlcs.as_slice().iter() { local_htlcs.push( { unsafe { &*item.inner } }); }; - let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(feerate_per_kw, &commitment_tx.into_bitcoin(), unsafe { &*pre_keys.inner }, &local_htlcs[..], &bitcoin::secp256k1::Secp256k1::new()); +extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) }; local_ret } #[must_use] -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, 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*/ }) }; +extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_and_htlcs(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) }; local_ret } #[must_use] @@ -805,8 +849,8 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_channel_announcement(this_arg 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 } -extern "C" fn InMemoryChannelKeys_ChannelKeys_on_accept(this_arg: *mut c_void, channel_pubkeys: &crate::ln::chan_utils::ChannelPublicKeys, mut counterparty_selected_contest_delay: u16, mut holder_selected_contest_delay: u16) { - unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.on_accept(unsafe { &*channel_pubkeys.inner }, counterparty_selected_contest_delay, holder_selected_contest_delay) +extern "C" fn InMemoryChannelKeys_ChannelKeys_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::ln::chan_utils::ChannelTransactionParameters) { + unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.ready_channel(unsafe { &*channel_parameters.inner }) } #[no_mangle] @@ -814,6 +858,10 @@ pub extern "C" fn InMemoryChannelKeys_write(obj: *const InMemoryChannelKeys) -> crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn InMemoryChannelKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemoryChannelKeys) }) +} +#[no_mangle] pub extern "C" fn InMemoryChannelKeys_read(ser: crate::c_types::u8slice) -> InMemoryChannelKeys { if let Ok(res) = crate::c_types::deserialize_obj(ser) { InMemoryChannelKeys { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -858,7 +906,7 @@ extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl KeysManager { - pub(crate) fn take_ptr(mut self) -> *mut nativeKeysManager { + pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -903,6 +951,16 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut ch crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true } } +impl From for crate::chain::keysinterface::KeysInterface { + fn from(obj: nativeKeysManager) -> Self { + let mut rust_obj = KeysManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = KeysManager_as_KeysInterface(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(KeysManager_free_void); + ret + } +} #[no_mangle] pub extern "C" fn KeysManager_as_KeysInterface(this_arg: *const KeysManager) -> crate::chain::keysinterface::KeysInterface { crate::chain::keysinterface::KeysInterface { @@ -913,6 +971,7 @@ pub extern "C" fn KeysManager_as_KeysInterface(this_arg: *const KeysManager) -> get_shutdown_pubkey: KeysManager_KeysInterface_get_shutdown_pubkey, get_channel_keys: KeysManager_KeysInterface_get_channel_keys, get_secure_random_bytes: KeysManager_KeysInterface_get_secure_random_bytes, + read_chan_signer: KeysManager_KeysInterface_read_chan_signer, } } use lightning::chain::keysinterface::KeysInterface as KeysInterfaceTraitImport; @@ -934,17 +993,17 @@ extern "C" fn KeysManager_KeysInterface_get_shutdown_pubkey(this_arg: *const c_v #[must_use] extern "C" fn KeysManager_KeysInterface_get_channel_keys(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::chain::keysinterface::ChannelKeys { let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_channel_keys(_inbound, channel_value_satoshis); - let mut rust_obj = InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }; - let mut ret = InMemoryChannelKeys_as_ChannelKeys(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = std::ptr::null_mut(); - ret.free = Some(InMemoryChannelKeys_free_void); - ret - + ret.into() } #[must_use] extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.get_secure_random_bytes(); crate::c_types::ThirtyTwoBytes { data: ret } } +#[must_use] +extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChanKeySignerDecodeErrorZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeKeysManager) }.read_chan_signer(reader.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) }; + local_ret +} diff --git a/lightning-c-bindings/src/chain/mod.rs b/lightning-c-bindings/src/chain/mod.rs index 6ea4d99db..fa337d314 100644 --- a/lightning-c-bindings/src/chain/mod.rs +++ b/lightning-c-bindings/src/chain/mod.rs @@ -77,7 +77,7 @@ use lightning::chain::Access as rustAccess; impl rustAccess for Access { fn get_utxo(&self, genesis_hash: &bitcoin::hash_types::BlockHash, short_channel_id: u64) -> Result { let mut ret = (self.get_utxo)(self.this_arg, genesis_hash.as_inner(), short_channel_id); - 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()) }).into_native() })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } } @@ -156,19 +156,19 @@ unsafe impl Sync for Watch {} use lightning::chain::Watch as rustWatch; impl rustWatch for Watch { type Keys = crate::chain::keysinterface::ChannelKeys; - fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.watch_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })}; + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } fn update_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, update: lightning::chain::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.update_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(update)), is_owned: true }); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })}; + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } fn release_pending_monitor_events(&self) -> Vec { let mut ret = (self.release_pending_monitor_events)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret } } diff --git a/lightning-c-bindings/src/chain/transaction.rs b/lightning-c-bindings/src/chain/transaction.rs index 3a35c4727..ff7aff7e9 100644 --- a/lightning-c-bindings/src/chain/transaction.rs +++ b/lightning-c-bindings/src/chain/transaction.rs @@ -38,7 +38,7 @@ extern "C" fn OutPoint_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl OutPoint { - pub(crate) fn take_ptr(mut self) -> *mut nativeOutPoint { + pub(crate) fn take_inner(mut self) -> *mut nativeOutPoint { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -105,6 +105,10 @@ pub extern "C" fn OutPoint_write(obj: *const OutPoint) -> crate::c_types::derive crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn OutPoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutPoint) }) +} +#[no_mangle] pub extern "C" fn OutPoint_read(ser: crate::c_types::u8slice) -> OutPoint { if let Ok(res) = crate::c_types::deserialize_obj(ser) { OutPoint { inner: Box::into_raw(Box::new(res)), is_owned: true } diff --git a/lightning-c-bindings/src/ln/chan_utils.rs b/lightning-c-bindings/src/ln/chan_utils.rs index f9e6c407e..5bd272070 100644 --- a/lightning-c-bindings/src/ln/chan_utils.rs +++ b/lightning-c-bindings/src/ln/chan_utils.rs @@ -85,7 +85,7 @@ type nativeTxCreationKeys = nativeTxCreationKeysImport; /// /// 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 +/// CommitmentTransaction.trust().keys() because we trusted the source of the /// pre-calculated keys. #[must_use] #[repr(C)] @@ -113,7 +113,7 @@ extern "C" fn TxCreationKeys_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl TxCreationKeys { - pub(crate) fn take_ptr(mut self) -> *mut nativeTxCreationKeys { + pub(crate) fn take_inner(mut self) -> *mut nativeTxCreationKeys { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -212,6 +212,10 @@ pub extern "C" fn TxCreationKeys_write(obj: *const TxCreationKeys) -> crate::c_t crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxCreationKeys) }) +} +#[no_mangle] pub extern "C" fn TxCreationKeys_read(ser: crate::c_types::u8slice) -> TxCreationKeys { if let Ok(res) = crate::c_types::deserialize_obj(ser) { TxCreationKeys { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -220,89 +224,6 @@ pub extern "C" fn TxCreationKeys_read(ser: crate::c_types::u8slice) -> TxCreatio } } -use lightning::ln::chan_utils::PreCalculatedTxCreationKeys as nativePreCalculatedTxCreationKeysImport; -type nativePreCalculatedTxCreationKeys = nativePreCalculatedTxCreationKeysImport; - -/// The per-commitment point and a set of pre-calculated public keys used for transaction creation -/// in the signer. -/// The pre-calculated keys are an optimization, because ChannelKeys has enough -/// information to re-derive them. -#[must_use] -#[repr(C)] -pub struct PreCalculatedTxCreationKeys { - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativePreCalculatedTxCreationKeys, - pub is_owned: bool, -} - -impl Drop for PreCalculatedTxCreationKeys { - 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 PreCalculatedTxCreationKeys_free(this_ptr: PreCalculatedTxCreationKeys) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn PreCalculatedTxCreationKeys_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativePreCalculatedTxCreationKeys); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl PreCalculatedTxCreationKeys { - pub(crate) fn take_ptr(mut self) -> *mut nativePreCalculatedTxCreationKeys { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret - } -} -impl Clone for PreCalculatedTxCreationKeys { - 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 PreCalculatedTxCreationKeys_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePreCalculatedTxCreationKeys)).clone() })) as *mut c_void -} -#[no_mangle] -pub extern "C" fn PreCalculatedTxCreationKeys_clone(orig: &PreCalculatedTxCreationKeys) -> PreCalculatedTxCreationKeys { - PreCalculatedTxCreationKeys { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } -} -/// Create a new PreCalculatedTxCreationKeys from TxCreationKeys -#[must_use] -#[no_mangle] -pub extern "C" fn PreCalculatedTxCreationKeys_new(mut keys: crate::ln::chan_utils::TxCreationKeys) -> PreCalculatedTxCreationKeys { - let mut ret = lightning::ln::chan_utils::PreCalculatedTxCreationKeys::new(*unsafe { Box::from_raw(keys.take_ptr()) }); - PreCalculatedTxCreationKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true } -} - -/// The pre-calculated transaction creation public keys. -/// An external validating signer should not trust these keys. -#[must_use] -#[no_mangle] -pub extern "C" fn PreCalculatedTxCreationKeys_trust_key_derivation(this_arg: &PreCalculatedTxCreationKeys) -> crate::ln::chan_utils::TxCreationKeys { - let mut ret = unsafe { &*this_arg.inner }.trust_key_derivation(); - crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } -} - -/// The transaction per-commitment point -#[must_use] -#[no_mangle] -pub extern "C" fn PreCalculatedTxCreationKeys_per_commitment_point(this_arg: &PreCalculatedTxCreationKeys) -> crate::c_types::PublicKey { - let mut ret = unsafe { &*this_arg.inner }.per_commitment_point(); - crate::c_types::PublicKey::from_rust(&*ret) -} - - use lightning::ln::chan_utils::ChannelPublicKeys as nativeChannelPublicKeysImport; type nativeChannelPublicKeys = nativeChannelPublicKeysImport; @@ -333,7 +254,7 @@ extern "C" fn ChannelPublicKeys_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelPublicKeys { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelPublicKeys { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelPublicKeys { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -446,6 +367,10 @@ pub extern "C" fn ChannelPublicKeys_write(obj: *const ChannelPublicKeys) -> crat crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelPublicKeys) }) +} +#[no_mangle] pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> ChannelPublicKeys { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelPublicKeys { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -453,7 +378,8 @@ pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> Channe ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true } } } -/// Create a new TxCreationKeys from channel base points and the per-commitment point +/// Create per-state keys from channel base points and the per-commitment point. +/// Key set is asymmetric and can't be used as part of counter-signatory set of transactions. #[must_use] #[no_mangle] pub extern "C" fn TxCreationKeys_derive_new(mut per_commitment_point: crate::c_types::PublicKey, mut broadcaster_delayed_payment_base: crate::c_types::PublicKey, mut broadcaster_htlc_base: crate::c_types::PublicKey, mut countersignatory_revocation_base: crate::c_types::PublicKey, mut countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ { @@ -462,6 +388,16 @@ pub extern "C" fn TxCreationKeys_derive_new(mut per_commitment_point: crate::c_t local_ret } +/// Generate per-state keys from channel static keys. +/// Key set is asymmetric and can't be used as part of counter-signatory set of transactions. +#[must_use] +#[no_mangle] +pub extern "C" fn TxCreationKeys_from_channel_static_keys(mut per_commitment_point: crate::c_types::PublicKey, broadcaster_keys: &crate::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ { + let mut ret = lightning::ln::chan_utils::TxCreationKeys::from_channel_static_keys(&per_commitment_point.into_rust(), unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, &bitcoin::secp256k1::Secp256k1::new()); + 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_holder` output on a commitment transaction or 2nd-stage HTLC transactions. @@ -502,7 +438,7 @@ extern "C" fn HTLCOutputInCommitment_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl HTLCOutputInCommitment { - pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCOutputInCommitment { + pub(crate) fn take_inner(mut self) -> *mut nativeHTLCOutputInCommitment { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -583,6 +519,10 @@ pub extern "C" fn HTLCOutputInCommitment_write(obj: *const HTLCOutputInCommitmen crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCOutputInCommitment) }) +} +#[no_mangle] pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> HTLCOutputInCommitment { if let Ok(res) = crate::c_types::deserialize_obj(ser) { HTLCOutputInCommitment { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -615,12 +555,380 @@ pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate } +use lightning::ln::chan_utils::ChannelTransactionParameters as nativeChannelTransactionParametersImport; +type nativeChannelTransactionParameters = nativeChannelTransactionParametersImport; + +/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). +/// The fields are organized by holder/counterparty. +/// +/// Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters +/// before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions. +#[must_use] +#[repr(C)] +pub struct ChannelTransactionParameters { + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelTransactionParameters, + pub is_owned: bool, +} + +impl Drop for ChannelTransactionParameters { + 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 ChannelTransactionParameters_free(this_ptr: ChannelTransactionParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn ChannelTransactionParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelTransactionParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl ChannelTransactionParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelTransactionParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for ChannelTransactionParameters { + 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 ChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelTransactionParameters)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_clone(orig: &ChannelTransactionParameters) -> ChannelTransactionParameters { + ChannelTransactionParameters { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} +/// Holder public keys +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_holder_pubkeys(this_ptr: &ChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_pubkeys; + crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Holder public keys +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_holder_pubkeys(this_ptr: &mut ChannelTransactionParameters, mut val: crate::ln::chan_utils::ChannelPublicKeys) { + unsafe { &mut *this_ptr.inner }.holder_pubkeys = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_holder_selected_contest_delay(this_ptr: &ChannelTransactionParameters) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay; + (*inner_val) +} +/// The contest delay selected by the holder, which applies to counterparty-broadcast transactions +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_holder_selected_contest_delay(this_ptr: &mut ChannelTransactionParameters, mut val: u16) { + unsafe { &mut *this_ptr.inner }.holder_selected_contest_delay = val; +} +/// Whether the holder is the initiator of this channel. +/// This is an input to the commitment number obscure factor computation. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_is_outbound_from_holder(this_ptr: &ChannelTransactionParameters) -> bool { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound_from_holder; + (*inner_val) +} +/// Whether the holder is the initiator of this channel. +/// This is an input to the commitment number obscure factor computation. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_is_outbound_from_holder(this_ptr: &mut ChannelTransactionParameters, mut val: bool) { + unsafe { &mut *this_ptr.inner }.is_outbound_from_holder = val; +} +/// The late-bound counterparty channel transaction parameters. +/// These parameters are populated at the point in the protocol where the counterparty provides them. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_counterparty_parameters(this_ptr: &ChannelTransactionParameters) -> crate::ln::chan_utils::CounterpartyChannelTransactionParameters { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_parameters; + let mut local_inner_val = crate::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The late-bound counterparty channel transaction parameters. +/// These parameters are populated at the point in the protocol where the counterparty provides them. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_counterparty_parameters(this_ptr: &mut ChannelTransactionParameters, mut val: crate::ln::chan_utils::CounterpartyChannelTransactionParameters) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.counterparty_parameters = local_val; +} +/// The late-bound funding outpoint +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_get_funding_outpoint(this_ptr: &ChannelTransactionParameters) -> crate::chain::transaction::OutPoint { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_outpoint; + let mut local_inner_val = crate::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The late-bound funding outpoint +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &mut ChannelTransactionParameters, mut val: crate::chain::transaction::OutPoint) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *this_ptr.inner }.funding_outpoint = local_val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::chain::transaction::OutPoint) -> ChannelTransactionParameters { + let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) }; + let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) }; + ChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeChannelTransactionParameters { + holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) }, + holder_selected_contest_delay: holder_selected_contest_delay_arg, + is_outbound_from_holder: is_outbound_from_holder_arg, + counterparty_parameters: local_counterparty_parameters_arg, + funding_outpoint: local_funding_outpoint_arg, + })), is_owned: true } +} + +use lightning::ln::chan_utils::CounterpartyChannelTransactionParameters as nativeCounterpartyChannelTransactionParametersImport; +type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelTransactionParametersImport; + +/// Late-bound per-channel counterparty data used to build transactions. +#[must_use] +#[repr(C)] +pub struct CounterpartyChannelTransactionParameters { + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeCounterpartyChannelTransactionParameters, + pub is_owned: bool, +} + +impl Drop for CounterpartyChannelTransactionParameters { + 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 CounterpartyChannelTransactionParameters_free(this_ptr: CounterpartyChannelTransactionParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn CounterpartyChannelTransactionParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCounterpartyChannelTransactionParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl CounterpartyChannelTransactionParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyChannelTransactionParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for CounterpartyChannelTransactionParameters { + 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 CounterpartyChannelTransactionParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyChannelTransactionParameters)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_clone(orig: &CounterpartyChannelTransactionParameters) -> CounterpartyChannelTransactionParameters { + CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} +/// Counter-party public keys +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_get_pubkeys(this_ptr: &CounterpartyChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkeys; + crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Counter-party public keys +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_set_pubkeys(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: crate::ln::chan_utils::ChannelPublicKeys) { + unsafe { &mut *this_ptr.inner }.pubkeys = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_get_selected_contest_delay(this_ptr: &CounterpartyChannelTransactionParameters) -> u16 { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.selected_contest_delay; + (*inner_val) +} +/// The contest delay selected by the counterparty, which applies to holder-broadcast transactions +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_set_selected_contest_delay(this_ptr: &mut CounterpartyChannelTransactionParameters, mut val: u16) { + unsafe { &mut *this_ptr.inner }.selected_contest_delay = val; +} +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_new(mut pubkeys_arg: crate::ln::chan_utils::ChannelPublicKeys, mut selected_contest_delay_arg: u16) -> CounterpartyChannelTransactionParameters { + CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(nativeCounterpartyChannelTransactionParameters { + pubkeys: *unsafe { Box::from_raw(pubkeys_arg.take_inner()) }, + selected_contest_delay: selected_contest_delay_arg, + })), is_owned: true } +} +/// Whether the late bound parameters are populated. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_is_populated(this_arg: &ChannelTransactionParameters) -> bool { + let mut ret = unsafe { &*this_arg.inner }.is_populated(); + ret +} + +/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, +/// given that the holder is the broadcaster. +/// +/// self.is_populated() must be true before calling this function. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_as_holder_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::ln::chan_utils::DirectedChannelTransactionParameters { + let mut ret = unsafe { &*this_arg.inner }.as_holder_broadcastable(); + crate::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +/// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, +/// given that the counterparty is the broadcaster. +/// +/// self.is_populated() must be true before calling this function. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_as_counterparty_broadcastable(this_arg: &ChannelTransactionParameters) -> crate::ln::chan_utils::DirectedChannelTransactionParameters { + let mut ret = unsafe { &*this_arg.inner }.as_counterparty_broadcastable(); + crate::ln::chan_utils::DirectedChannelTransactionParameters { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: *const CounterpartyChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) }) +} +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> CounterpartyChannelTransactionParameters { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + CounterpartyChannelTransactionParameters { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + CounterpartyChannelTransactionParameters { inner: std::ptr::null_mut(), is_owned: true } + } +} +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_write(obj: *const ChannelTransactionParameters) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) }) +} +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_read(ser: crate::c_types::u8slice) -> ChannelTransactionParameters { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + ChannelTransactionParameters { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + ChannelTransactionParameters { inner: std::ptr::null_mut(), is_owned: true } + } +} + +use lightning::ln::chan_utils::DirectedChannelTransactionParameters as nativeDirectedChannelTransactionParametersImport; +type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static>; + +/// Static channel fields used to build transactions given per-commitment fields, organized by +/// broadcaster/countersignatory. +/// +/// This is derived from the holder/counterparty-organized ChannelTransactionParameters via the +/// as_holder_broadcastable and as_counterparty_broadcastable functions. +#[must_use] +#[repr(C)] +pub struct DirectedChannelTransactionParameters { + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeDirectedChannelTransactionParameters, + pub is_owned: bool, +} + +impl Drop for DirectedChannelTransactionParameters { + 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 DirectedChannelTransactionParameters_free(this_ptr: DirectedChannelTransactionParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn DirectedChannelTransactionParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelTransactionParameters); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl DirectedChannelTransactionParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelTransactionParameters { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// Get the channel pubkeys for the broadcaster +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_broadcaster_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &*this_arg.inner }.broadcaster_pubkeys(); + crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Get the channel pubkeys for the countersignatory +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_countersignatory_pubkeys(this_arg: &DirectedChannelTransactionParameters) -> crate::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &*this_arg.inner }.countersignatory_pubkeys(); + crate::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// Get the contest delay applicable to the transactions. +/// Note that the contest delay was selected by the countersignatory. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_contest_delay(this_arg: &DirectedChannelTransactionParameters) -> u16 { + let mut ret = unsafe { &*this_arg.inner }.contest_delay(); + ret +} + +/// Whether the channel is outbound from the broadcaster. +/// +/// The boolean representing the side that initiated the channel is +/// an input to the commitment number obscure factor computation. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &DirectedChannelTransactionParameters) -> bool { + let mut ret = unsafe { &*this_arg.inner }.is_outbound(); + ret +} + +/// The funding outpoint +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &DirectedChannelTransactionParameters) -> crate::chain::transaction::OutPoint { + let mut ret = unsafe { &*this_arg.inner }.funding_outpoint(); + crate::c_types::bitcoin_to_C_outpoint(ret) +} + + use lightning::ln::chan_utils::HolderCommitmentTransaction as nativeHolderCommitmentTransactionImport; type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport; -/// 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. +/// Information needed to build and sign a holder's commitment transaction. +/// +/// The transaction is only signed once we are ready to broadcast. #[must_use] #[repr(C)] pub struct HolderCommitmentTransaction { @@ -647,7 +955,7 @@ extern "C" fn HolderCommitmentTransaction_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl HolderCommitmentTransaction { - pub(crate) fn take_ptr(mut self) -> *mut nativeHolderCommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeHolderCommitmentTransaction { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -671,124 +979,394 @@ pub(crate) extern "C" fn HolderCommitmentTransaction_clone_void(this_ptr: *const pub extern "C" fn HolderCommitmentTransaction_clone(orig: &HolderCommitmentTransaction) -> HolderCommitmentTransaction { HolderCommitmentTransaction { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } } -/// The commitment transaction itself, in unsigned form. +/// Our counterparty's signature for the transaction +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_get_counterparty_sig(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Signature { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_sig; + crate::c_types::Signature::from_rust(&(*inner_val)) +} +/// Our counterparty's signature for the transaction +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_set_counterparty_sig(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Signature) { + unsafe { &mut *this_ptr.inner }.counterparty_sig = val.into_rust(); +} +/// All non-dust counterparty HTLC signatures, in the order they appear in the transaction +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_set_counterparty_htlc_sigs(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::derived::CVec_SignatureZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); }; + unsafe { &mut *this_ptr.inner }.counterparty_htlc_sigs = local_val; +} +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_write(obj: *const HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) }) +} +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_read(ser: crate::c_types::u8slice) -> HolderCommitmentTransaction { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + HolderCommitmentTransaction { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + HolderCommitmentTransaction { inner: std::ptr::null_mut(), is_owned: true } + } +} +/// Create a new holder transaction with the given counterparty signatures. +/// The funding keys are used to figure out which signature should go first when building the transaction for broadcast. +#[must_use] +#[no_mangle] +pub extern "C" fn HolderCommitmentTransaction_new(mut commitment_tx: crate::ln::chan_utils::CommitmentTransaction, mut counterparty_sig: crate::c_types::Signature, mut counterparty_htlc_sigs: crate::c_types::derived::CVec_SignatureZ, mut holder_funding_key: crate::c_types::PublicKey, mut counterparty_funding_key: crate::c_types::PublicKey) -> HolderCommitmentTransaction { + let mut local_counterparty_htlc_sigs = Vec::new(); for mut item in counterparty_htlc_sigs.into_rust().drain(..) { local_counterparty_htlc_sigs.push( { item.into_rust() }); }; + let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new(*unsafe { Box::from_raw(commitment_tx.take_inner()) }, counterparty_sig.into_rust(), local_counterparty_htlc_sigs, &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust()); + HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } +} + + +use lightning::ln::chan_utils::BuiltCommitmentTransaction as nativeBuiltCommitmentTransactionImport; +type nativeBuiltCommitmentTransaction = nativeBuiltCommitmentTransactionImport; + +/// A pre-built Bitcoin commitment transaction and its txid. +#[must_use] +#[repr(C)] +pub struct BuiltCommitmentTransaction { + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBuiltCommitmentTransaction, + pub is_owned: bool, +} + +impl Drop for BuiltCommitmentTransaction { + 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 BuiltCommitmentTransaction_free(this_ptr: BuiltCommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn BuiltCommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBuiltCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl BuiltCommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeBuiltCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for BuiltCommitmentTransaction { + 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 BuiltCommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBuiltCommitmentTransaction)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_clone(orig: &BuiltCommitmentTransaction) -> BuiltCommitmentTransaction { + BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} +/// The commitment transaction #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_get_unsigned_tx(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Transaction { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.unsigned_tx; +pub extern "C" fn BuiltCommitmentTransaction_get_transaction(this_ptr: &BuiltCommitmentTransaction) -> crate::c_types::Transaction { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.transaction; let mut local_inner_val = ::bitcoin::consensus::encode::serialize(inner_val); crate::c_types::Transaction::from_vec(local_inner_val) } -/// The commitment transaction itself, in unsigned form. +/// The commitment transaction #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_set_unsigned_tx(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Transaction) { - unsafe { &mut *this_ptr.inner }.unsigned_tx = val.into_bitcoin(); +pub extern "C" fn BuiltCommitmentTransaction_set_transaction(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::Transaction) { + unsafe { &mut *this_ptr.inner }.transaction = val.into_bitcoin(); } -/// Our counterparty's signature for the transaction, above. +/// The txid for the commitment transaction. +/// +/// This is provided as a performance optimization, instead of calling transaction.txid() +/// multiple times. #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_get_counterparty_sig(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Signature { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_sig; - crate::c_types::Signature::from_rust(&(*inner_val)) +pub extern "C" fn BuiltCommitmentTransaction_get_txid(this_ptr: &BuiltCommitmentTransaction) -> *const [u8; 32] { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid; + (*inner_val).as_inner() } -/// Our counterparty's signature for the transaction, above. +/// The txid for the commitment transaction. +/// +/// This is provided as a performance optimization, instead of calling transaction.txid() +/// multiple times. #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_set_counterparty_sig(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Signature) { - unsafe { &mut *this_ptr.inner }.counterparty_sig = val.into_rust(); +pub extern "C" fn BuiltCommitmentTransaction_set_txid(this_ptr: &mut BuiltCommitmentTransaction, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *this_ptr.inner }.txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); } -/// The feerate paid per 1000-weight-unit in this commitment transaction. This value is -/// controlled by the channel initiator. +#[must_use] #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_get_feerate_per_kw(this_ptr: &HolderCommitmentTransaction) -> u32 { - let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw; - (*inner_val) +pub extern "C" fn BuiltCommitmentTransaction_new(mut transaction_arg: crate::c_types::Transaction, mut txid_arg: crate::c_types::ThirtyTwoBytes) -> BuiltCommitmentTransaction { + BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(nativeBuiltCommitmentTransaction { + transaction: transaction_arg.into_bitcoin(), + txid: ::bitcoin::hash_types::Txid::from_slice(&txid_arg.data[..]).unwrap(), + })), is_owned: true } } -/// The feerate paid per 1000-weight-unit in this commitment transaction. This value is -/// controlled by the channel initiator. #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_set_feerate_per_kw(this_ptr: &mut HolderCommitmentTransaction, mut val: u32) { - unsafe { &mut *this_ptr.inner }.feerate_per_kw = val; +pub extern "C" fn BuiltCommitmentTransaction_write(obj: *const BuiltCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) }) +} +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) -> BuiltCommitmentTransaction { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + BuiltCommitmentTransaction { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + BuiltCommitmentTransaction { inner: std::ptr::null_mut(), is_owned: true } + } } -/// The HTLCs and counterparty htlc signatures which were included in this commitment transaction. +/// Get the SIGHASH_ALL sighash value of the 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_holder or to_counterparty outputs. +/// This can be used to verify a signature. +#[must_use] +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*this_arg.inner }.get_sighash_all(&::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis); + crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } +} + +/// Sign a transaction, either because we are counter-signing the counterparty's transaction or +/// because we are about to broadcast a holder transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_sign(this_arg: &BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature { + let mut ret = unsafe { &*this_arg.inner }.sign(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, &bitcoin::secp256k1::Secp256k1::new()); + crate::c_types::Signature::from_rust(&ret) +} + + +use lightning::ln::chan_utils::CommitmentTransaction as nativeCommitmentTransactionImport; +type nativeCommitmentTransaction = nativeCommitmentTransactionImport; + +/// This class tracks the per-transaction information needed to build a commitment transaction and to +/// actually build it and sign. It is used for holder transactions that we sign only when needed +/// and for transactions we sign for the counterparty. /// -/// 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(). +/// This class can be used inside a signer implementation to generate a signature given the relevant +/// secret key. +#[must_use] +#[repr(C)] +pub struct CommitmentTransaction { + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeCommitmentTransaction, + pub is_owned: bool, +} + +impl Drop for CommitmentTransaction { + 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 CommitmentTransaction_free(this_ptr: CommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn CommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl CommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +impl Clone for CommitmentTransaction { + 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 CommitmentTransaction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentTransaction)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn CommitmentTransaction_clone(orig: &CommitmentTransaction) -> CommitmentTransaction { + CommitmentTransaction { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true } +} +#[no_mangle] +pub extern "C" fn CommitmentTransaction_write(obj: *const CommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) +} +#[no_mangle] +pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentTransaction) }) +} +#[no_mangle] +pub extern "C" fn CommitmentTransaction_read(ser: crate::c_types::u8slice) -> CommitmentTransaction { + if let Ok(res) = crate::c_types::deserialize_obj(ser) { + CommitmentTransaction { inner: Box::into_raw(Box::new(res)), is_owned: true } + } else { + CommitmentTransaction { inner: std::ptr::null_mut(), is_owned: true } + } +} +/// The backwards-counting commitment number +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_commitment_number(this_arg: &CommitmentTransaction) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.commitment_number(); + ret +} + +/// The value to be sent to the broadcaster +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_to_broadcaster_value_sat(this_arg: &CommitmentTransaction) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.to_broadcaster_value_sat(); + ret +} + +/// The value to be sent to the counterparty +#[must_use] #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_set_per_htlc(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let (mut orig_val_0_0, mut orig_val_0_1) = item.to_rust(); let mut local_orig_val_0_1 = if orig_val_0_1.is_null() { None } else { Some( { orig_val_0_1.into_rust() }) }; let mut local_val_0 = (*unsafe { Box::from_raw(orig_val_0_0.take_ptr()) }, local_orig_val_0_1); local_val_0 }); }; - unsafe { &mut *this_ptr.inner }.per_htlc = local_val; +pub extern "C" fn CommitmentTransaction_to_countersignatory_value_sat(this_arg: &CommitmentTransaction) -> u64 { + let mut ret = unsafe { &*this_arg.inner }.to_countersignatory_value_sat(); + ret } -/// Generate a new HolderCommitmentTransaction based on a raw commitment transaction, -/// counterparty signature and both parties keys. + +/// The feerate paid per 1000-weight-unit in this commitment transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentTransaction_feerate_per_kw(this_arg: &CommitmentTransaction) -> u32 { + let mut ret = unsafe { &*this_arg.inner }.feerate_per_kw(); + ret +} + +/// Trust our pre-built transaction and derived transaction creation public keys. +/// +/// Applies a wrapper which allows access to these fields. /// -/// 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. +/// This should only be used if you fully trust the builder of this object. It should not +///\tbe used by an external signer - instead use the verify function. #[must_use] #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_new_missing_holder_sig(mut unsigned_tx: crate::c_types::Transaction, mut counterparty_sig: crate::c_types::Signature, mut holder_funding_key: crate::c_types::PublicKey, mut 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 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(unsigned_tx.into_bitcoin(), 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 } +pub extern "C" fn CommitmentTransaction_trust(this_arg: &CommitmentTransaction) -> crate::ln::chan_utils::TrustedCommitmentTransaction { + let mut ret = unsafe { &*this_arg.inner }.trust(); + crate::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true } } -/// The pre-calculated transaction creation public keys. -/// An external validating signer should not trust these keys. +/// Verify our pre-built transaction and derived transaction creation public keys. +/// +/// Applies a wrapper which allows access to these fields. +/// +/// An external validating signer must call this method before signing +/// or using the built transaction. #[must_use] #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_trust_key_derivation(this_arg: &HolderCommitmentTransaction) -> crate::ln::chan_utils::TxCreationKeys { - let mut ret = unsafe { &*this_arg.inner }.trust_key_derivation(); - crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +pub extern "C" fn CommitmentTransaction_verify(this_arg: &CommitmentTransaction, channel_parameters: &crate::ln::chan_utils::DirectedChannelTransactionParameters, broadcaster_keys: &crate::ln::chan_utils::ChannelPublicKeys, countersignatory_keys: &crate::ln::chan_utils::ChannelPublicKeys) -> crate::c_types::derived::CResult_TrustedCommitmentTransactionNoneZ { + let mut ret = unsafe { &*this_arg.inner }.verify(unsafe { &*channel_parameters.inner }, unsafe { &*broadcaster_keys.inner }, unsafe { &*countersignatory_keys.inner }, &bitcoin::secp256k1::Secp256k1::new()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::TrustedCommitmentTransaction { inner: Box::into_raw(Box::new(o)), is_owned: true } }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) }; + local_ret } -/// Get the txid of the holder commitment transaction contained in this -/// HolderCommitmentTransaction + +use lightning::ln::chan_utils::TrustedCommitmentTransaction as nativeTrustedCommitmentTransactionImport; +type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImport<'static>; + +/// A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin +/// transaction and the transaction creation keys) are trusted. +/// +/// See trust() and verify() functions on CommitmentTransaction. +/// +/// This structure implements Deref. #[must_use] +#[repr(C)] +pub struct TrustedCommitmentTransaction { + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTrustedCommitmentTransaction, + pub is_owned: bool, +} + +impl Drop for TrustedCommitmentTransaction { + 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 HolderCommitmentTransaction_txid(this_arg: &HolderCommitmentTransaction) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn TrustedCommitmentTransaction_free(this_ptr: TrustedCommitmentTransaction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +extern "C" fn TrustedCommitmentTransaction_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTrustedCommitmentTransaction); } +} +#[allow(unused)] +/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy +impl TrustedCommitmentTransaction { + pub(crate) fn take_inner(mut self) -> *mut nativeTrustedCommitmentTransaction { + assert!(self.is_owned); + let ret = self.inner; + self.inner = std::ptr::null_mut(); + ret + } +} +/// The transaction ID of the built Bitcoin transaction +#[must_use] +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_txid(this_arg: &TrustedCommitmentTransaction) -> crate::c_types::ThirtyTwoBytes { let mut ret = unsafe { &*this_arg.inner }.txid(); crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } } -/// 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_holder_commitment() calls directly. -/// Channel value is amount locked in funding_outpoint. +/// The pre-built Bitcoin commitment transaction #[must_use] #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_get_holder_sig(this_arg: &HolderCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature { - let mut ret = unsafe { &*this_arg.inner }.get_holder_sig(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, &bitcoin::secp256k1::Secp256k1::new()); - crate::c_types::Signature::from_rust(&ret) +pub extern "C" fn TrustedCommitmentTransaction_built_transaction(this_arg: &TrustedCommitmentTransaction) -> crate::ln::chan_utils::BuiltCommitmentTransaction { + let mut ret = unsafe { &*this_arg.inner }.built_transaction(); + crate::ln::chan_utils::BuiltCommitmentTransaction { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } +} + +/// The pre-calculated transaction creation public keys. +#[must_use] +#[no_mangle] +pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &TrustedCommitmentTransaction) -> crate::ln::chan_utils::TxCreationKeys { + let mut ret = unsafe { &*this_arg.inner }.keys(); + crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } /// Get a signature for each HTLC which was included in the commitment transaction (ie for /// which HTLCOutputInCommitment::transaction_output_index.is_some()). /// -/// The returned Vec has one entry for each HTLC, and in the same order. For HTLCs which were -/// considered dust and not included, a None entry exists, for all others a signature is -/// included. +/// The returned Vec has one entry for each HTLC, and in the same order. #[must_use] #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_get_htlc_sigs(this_arg: &HolderCommitmentTransaction, htlc_base_key: *const [u8; 32], mut counterparty_selected_contest_delay: u16) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { - let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), counterparty_selected_contest_delay, &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*/ }) }; +pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { + let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), unsafe { &*channel_parameters.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( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) }; local_ret } +/// Get the transaction number obscure factor #[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_write(obj: *const HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) -} -#[no_mangle] -pub extern "C" fn HolderCommitmentTransaction_read(ser: crate::c_types::u8slice) -> HolderCommitmentTransaction { - if let Ok(res) = crate::c_types::deserialize_obj(ser) { - HolderCommitmentTransaction { inner: Box::into_raw(Box::new(res)), is_owned: true } - } else { - HolderCommitmentTransaction { inner: std::ptr::null_mut(), is_owned: true } - } +pub extern "C" fn get_commitment_transaction_number_obscure_factor(mut broadcaster_payment_basepoint: crate::c_types::PublicKey, mut countersignatory_payment_basepoint: crate::c_types::PublicKey, mut outbound_from_broadcaster: bool) -> u64 { + let mut ret = lightning::ln::chan_utils::get_commitment_transaction_number_obscure_factor(&broadcaster_payment_basepoint.into_rust(), &countersignatory_payment_basepoint.into_rust(), outbound_from_broadcaster); + ret } + diff --git a/lightning-c-bindings/src/ln/channelmanager.rs b/lightning-c-bindings/src/ln/channelmanager.rs index c21f26e94..57570d9f2 100644 --- a/lightning-c-bindings/src/ln/channelmanager.rs +++ b/lightning-c-bindings/src/ln/channelmanager.rs @@ -79,7 +79,7 @@ extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelManager { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelManager { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -117,7 +117,7 @@ extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelDetails { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelDetails { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -182,7 +182,7 @@ pub extern "C" fn ChannelDetails_get_counterparty_features(this_ptr: &ChannelDet /// many routing-relevant features are present in the init context. #[no_mangle] pub extern "C" fn ChannelDetails_set_counterparty_features(this_ptr: &mut ChannelDetails, mut val: crate::ln::features::InitFeatures) { - unsafe { &mut *this_ptr.inner }.counterparty_features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.counterparty_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The value, in satoshis, of this channel as appears in the funding output #[no_mangle] @@ -288,7 +288,7 @@ extern "C" fn PaymentSendFailure_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl PaymentSendFailure { - pub(crate) fn take_ptr(mut self) -> *mut nativePaymentSendFailure { + pub(crate) fn take_inner(mut self) -> *mut nativePaymentSendFailure { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -312,7 +312,7 @@ impl PaymentSendFailure { #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_new(mut network: crate::bitcoin::network::Network, mut fee_est: crate::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::chain::Watch, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut keys_manager: crate::chain::keysinterface::KeysInterface, mut config: crate::util::config::UserConfig, mut current_blockchain_height: usize) -> ChannelManager { - let mut ret = lightning::ln::channelmanager::ChannelManager::new(network.into_bitcoin(), fee_est, chain_monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_ptr()) }, current_blockchain_height); + let mut ret = lightning::ln::channelmanager::ChannelManager::new(network.into_bitcoin(), fee_est, chain_monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_inner()) }, current_blockchain_height); ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } } @@ -331,7 +331,7 @@ pub extern "C" fn ChannelManager_new(mut network: crate::bitcoin::network::Netwo #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_create_channel(this_arg: &ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_id: u64, mut override_config: crate::util::config::UserConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_ptr()) } }) }; + let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) }; let mut ret = unsafe { &*this_arg.inner }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_id, local_override_config); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }) }; local_ret @@ -374,10 +374,13 @@ pub extern "C" fn ChannelManager_close_channel(this_arg: &ChannelManager, channe } /// Force closes a channel, immediately broadcasting the latest local commitment transaction to -/// the chain and rejecting new HTLCs on the given channel. +/// the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager. +#[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) { - unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id}) +pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id}); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }) }; + local_ret } /// Force close all channels, immediately broadcasting the latest local commitment transaction @@ -446,7 +449,7 @@ pub extern "C" fn ChannelManager_send_payment(this_arg: &ChannelManager, route: /// be trivially prevented by using unique funding transaction keys per-channel). #[no_mangle] pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut funding_txo: crate::chain::transaction::OutPoint) { - unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, *unsafe { Box::from_raw(funding_txo.take_ptr()) }) + unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, *unsafe { Box::from_raw(funding_txo.take_inner()) }) } /// Generates a signed node_announcement from the given arguments and creates a @@ -556,6 +559,16 @@ pub extern "C" fn ChannelManager_channel_monitor_updated(this_arg: &ChannelManag unsafe { &*this_arg.inner }.channel_monitor_updated(unsafe { &*funding_txo.inner }, highest_applied_update_id) } +impl From for crate::util::events::MessageSendEventsProvider { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChannelManager_free_void); + ret + } +} #[no_mangle] pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: *const ChannelManager) -> crate::util::events::MessageSendEventsProvider { crate::util::events::MessageSendEventsProvider { @@ -572,6 +585,16 @@ extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg local_ret.into() } +impl From for crate::util::events::EventsProvider { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_EventsProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChannelManager_free_void); + ret + } +} #[no_mangle] pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: *const ChannelManager) -> crate::util::events::EventsProvider { crate::util::events::EventsProvider { @@ -604,6 +627,16 @@ pub extern "C" fn ChannelManager_block_disconnected(this_arg: &ChannelManager, h unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap()) } +impl From for crate::ln::msgs::ChannelMessageHandler { + fn from(obj: nativeChannelManager) -> Self { + let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChannelManager_free_void); + ret + } +} #[no_mangle] pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: *const ChannelManager) -> crate::ln::msgs::ChannelMessageHandler { crate::ln::msgs::ChannelMessageHandler { @@ -637,10 +670,10 @@ 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, mut 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 }) + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_open_channel(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner }) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut 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 }) + unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_accept_channel(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner }) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut 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 }) @@ -745,7 +778,7 @@ extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelManagerReadArgs { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelManagerReadArgs { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -753,14 +786,16 @@ impl ChannelManagerReadArgs { } } /// The keys provider which will give us relevant keys. Some keys will be loaded during -/// deserialization. +/// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel +/// signing data. #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::chain::keysinterface::KeysInterface { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.keys_manager; &(*inner_val) } /// The keys provider which will give us relevant keys. Some keys will be loaded during -/// deserialization. +/// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel +/// signing data. #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::keysinterface::KeysInterface) { unsafe { &mut *this_ptr.inner }.keys_manager = val; @@ -838,7 +873,7 @@ pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelMa /// runtime settings which were stored when the ChannelManager was serialized. #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::util::config::UserConfig) { - unsafe { &mut *this_ptr.inner }.default_config = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.default_config = *unsafe { Box::from_raw(val.take_inner()) }; } /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor /// HashMap for you. This is primarily useful for C bindings where it is not practical to @@ -847,7 +882,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut Chann #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::chain::keysinterface::KeysInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::chain::Watch, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut default_config: crate::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> ChannelManagerReadArgs { let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { unsafe { &mut *item.inner } }); }; - let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(keys_manager, fee_estimator, chain_monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_ptr()) }, local_channel_monitors); + let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(keys_manager, fee_estimator, chain_monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_inner()) }, local_channel_monitors); ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true } } diff --git a/lightning-c-bindings/src/ln/features.rs b/lightning-c-bindings/src/ln/features.rs index 6a6be2845..b01b011a5 100644 --- a/lightning-c-bindings/src/ln/features.rs +++ b/lightning-c-bindings/src/ln/features.rs @@ -51,7 +51,7 @@ extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl InitFeatures { - pub(crate) fn take_ptr(mut self) -> *mut nativeInitFeatures { + pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -89,7 +89,7 @@ extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NodeFeatures { - pub(crate) fn take_ptr(mut self) -> *mut nativeNodeFeatures { + pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -127,7 +127,7 @@ extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelFeatures { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelFeatures { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); diff --git a/lightning-c-bindings/src/ln/msgs.rs b/lightning-c-bindings/src/ln/msgs.rs index 401da3777..3680c2ac2 100644 --- a/lightning-c-bindings/src/ln/msgs.rs +++ b/lightning-c-bindings/src/ln/msgs.rs @@ -50,7 +50,7 @@ extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl DecodeError { - pub(crate) fn take_ptr(mut self) -> *mut nativeDecodeError { + pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -88,7 +88,7 @@ extern "C" fn Init_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl Init { - pub(crate) fn take_ptr(mut self) -> *mut nativeInit { + pub(crate) fn take_inner(mut self) -> *mut nativeInit { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -143,7 +143,7 @@ extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ErrorMessage { - pub(crate) fn take_ptr(mut self) -> *mut nativeErrorMessage { + pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -234,7 +234,7 @@ extern "C" fn Ping_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl Ping { - pub(crate) fn take_ptr(mut self) -> *mut nativePing { + pub(crate) fn take_inner(mut self) -> *mut nativePing { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -321,7 +321,7 @@ extern "C" fn Pong_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl Pong { - pub(crate) fn take_ptr(mut self) -> *mut nativePong { + pub(crate) fn take_inner(mut self) -> *mut nativePong { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -396,7 +396,7 @@ extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl OpenChannel { - pub(crate) fn take_ptr(mut self) -> *mut nativeOpenChannel { + pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -649,7 +649,7 @@ extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl AcceptChannel { - pub(crate) fn take_ptr(mut self) -> *mut nativeAcceptChannel { + pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -858,7 +858,7 @@ extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl FundingCreated { - pub(crate) fn take_ptr(mut self) -> *mut nativeFundingCreated { + pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -967,7 +967,7 @@ extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl FundingSigned { - pub(crate) fn take_ptr(mut self) -> *mut nativeFundingSigned { + pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1052,7 +1052,7 @@ extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl FundingLocked { - pub(crate) fn take_ptr(mut self) -> *mut nativeFundingLocked { + pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1137,7 +1137,7 @@ extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl Shutdown { - pub(crate) fn take_ptr(mut self) -> *mut nativeShutdown { + pub(crate) fn take_inner(mut self) -> *mut nativeShutdown { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1224,7 +1224,7 @@ extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ClosingSigned { - pub(crate) fn take_ptr(mut self) -> *mut nativeClosingSigned { + pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1321,7 +1321,7 @@ extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UpdateAddHTLC { - pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateAddHTLC { + pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1431,7 +1431,7 @@ extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UpdateFulfillHTLC { - pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFulfillHTLC { + pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1528,7 +1528,7 @@ extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UpdateFailHTLC { - pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFailHTLC { + pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1605,7 +1605,7 @@ extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UpdateFailMalformedHTLC { - pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFailMalformedHTLC { + pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1693,7 +1693,7 @@ extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl CommitmentSigned { - pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentSigned { + pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1786,7 +1786,7 @@ extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl RevokeAndACK { - pub(crate) fn take_ptr(mut self) -> *mut nativeRevokeAndACK { + pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1883,7 +1883,7 @@ extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UpdateFee { - pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFee { + pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -1971,7 +1971,7 @@ extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl DataLossProtect { - pub(crate) fn take_ptr(mut self) -> *mut nativeDataLossProtect { + pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2058,7 +2058,7 @@ extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelReestablish { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelReestablish { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2146,7 +2146,7 @@ extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl AnnouncementSignatures { - pub(crate) fn take_ptr(mut self) -> *mut nativeAnnouncementSignatures { + pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2438,7 +2438,7 @@ extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UnsignedNodeAnnouncement { - pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedNodeAnnouncement { + pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2471,7 +2471,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeA /// The advertised features #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// A strictly monotonic announcement counter, with gaps allowed #[no_mangle] @@ -2558,7 +2558,7 @@ extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NodeAnnouncement { - pub(crate) fn take_ptr(mut self) -> *mut nativeNodeAnnouncement { + pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2602,14 +2602,14 @@ pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> /// The actual content of the announcement #[no_mangle] pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) { - unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) }; } #[must_use] #[no_mangle] pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement { NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement { signature: signature_arg.into_rust(), - contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) }, + contents: *unsafe { Box::from_raw(contents_arg.take_inner()) }, })), is_owned: true } } @@ -2643,7 +2643,7 @@ extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UnsignedChannelAnnouncement { - pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelAnnouncement { + pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2676,7 +2676,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedCh /// The advertised channel features #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -2775,7 +2775,7 @@ extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelAnnouncement { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelAnnouncement { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -2852,7 +2852,7 @@ pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncemen /// The actual announcement #[no_mangle] pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) { - unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) }; } #[must_use] #[no_mangle] @@ -2862,7 +2862,7 @@ pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_typ node_signature_2: node_signature_2_arg.into_rust(), bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(), bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(), - contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) }, + contents: *unsafe { Box::from_raw(contents_arg.take_inner()) }, })), is_owned: true } } @@ -2896,7 +2896,7 @@ extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UnsignedChannelUpdate { - pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelUpdate { + pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3039,7 +3039,7 @@ extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelUpdate { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelUpdate { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3083,14 +3083,14 @@ pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate: /// The actual channel update #[no_mangle] pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) { - unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) }; } #[must_use] #[no_mangle] pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate { ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate { signature: signature_arg.into_rust(), - contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) }, + contents: *unsafe { Box::from_raw(contents_arg.take_inner()) }, })), is_owned: true } } @@ -3127,7 +3127,7 @@ extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) { #[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 { + pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3230,7 +3230,7 @@ extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) { #[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 { + pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3356,7 +3356,7 @@ extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) { #[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 { + pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3440,7 +3440,7 @@ extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) { #[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 { + pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3529,7 +3529,7 @@ extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) { #[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 { + pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3618,7 +3618,7 @@ impl ErrorAction { match self { ErrorAction::DisconnectPeer {ref msg, } => { let mut msg_nonref = (*msg).clone(); - let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_ptr()) } }) }; + let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) }; nativeErrorAction::DisconnectPeer { msg: local_msg_nonref, } @@ -3627,7 +3627,7 @@ impl ErrorAction { ErrorAction::SendErrorMessage {ref msg, } => { let mut msg_nonref = (*msg).clone(); nativeErrorAction::SendErrorMessage { - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, } @@ -3636,7 +3636,7 @@ impl ErrorAction { pub(crate) fn into_native(self) -> nativeErrorAction { match self { ErrorAction::DisconnectPeer {mut msg, } => { - let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_ptr()) } }) }; + let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) }; nativeErrorAction::DisconnectPeer { msg: local_msg, } @@ -3644,7 +3644,7 @@ impl ErrorAction { ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, ErrorAction::SendErrorMessage {mut msg, } => { nativeErrorAction::SendErrorMessage { - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, } @@ -3723,7 +3723,7 @@ extern "C" fn LightningError_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl LightningError { - pub(crate) fn take_ptr(mut self) -> *mut nativeLightningError { + pub(crate) fn take_inner(mut self) -> *mut nativeLightningError { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3792,7 +3792,7 @@ extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl CommitmentUpdate { - pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentUpdate { + pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -3819,25 +3819,25 @@ pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentU /// update_add_htlc messages which should be sent #[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val; } /// update_fulfill_htlc messages which should be sent #[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val; } /// update_fail_htlc messages which should be sent #[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val; } /// update_fail_malformed_htlc messages which should be sent #[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val; } /// An update_fee message which should be sent @@ -3850,7 +3850,7 @@ pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) - /// An update_fee message which should be sent #[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.update_fee = local_val; } /// Finally, the commitment_signed message which should be sent @@ -3862,23 +3862,23 @@ pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUp /// Finally, the commitment_signed message which should be sent #[no_mangle] pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) { - unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) }; } #[must_use] #[no_mangle] pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types::derived::CVec_UpdateAddHTLCZ, mut update_fulfill_htlcs_arg: crate::c_types::derived::CVec_UpdateFulfillHTLCZ, mut update_fail_htlcs_arg: crate::c_types::derived::CVec_UpdateFailHTLCZ, mut update_fail_malformed_htlcs_arg: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ, mut update_fee_arg: crate::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::ln::msgs::CommitmentSigned) -> CommitmentUpdate { - let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; - let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; - let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; - let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; - let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_ptr()) } }) }; + let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) }; CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate { update_add_htlcs: local_update_add_htlcs_arg, update_fulfill_htlcs: local_update_fulfill_htlcs_arg, update_fail_htlcs: local_update_fail_htlcs_arg, update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg, update_fee: local_update_fee_arg, - commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_ptr()) }, + commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) }, })), is_owned: true } } /// The information we received from a peer along the route of a payment we originated. This is @@ -3911,7 +3911,7 @@ impl HTLCFailChannelUpdate { HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => { let mut msg_nonref = (*msg).clone(); nativeHTLCFailChannelUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => { @@ -3937,7 +3937,7 @@ impl HTLCFailChannelUpdate { match self { HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => { nativeHTLCFailChannelUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => { @@ -4149,6 +4149,12 @@ impl Drop for ChannelMessageHandler { } } /// A trait to describe an object which can receive routing messages. +/// +/// # Implementor DoS Warnings +/// +/// For `gossip_queries` messages there are potential DoS vectors when handling +/// inbound queries. Implementors using an on-disk network graph should be aware of +/// repeated disk I/O for queries accessing different parts of the network graph. #[repr(C)] pub struct RoutingMessageHandler { pub this_arg: *mut c_void, @@ -4177,29 +4183,55 @@ pub struct RoutingMessageHandler { /// If None is provided for starting_point, we start at the first node. #[must_use] pub get_next_node_announcements: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey, batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ, - /// Returns whether a full sync should be requested from a peer. + /// Called when a connection is established with a peer. This can be used to + /// perform routing table synchronization using a strategy defined by the + /// implementor. + pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init), + /// Handles the reply of a query we initiated to learn about channels + /// for a given range of blocks. We can expect to receive one or more + /// replies to a single query. + #[must_use] + pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Handles the reply of a query we initiated asking for routing gossip + /// messages for a list of channels. We should receive this message when + /// a node has completed its best effort to send us the pertaining routing + /// gossip messages. #[must_use] - pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool, + pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Handles when a peer asks us to send a list of short_channel_ids + /// for the requested range of blocks. + #[must_use] + pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + /// Handles when a peer asks us to send routing gossip messages for a + /// list of short_channel_ids. + #[must_use] + pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ, + pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider, pub free: Option, } unsafe impl Send for RoutingMessageHandler {} unsafe impl Sync for RoutingMessageHandler {} +impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler { + fn get_and_clear_pending_msg_events(&self) -> Vec { + ::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider) + } +} use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; impl rustRoutingMessageHandler for RoutingMessageHandler { fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg 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()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg 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()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result { let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg 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()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })}; + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) { @@ -4207,18 +4239,37 @@ impl rustRoutingMessageHandler for RoutingMessageHandler { } fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_ptr()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_ptr()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_ptr()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); }; local_ret } fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec { let mut local_starting_point = if starting_point.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(starting_point.unwrap())) } }; let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret } - fn should_request_full_sync(&self, node_id: &bitcoin::secp256k1::key::PublicKey) -> bool { - let mut ret = (self.should_request_full_sync)(self.this_arg, crate::c_types::PublicKey::from_rust(&node_id)); - ret + fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) { + (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Init { inner: unsafe { (init as *const _) as *mut _ }, is_owned: false }) + } + fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_reply_short_channel_ids_end(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret } } @@ -4245,6 +4296,10 @@ pub extern "C" fn AcceptChannel_write(obj: *const AcceptChannel) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) }) +} +#[no_mangle] pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel { if let Ok(res) = crate::c_types::deserialize_obj(ser) { AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4257,6 +4312,10 @@ pub extern "C" fn AnnouncementSignatures_write(obj: *const AnnouncementSignature crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) }) +} +#[no_mangle] pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures { if let Ok(res) = crate::c_types::deserialize_obj(ser) { AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4269,6 +4328,10 @@ pub extern "C" fn ChannelReestablish_write(obj: *const ChannelReestablish) -> cr crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) }) +} +#[no_mangle] pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> ChannelReestablish { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelReestablish { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4281,6 +4344,10 @@ pub extern "C" fn ClosingSigned_write(obj: *const ClosingSigned) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) }) +} +#[no_mangle] pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4293,6 +4360,10 @@ pub extern "C" fn CommitmentSigned_write(obj: *const CommitmentSigned) -> crate: crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) }) +} +#[no_mangle] pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned { if let Ok(res) = crate::c_types::deserialize_obj(ser) { CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4305,6 +4376,10 @@ pub extern "C" fn FundingCreated_write(obj: *const FundingCreated) -> crate::c_t crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) }) +} +#[no_mangle] pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated { if let Ok(res) = crate::c_types::deserialize_obj(ser) { FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4317,6 +4392,10 @@ pub extern "C" fn FundingSigned_write(obj: *const FundingSigned) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) }) +} +#[no_mangle] pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned { if let Ok(res) = crate::c_types::deserialize_obj(ser) { FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4329,6 +4408,10 @@ pub extern "C" fn FundingLocked_write(obj: *const FundingLocked) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) }) +} +#[no_mangle] pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked { if let Ok(res) = crate::c_types::deserialize_obj(ser) { FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4341,6 +4424,10 @@ pub extern "C" fn Init_write(obj: *const Init) -> crate::c_types::derived::CVec_ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) }) +} +#[no_mangle] pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> Init { if let Ok(res) = crate::c_types::deserialize_obj(ser) { Init { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4353,6 +4440,10 @@ pub extern "C" fn OpenChannel_write(obj: *const OpenChannel) -> crate::c_types:: crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) }) +} +#[no_mangle] pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel { if let Ok(res) = crate::c_types::deserialize_obj(ser) { OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4365,6 +4456,10 @@ pub extern "C" fn RevokeAndACK_write(obj: *const RevokeAndACK) -> crate::c_types crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) }) +} +#[no_mangle] pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK { if let Ok(res) = crate::c_types::deserialize_obj(ser) { RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4377,6 +4472,10 @@ pub extern "C" fn Shutdown_write(obj: *const Shutdown) -> crate::c_types::derive crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) }) +} +#[no_mangle] pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown { if let Ok(res) = crate::c_types::deserialize_obj(ser) { Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4389,6 +4488,10 @@ pub extern "C" fn UpdateFailHTLC_write(obj: *const UpdateFailHTLC) -> crate::c_t crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) }) +} +#[no_mangle] pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4401,6 +4504,10 @@ pub extern "C" fn UpdateFailMalformedHTLC_write(obj: *const UpdateFailMalformedH crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) }) +} +#[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4413,6 +4520,10 @@ pub extern "C" fn UpdateFee_write(obj: *const UpdateFee) -> crate::c_types::deri crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) }) +} +#[no_mangle] pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4425,6 +4536,10 @@ pub extern "C" fn UpdateFulfillHTLC_write(obj: *const UpdateFulfillHTLC) -> crat crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) }) +} +#[no_mangle] pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4437,6 +4552,10 @@ pub extern "C" fn UpdateAddHTLC_write(obj: *const UpdateAddHTLC) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) }) +} +#[no_mangle] pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4449,6 +4568,10 @@ pub extern "C" fn Ping_write(obj: *const Ping) -> crate::c_types::derived::CVec_ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) }) +} +#[no_mangle] pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> Ping { if let Ok(res) = crate::c_types::deserialize_obj(ser) { Ping { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4461,6 +4584,10 @@ pub extern "C" fn Pong_write(obj: *const Pong) -> crate::c_types::derived::CVec_ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) }) +} +#[no_mangle] pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> Pong { if let Ok(res) = crate::c_types::deserialize_obj(ser) { Pong { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4473,6 +4600,10 @@ pub extern "C" fn UnsignedChannelAnnouncement_write(obj: *const UnsignedChannelA crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) }) +} +#[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedChannelAnnouncement { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4485,6 +4616,10 @@ pub extern "C" fn ChannelAnnouncement_write(obj: *const ChannelAnnouncement) -> crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) }) +} +#[no_mangle] pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4497,6 +4632,10 @@ pub extern "C" fn UnsignedChannelUpdate_write(obj: *const UnsignedChannelUpdate) crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) }) +} +#[no_mangle] pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> UnsignedChannelUpdate { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UnsignedChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4509,6 +4648,10 @@ pub extern "C" fn ChannelUpdate_write(obj: *const ChannelUpdate) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) }) +} +#[no_mangle] pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4521,6 +4664,10 @@ pub extern "C" fn ErrorMessage_write(obj: *const ErrorMessage) -> crate::c_types crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) }) +} +#[no_mangle] pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> ErrorMessage { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ErrorMessage { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4533,6 +4680,10 @@ pub extern "C" fn UnsignedNodeAnnouncement_write(obj: *const UnsignedNodeAnnounc crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) }) +} +#[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedNodeAnnouncement { if let Ok(res) = crate::c_types::deserialize_obj(ser) { UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4545,6 +4696,10 @@ pub extern "C" fn NodeAnnouncement_write(obj: *const NodeAnnouncement) -> crate: crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) }) +} +#[no_mangle] pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement { if let Ok(res) = crate::c_types::deserialize_obj(ser) { NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -4565,6 +4720,10 @@ pub extern "C" fn QueryShortChannelIds_write(obj: *const QueryShortChannelIds) - crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) }) +} +#[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 } @@ -4577,6 +4736,10 @@ pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: *const ReplyShortChannelIds crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) +} +#[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 } @@ -4589,6 +4752,10 @@ pub extern "C" fn QueryChannelRange_write(obj: *const QueryChannelRange) -> crat crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) }) +} +#[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 } @@ -4601,6 +4768,10 @@ pub extern "C" fn ReplyChannelRange_write(obj: *const ReplyChannelRange) -> crat crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) }) +} +#[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 } @@ -4612,3 +4783,7 @@ pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> Go pub extern "C" fn GossipTimestampFilter_write(obj: *const GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } +#[no_mangle] +pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) }) +} diff --git a/lightning-c-bindings/src/ln/peer_handler.rs b/lightning-c-bindings/src/ln/peer_handler.rs index 50e1c3696..cd702ec35 100644 --- a/lightning-c-bindings/src/ln/peer_handler.rs +++ b/lightning-c-bindings/src/ln/peer_handler.rs @@ -41,7 +41,7 @@ extern "C" fn MessageHandler_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl MessageHandler { - pub(crate) fn take_ptr(mut self) -> *mut nativeMessageHandler { + pub(crate) fn take_inner(mut self) -> *mut nativeMessageHandler { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -213,7 +213,7 @@ extern "C" fn PeerHandleError_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl PeerHandleError { - pub(crate) fn take_ptr(mut self) -> *mut nativePeerHandleError { + pub(crate) fn take_inner(mut self) -> *mut nativePeerHandleError { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -278,7 +278,7 @@ extern "C" fn PeerManager_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl PeerManager { - pub(crate) fn take_ptr(mut self) -> *mut nativePeerManager { + pub(crate) fn take_inner(mut self) -> *mut nativePeerManager { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -291,7 +291,7 @@ impl PeerManager { #[must_use] #[no_mangle] pub extern "C" fn PeerManager_new(mut message_handler: crate::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, ephemeral_random_data: *const [u8; 32], mut logger: crate::util::logger::Logger) -> PeerManager { - let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_ptr()) }, our_node_secret.into_rust(), unsafe { &*ephemeral_random_data}, logger); + let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, our_node_secret.into_rust(), unsafe { &*ephemeral_random_data}, logger); PeerManager { inner: Box::into_raw(Box::new(ret)), is_owned: true } } @@ -400,6 +400,18 @@ pub extern "C" fn PeerManager_socket_disconnected(this_arg: &PeerManager, descri unsafe { &*this_arg.inner }.socket_disconnected(descriptor) } +/// Disconnect a peer given its node id. +/// +/// Set no_connection_possible to true to prevent any further connection with this peer, +/// force-closing any channels we have with it. +/// +/// If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, +/// so be careful about reentrancy issues. +#[no_mangle] +pub extern "C" fn PeerManager_disconnect_by_node_id(this_arg: &PeerManager, mut node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) { + unsafe { &*this_arg.inner }.disconnect_by_node_id(node_id.into_rust(), no_connection_possible) +} + /// This function should be called roughly once every 30 seconds. /// It will send pings to each peer and disconnect those which did not respond to the last round of pings. /// Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues! diff --git a/lightning-c-bindings/src/routing/network_graph.rs b/lightning-c-bindings/src/routing/network_graph.rs index b4c8de585..f70b2e41e 100644 --- a/lightning-c-bindings/src/routing/network_graph.rs +++ b/lightning-c-bindings/src/routing/network_graph.rs @@ -35,7 +35,7 @@ extern "C" fn NetworkGraph_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NetworkGraph { - pub(crate) fn take_ptr(mut self) -> *mut nativeNetworkGraph { + pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -75,7 +75,7 @@ extern "C" fn LockedNetworkGraph_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl LockedNetworkGraph { - pub(crate) fn take_ptr(mut self) -> *mut nativeLockedNetworkGraph { + pub(crate) fn take_inner(mut self) -> *mut nativeLockedNetworkGraph { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -117,7 +117,7 @@ extern "C" fn NetGraphMsgHandler_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NetGraphMsgHandler { - pub(crate) fn take_ptr(mut self) -> *mut nativeNetGraphMsgHandler { + pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -131,9 +131,9 @@ impl NetGraphMsgHandler { /// channel owners' keys. #[must_use] #[no_mangle] -pub extern "C" fn NetGraphMsgHandler_new(chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger) -> NetGraphMsgHandler { +pub extern "C" fn NetGraphMsgHandler_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes, chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger) -> NetGraphMsgHandler { let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(local_chain_access, logger); + let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, logger); NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true } } @@ -143,7 +143,7 @@ pub extern "C" fn NetGraphMsgHandler_new(chain_access: *mut crate::chain::Access #[no_mangle] pub extern "C" fn NetGraphMsgHandler_from_net_graph(chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger, mut network_graph: crate::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler { let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) }; - let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_ptr()) }); + let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) }); NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true } } @@ -166,6 +166,16 @@ pub extern "C" fn LockedNetworkGraph_graph(this_arg: &LockedNetworkGraph) -> cra crate::routing::network_graph::NetworkGraph { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false } } +impl From for crate::ln::msgs::RoutingMessageHandler { + fn from(obj: nativeNetGraphMsgHandler) -> Self { + let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(NetGraphMsgHandler_free_void); + ret + } +} #[no_mangle] pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: *const NetGraphMsgHandler) -> crate::ln::msgs::RoutingMessageHandler { crate::ln::msgs::RoutingMessageHandler { @@ -177,7 +187,16 @@ pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: *const N handle_htlc_fail_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update, get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements, get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements, - should_request_full_sync: NetGraphMsgHandler_RoutingMessageHandler_should_request_full_sync, + sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table, + handle_reply_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range, + handle_reply_short_channel_ids_end: NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end, + handle_query_channel_range: NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range, + handle_query_short_channel_ids: NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids, + MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: NetGraphMsgHandler_RoutingMessageHandler_get_and_clear_pending_msg_events, + }, } } use lightning::ln::msgs::RoutingMessageHandler as RoutingMessageHandlerTraitImport; @@ -215,10 +234,65 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcemen let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; local_ret.into() } +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) { + unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.sync_routing_table(&their_node_id.into_rust(), unsafe { &*init_msg.inner }) +} #[must_use] -extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_should_request_full_sync(this_arg: *const c_void, mut _node_id: crate::c_types::PublicKey) -> bool { - let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.should_request_full_sync(&_node_id.into_rust()); - ret +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_reply_channel_range(&their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_reply_short_channel_ids_end(&their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_query_channel_range(&_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) }; + local_ret +} +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut _their_node_id: crate::c_types::PublicKey, mut _msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.handle_query_short_channel_ids(&_their_node_id.into_rust(), *unsafe { Box::from_raw(_msg.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) }; + local_ret +} +use lightning::util::events::MessageSendEventsProvider as nativeMessageSendEventsProviderTrait; +#[must_use] +extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_and_clear_pending_msg_events(); + let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); }; + local_ret.into() +} + +impl From for crate::util::events::MessageSendEventsProvider { + fn from(obj: nativeNetGraphMsgHandler) -> Self { + let mut rust_obj = NetGraphMsgHandler { inner: Box::into_raw(Box::new(obj)), is_owned: true }; + let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(NetGraphMsgHandler_free_void); + ret + } +} +#[no_mangle] +pub extern "C" fn NetGraphMsgHandler_as_MessageSendEventsProvider(this_arg: *const NetGraphMsgHandler) -> crate::util::events::MessageSendEventsProvider { + crate::util::events::MessageSendEventsProvider { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + get_and_clear_pending_msg_events: NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, + } +} +use lightning::util::events::MessageSendEventsProvider as MessageSendEventsProviderTraitImport; +#[must_use] +extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { + let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_and_clear_pending_msg_events(); + let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); }; + local_ret.into() } @@ -253,7 +327,7 @@ extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl DirectionalChannelInfo { - pub(crate) fn take_ptr(mut self) -> *mut nativeDirectionalChannelInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -306,6 +380,17 @@ pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &Direct pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) { unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val; } +/// Fees charged when the channel is used for routing +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::routing::network_graph::RoutingFees { + let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees; + crate::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } +} +/// Fees charged when the channel is used for routing +#[no_mangle] +pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::routing::network_graph::RoutingFees) { + unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) }; +} /// Most recent update for the channel received from the network /// Mostly redundant with the data we store in fields explicitly. /// Everything else is useful only for sending out for initial routing sync. @@ -322,7 +407,7 @@ pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &Dire /// Not stored if contains excess data to prevent DoS. #[no_mangle] pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::ln::msgs::ChannelUpdate) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.last_update_message = local_val; } #[no_mangle] @@ -330,6 +415,10 @@ pub extern "C" fn DirectionalChannelInfo_write(obj: *const DirectionalChannelInf crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) }) +} +#[no_mangle] pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> DirectionalChannelInfo { if let Ok(res) = crate::c_types::deserialize_obj(ser) { DirectionalChannelInfo { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -369,7 +458,7 @@ extern "C" fn ChannelInfo_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelInfo { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -385,7 +474,7 @@ pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::ln: /// Protocol features of a channel communicated during its announcement #[no_mangle] pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::ln::features::ChannelFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Source node of the first direction of a channel #[no_mangle] @@ -408,7 +497,7 @@ pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::r /// Details about the first direction of a channel #[no_mangle] pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::routing::network_graph::DirectionalChannelInfo) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.one_to_two = local_val; } /// Source node of the second direction of a channel @@ -432,7 +521,7 @@ pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::r /// Details about the second direction of a channel #[no_mangle] pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::routing::network_graph::DirectionalChannelInfo) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.two_to_one = local_val; } /// An initial announcement of the channel @@ -451,7 +540,7 @@ pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) - /// Not stored if contains excess data to prevent DoS. #[no_mangle] pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInfo, mut val: crate::ln::msgs::ChannelAnnouncement) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.announcement_message = local_val; } #[no_mangle] @@ -459,6 +548,10 @@ pub extern "C" fn ChannelInfo_write(obj: *const ChannelInfo) -> crate::c_types:: crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) }) +} +#[no_mangle] pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> ChannelInfo { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelInfo { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -497,7 +590,7 @@ extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl RoutingFees { - pub(crate) fn take_ptr(mut self) -> *mut nativeRoutingFees { + pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -565,6 +658,10 @@ pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> RoutingFees pub extern "C" fn RoutingFees_write(obj: *const RoutingFees) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } +#[no_mangle] +pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) }) +} use lightning::routing::network_graph::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport; type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport; @@ -596,7 +693,7 @@ extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NodeAnnouncementInfo { - pub(crate) fn take_ptr(mut self) -> *mut nativeNodeAnnouncementInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -612,7 +709,7 @@ pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementI /// Protocol features the node announced support for #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::features::NodeFeatures) { - unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// When the last known update to the node state was issued. /// Value is opaque, as set in the announcement. @@ -675,16 +772,16 @@ pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeA /// Not stored if contains excess data to prevent DoS. #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::msgs::NodeAnnouncement) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.announcement_message = local_val; } #[must_use] #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::c_types::ThirtyTwoBytes, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; - let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_ptr()) } }) }; + let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo { - features: *unsafe { Box::from_raw(features_arg.take_ptr()) }, + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, last_update: last_update_arg, rgb: rgb_arg.data, alias: alias_arg.data, @@ -697,6 +794,10 @@ pub extern "C" fn NodeAnnouncementInfo_write(obj: *const NodeAnnouncementInfo) - crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) }) +} +#[no_mangle] pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> NodeAnnouncementInfo { if let Ok(res) = crate::c_types::deserialize_obj(ser) { NodeAnnouncementInfo { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -735,7 +836,7 @@ extern "C" fn NodeInfo_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl NodeInfo { - pub(crate) fn take_ptr(mut self) -> *mut nativeNodeInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -762,7 +863,7 @@ pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) /// meaning they don't have to refer to the same channel. #[no_mangle] pub extern "C" fn NodeInfo_set_lowest_inbound_channel_fees(this_ptr: &mut NodeInfo, mut val: crate::routing::network_graph::RoutingFees) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.lowest_inbound_channel_fees = local_val; } /// More information about a node from node_announcement. @@ -779,15 +880,15 @@ pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate:: /// a channel announcement, but before receiving a node announcement. #[no_mangle] pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::routing::network_graph::NodeAnnouncementInfo) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) }; + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.announcement_info = local_val; } #[must_use] #[no_mangle] pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut lowest_inbound_channel_fees_arg: crate::routing::network_graph::RoutingFees, mut announcement_info_arg: crate::routing::network_graph::NodeAnnouncementInfo) -> NodeInfo { let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); }; - let mut local_lowest_inbound_channel_fees_arg = if lowest_inbound_channel_fees_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(lowest_inbound_channel_fees_arg.take_ptr()) } }) }; - let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_ptr()) } }) }; + let mut local_lowest_inbound_channel_fees_arg = if lowest_inbound_channel_fees_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(lowest_inbound_channel_fees_arg.take_inner()) } }) }; + let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_inner()) } }) }; NodeInfo { inner: Box::into_raw(Box::new(nativeNodeInfo { channels: local_channels_arg, lowest_inbound_channel_fees: local_lowest_inbound_channel_fees_arg, @@ -799,6 +900,10 @@ pub extern "C" fn NodeInfo_write(obj: *const NodeInfo) -> crate::c_types::derive crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) }) +} +#[no_mangle] pub extern "C" fn NodeInfo_read(ser: crate::c_types::u8slice) -> NodeInfo { if let Ok(res) = crate::c_types::deserialize_obj(ser) { NodeInfo { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -811,6 +916,10 @@ pub extern "C" fn NetworkGraph_write(obj: *const NetworkGraph) -> crate::c_types crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) }) +} +#[no_mangle] pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> NetworkGraph { if let Ok(res) = crate::c_types::deserialize_obj(ser) { NetworkGraph { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -821,8 +930,8 @@ pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice) -> NetworkGrap /// Creates a new, empty, network graph. #[must_use] #[no_mangle] -pub extern "C" fn NetworkGraph_new() -> crate::routing::network_graph::NetworkGraph { - let mut ret = lightning::routing::network_graph::NetworkGraph::new(); +pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes) -> crate::routing::network_graph::NetworkGraph { + let mut ret = lightning::routing::network_graph::NetworkGraph::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap()); crate::routing::network_graph::NetworkGraph { inner: Box::into_raw(Box::new(ret)), is_owned: true } } diff --git a/lightning-c-bindings/src/routing/router.rs b/lightning-c-bindings/src/routing/router.rs index 8be952833..47f89af45 100644 --- a/lightning-c-bindings/src/routing/router.rs +++ b/lightning-c-bindings/src/routing/router.rs @@ -38,7 +38,7 @@ extern "C" fn RouteHop_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl RouteHop { - pub(crate) fn take_ptr(mut self) -> *mut nativeRouteHop { + pub(crate) fn take_inner(mut self) -> *mut nativeRouteHop { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -84,7 +84,7 @@ pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::ln:: /// amended to match the features present in the invoice this node generated. #[no_mangle] pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::ln::features::NodeFeatures) { - unsafe { &mut *this_ptr.inner }.node_features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.node_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The channel that should be used from the previous hop to reach this node. #[no_mangle] @@ -108,7 +108,7 @@ pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::l /// to reach this node. #[no_mangle] pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::ln::features::ChannelFeatures) { - unsafe { &mut *this_ptr.inner }.channel_features = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.channel_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The fee taken on this hop. For the last hop, this should be the full value of the payment. #[no_mangle] @@ -139,9 +139,9 @@ pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut va pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32) -> RouteHop { RouteHop { inner: Box::into_raw(Box::new(nativeRouteHop { pubkey: pubkey_arg.into_rust(), - node_features: *unsafe { Box::from_raw(node_features_arg.take_ptr()) }, + node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) }, short_channel_id: short_channel_id_arg, - channel_features: *unsafe { Box::from_raw(channel_features_arg.take_ptr()) }, + channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) }, fee_msat: fee_msat_arg, cltv_expiry_delta: cltv_expiry_delta_arg, })), is_owned: true } @@ -178,7 +178,7 @@ extern "C" fn Route_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl Route { - pub(crate) fn take_ptr(mut self) -> *mut nativeRoute { + pub(crate) fn take_inner(mut self) -> *mut nativeRoute { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -210,13 +210,13 @@ pub extern "C" fn Route_clone(orig: &Route) -> Route { /// ensure it is viable. #[no_mangle] pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_CVec_RouteHopZZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; local_val_0 }); }; + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_val_0 }); }; unsafe { &mut *this_ptr.inner }.paths = local_val; } #[must_use] #[no_mangle] pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ) -> Route { - let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { let mut local_paths_arg_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_paths_arg_0.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); }; local_paths_arg_0 }); }; + let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { let mut local_paths_arg_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_paths_arg_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_paths_arg_0 }); }; Route { inner: Box::into_raw(Box::new(nativeRoute { paths: local_paths_arg, })), is_owned: true } @@ -226,6 +226,10 @@ pub extern "C" fn Route_write(obj: *const Route) -> crate::c_types::derived::CVe crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) }) +} +#[no_mangle] pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> Route { if let Ok(res) = crate::c_types::deserialize_obj(ser) { Route { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -264,7 +268,7 @@ extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl RouteHint { - pub(crate) fn take_ptr(mut self) -> *mut nativeRouteHint { + pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -319,7 +323,7 @@ pub extern "C" fn RouteHint_get_fees(this_ptr: &RouteHint) -> crate::routing::ne /// The fees which must be paid to use this channel #[no_mangle] pub extern "C" fn RouteHint_set_fees(this_ptr: &mut RouteHint, mut val: crate::routing::network_graph::RoutingFees) { - unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.fees = *unsafe { Box::from_raw(val.take_inner()) }; } /// The difference in CLTV values between this node and the next node. #[no_mangle] @@ -349,7 +353,7 @@ pub extern "C" fn RouteHint_new(mut src_node_id_arg: crate::c_types::PublicKey, RouteHint { inner: Box::into_raw(Box::new(nativeRouteHint { src_node_id: src_node_id_arg.into_rust(), short_channel_id: short_channel_id_arg, - fees: *unsafe { Box::from_raw(fees_arg.take_ptr()) }, + fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, cltv_expiry_delta: cltv_expiry_delta_arg, htlc_minimum_msat: htlc_minimum_msat_arg, })), is_owned: true } diff --git a/lightning-c-bindings/src/util/config.rs b/lightning-c-bindings/src/util/config.rs index 346ddc344..a9bcd6aee 100644 --- a/lightning-c-bindings/src/util/config.rs +++ b/lightning-c-bindings/src/util/config.rs @@ -38,7 +38,7 @@ extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelHandshakeConfig { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelHandshakeConfig { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -192,7 +192,7 @@ extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelHandshakeLimits { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelHandshakeLimits { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -465,7 +465,7 @@ extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl ChannelConfig { - pub(crate) fn take_ptr(mut self) -> *mut nativeChannelConfig { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -589,6 +589,10 @@ pub extern "C" fn ChannelConfig_write(obj: *const ChannelConfig) -> crate::c_typ crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) } #[no_mangle] +pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) }) +} +#[no_mangle] pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> ChannelConfig { if let Ok(res) = crate::c_types::deserialize_obj(ser) { ChannelConfig { inner: Box::into_raw(Box::new(res)), is_owned: true } @@ -630,7 +634,7 @@ extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) { #[allow(unused)] /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy impl UserConfig { - pub(crate) fn take_ptr(mut self) -> *mut nativeUserConfig { + pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig { assert!(self.is_owned); let ret = self.inner; self.inner = std::ptr::null_mut(); @@ -663,7 +667,7 @@ pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> cr /// Channel config that we propose to our counterparty. #[no_mangle] pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelHandshakeConfig) { - unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_inner()) }; } /// Limits applied to our counterparty's proposed channel config settings. #[no_mangle] @@ -674,7 +678,7 @@ pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfi /// Limits applied to our counterparty's proposed channel config settings. #[no_mangle] pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelHandshakeLimits) { - unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_inner()) }; } /// Channel config which affects behavior during channel lifetime. #[no_mangle] @@ -685,15 +689,15 @@ pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate /// Channel config which affects behavior during channel lifetime. #[no_mangle] pub extern "C" fn UserConfig_set_channel_options(this_ptr: &mut UserConfig, mut val: crate::util::config::ChannelConfig) { - unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_ptr()) }; + unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_inner()) }; } #[must_use] #[no_mangle] pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::util::config::ChannelConfig) -> UserConfig { UserConfig { inner: Box::into_raw(Box::new(nativeUserConfig { - own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_ptr()) }, - peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_ptr()) }, - channel_options: *unsafe { Box::from_raw(channel_options_arg.take_ptr()) }, + own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) }, + peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) }, + channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) }, })), is_owned: true } } #[must_use] diff --git a/lightning-c-bindings/src/util/events.rs b/lightning-c-bindings/src/util/events.rs index e596774b6..eef634762 100644 --- a/lightning-c-bindings/src/util/events.rs +++ b/lightning-c-bindings/src/util/events.rs @@ -100,7 +100,7 @@ impl Event { let mut funding_txo_nonref = (*funding_txo).clone(); let mut user_channel_id_nonref = (*user_channel_id).clone(); nativeEvent::FundingBroadcastSafe { - funding_txo: *unsafe { Box::from_raw(funding_txo_nonref.take_ptr()) }, + funding_txo: *unsafe { Box::from_raw(funding_txo_nonref.take_inner()) }, user_channel_id: user_channel_id_nonref, } }, @@ -157,7 +157,7 @@ impl Event { }, Event::FundingBroadcastSafe {mut funding_txo, mut user_channel_id, } => { nativeEvent::FundingBroadcastSafe { - funding_txo: *unsafe { Box::from_raw(funding_txo.take_ptr()) }, + funding_txo: *unsafe { Box::from_raw(funding_txo.take_inner()) }, user_channel_id: user_channel_id, } }, @@ -407,6 +407,17 @@ pub enum MessageSendEvent { PaymentFailureNetworkUpdate { update: crate::ln::msgs::HTLCFailChannelUpdate, }, + /// Query a peer for channels with funding transaction UTXOs in a block range. + SendChannelRangeQuery { + node_id: crate::c_types::PublicKey, + msg: crate::ln::msgs::QueryChannelRange, + }, + /// Request routing gossip messages from a peer for a list of channels identified by + /// their short_channel_ids. + SendShortIdsQuery { + node_id: crate::c_types::PublicKey, + msg: crate::ln::msgs::QueryShortChannelIds, + }, } use lightning::util::events::MessageSendEvent as nativeMessageSendEvent; impl MessageSendEvent { @@ -418,7 +429,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendAcceptChannel { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { @@ -426,7 +437,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendOpenChannel { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { @@ -434,7 +445,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendFundingCreated { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { @@ -442,7 +453,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendFundingSigned { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => { @@ -450,7 +461,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendFundingLocked { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { @@ -458,7 +469,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendAnnouncementSignatures { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { @@ -466,7 +477,7 @@ impl MessageSendEvent { let mut updates_nonref = (*updates).clone(); nativeMessageSendEvent::UpdateHTLCs { node_id: node_id_nonref.into_rust(), - updates: *unsafe { Box::from_raw(updates_nonref.take_ptr()) }, + updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) }, } }, MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { @@ -474,7 +485,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendRevokeAndACK { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { @@ -482,7 +493,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendClosingSigned { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendShutdown {ref node_id, ref msg, } => { @@ -490,7 +501,7 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendShutdown { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { @@ -498,27 +509,27 @@ impl MessageSendEvent { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::SendChannelReestablish { node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { let mut msg_nonref = (*msg).clone(); let mut update_msg_nonref = (*update_msg).clone(); nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, - update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) }, } }, MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::BroadcastChannelUpdate {ref msg, } => { let mut msg_nonref = (*msg).clone(); nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, MessageSendEvent::HandleError {ref node_id, ref action, } => { @@ -535,6 +546,22 @@ impl MessageSendEvent { update: update_nonref.into_native(), } }, + MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendChannelRangeQuery { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendShortIdsQuery { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, } } #[allow(unused)] @@ -543,83 +570,83 @@ impl MessageSendEvent { MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { nativeMessageSendEvent::SendAcceptChannel { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { nativeMessageSendEvent::SendOpenChannel { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { nativeMessageSendEvent::SendFundingCreated { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { nativeMessageSendEvent::SendFundingSigned { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => { nativeMessageSendEvent::SendFundingLocked { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { nativeMessageSendEvent::SendAnnouncementSignatures { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { nativeMessageSendEvent::UpdateHTLCs { node_id: node_id.into_rust(), - updates: *unsafe { Box::from_raw(updates.take_ptr()) }, + updates: *unsafe { Box::from_raw(updates.take_inner()) }, } }, MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { nativeMessageSendEvent::SendRevokeAndACK { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { nativeMessageSendEvent::SendClosingSigned { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendShutdown {mut node_id, mut msg, } => { nativeMessageSendEvent::SendShutdown { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { nativeMessageSendEvent::SendChannelReestablish { node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, - update_msg: *unsafe { Box::from_raw(update_msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) }, } }, MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::BroadcastChannelUpdate {mut msg, } => { nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg.take_ptr()) }, + msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, MessageSendEvent::HandleError {mut node_id, mut action, } => { @@ -633,6 +660,18 @@ impl MessageSendEvent { update: update.into_native(), } }, + MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelRangeQuery { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendShortIdsQuery { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, } } #[allow(unused)] @@ -760,6 +799,22 @@ impl MessageSendEvent { update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref), } }, + nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendChannelRangeQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendShortIdsQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, } } #[allow(unused)] @@ -858,6 +913,18 @@ impl MessageSendEvent { update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update), } }, + nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelRangeQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { + MessageSendEvent::SendShortIdsQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, } } } diff --git a/lightning-c-bindings/src/util/ser.rs b/lightning-c-bindings/src/util/ser.rs index deb9383ae..db9549c65 100644 --- a/lightning-c-bindings/src/util/ser.rs +++ b/lightning-c-bindings/src/util/ser.rs @@ -5,3 +5,6 @@ use std::ffi::c_void; use bitcoin::hashes::Hash; use crate::c_types::*; + +#[no_mangle] +pub static MAX_BUF_SIZE: usize = lightning::util::ser::MAX_BUF_SIZE; -- 2.39.5