From: Matt Corallo Date: Mon, 26 Apr 2021 15:49:44 +0000 (+0000) Subject: Update auto-generated bindings to latest upstream X-Git-Tag: v0.0.98~11^2~3 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=2d97d367136737b0a3bcda1312354aa37f9f215c;p=ldk-c-bindings Update auto-generated bindings to latest upstream --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 7d09159..4ae3d0b 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -6853,10 +6853,13 @@ typedef struct LDKAccess { } LDKAccess; /** - * The `Listen` trait is used to be notified of when blocks have been connected or disconnected - * from the chain. + * The `Listen` trait is used to notify when blocks have been connected or disconnected from the + * chain. * - * Useful when needing to replay chain data upon startup or as new chain events occur. + * Useful when needing to replay chain data upon startup or as new chain events occur. Clients + * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. + * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers + * when needed. */ typedef struct LDKListen { /** @@ -6879,6 +6882,103 @@ typedef struct LDKListen { void (*free)(void *this_arg); } LDKListen; +/** + * The `Confirm` trait is used to notify when transactions have been confirmed on chain or + * unconfirmed during a chain reorganization. + * + * Clients sourcing chain data using a transaction-oriented API should prefer this interface over + * [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity + * related to registered transactions and outputs. Upon notification, it would pass along the + * matching transactions using this interface. + * + * # Use + * + * The intended use is as follows: + * - Call [`transactions_confirmed`] to process any on-chain activity of interest. + * - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`] + * that has been reorganized out of the chain. + * - Call [`best_block_updated`] whenever a new chain tip becomes available. + * + * # Order + * + * Clients must call these methods in chain order. Specifically: + * - Transactions confirmed in a block must be given before transactions confirmed in a later + * block. + * - Dependent transactions within the same block must be given in topological order, possibly in + * separate calls. + * - Unconfirmed transactions must be given after the original confirmations and before any + * reconfirmation. + * + * See individual method documentation for further details. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * [`best_block_updated`]: Self::best_block_updated + * [`get_relevant_txids`]: Self::get_relevant_txids + */ +typedef struct LDKConfirm { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Processes transactions confirmed in a block with a given header and height. + * + * Should be called for any transactions registered by [`Filter::register_tx`] or any + * transactions spending an output registered by [`Filter::register_output`]. Such transactions + * appearing in the same block do not need to be included in the same call; instead, multiple + * calls with additional transactions may be made so long as they are made in [chain order]. + * + * May be called before or after [`best_block_updated`] for the corresponding block. However, + * in the event of a chain reorganization, it must not be called with a `header` that is no + * longer in the chain as of the last call to [`best_block_updated`]. + * + * [chain order]: Self#order + * [`best_block_updated`]: Self::best_block_updated + */ + void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + /** + * Processes a transaction that is no longer confirmed as result of a chain reorganization. + * + * Should be called for any transaction returned by [`get_relevant_txids`] if it has been + * reorganized out of the best chain. Once called, the given transaction should not be returned + * by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`]. + * + * [`get_relevant_txids`]: Self::get_relevant_txids + * [`transactions_confirmed`]: Self::transactions_confirmed + */ + void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); + /** + * Processes an update to the best header connected at the given height. + * + * Should be called when a new header is available but may be skipped for intermediary blocks + * if they become available at the same time. + */ + void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + /** + * Returns transactions that should be monitored for reorganization out of the chain. + * + * Should include any transactions passed to [`transactions_confirmed`] that have insufficient + * confirmations to be safe from a chain reorganization. Should not include any transactions + * passed to [`transaction_unconfirmed`] unless later reconfirmed. + * + * May be called to determine the subset of transactions that must still be monitored for + * reorganization. Will be idempotent between calls but may change as a result of calls to the + * other interface methods. Thus, this is useful to determine which transactions may need to be + * given to [`transaction_unconfirmed`]. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + */ + struct LDKCVec_TxidZ (*get_relevant_txids)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKConfirm; + /** @@ -10290,6 +10390,11 @@ void Access_free(struct LDKAccess this_ptr); */ void Listen_free(struct LDKListen this_ptr); +/** + * Calls the free function if one is set + */ +void Confirm_free(struct LDKConfirm this_ptr); + /** * Calls the free function if one is set */ @@ -10360,79 +10465,6 @@ void FeeEstimator_free(struct LDKFeeEstimator this_ptr); */ void ChainMonitor_free(struct LDKChainMonitor this_obj); -/** - * Dispatches to per-channel monitors, which are responsible for updating their on-chain view - * of a channel and reacting accordingly based on transactions in the connected block. See - * [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will - * be returned by [`chain::Watch::release_pending_monitor_events`]. - * - * Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent - * calls must not exclude any transactions matching the new outputs nor any in-block - * descendants of such transactions. It is not necessary to re-fetch the block to obtain - * updated `txdata`. - */ -void ChainMonitor_block_connected(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); - -/** - * Dispatches to per-channel monitors, which are responsible for updating their on-chain view - * of a channel and reacting accordingly to newly confirmed transactions. For details, see - * [`ChannelMonitor::transactions_confirmed`]. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. May be called before or after [`update_best_block`] for transactions in the - * corresponding block. See [`update_best_block`] for further calling expectations. - * - * [`block_connected`]: Self::block_connected - * [`update_best_block`]: Self::update_best_block - */ -void ChainMonitor_transactions_confirmed(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); - -/** - * Dispatches to per-channel monitors, which are responsible for updating their on-chain view - * of a channel and reacting accordingly based on the new chain tip. For details, see - * [`ChannelMonitor::update_best_block`]. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. May be called before or after [`transactions_confirmed`] for the corresponding - * block. - * - * Must be called after new blocks become available for the most recent block. Intermediary - * blocks, however, may be safely skipped. In the event of a chain re-organization, this only - * needs to be called for the most recent block assuming `transaction_unconfirmed` is called - * for any affected transactions. - * - * [`block_connected`]: Self::block_connected - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - */ -void ChainMonitor_update_best_block(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height); - -/** - * Dispatches to per-channel monitors, which are responsible for updating their on-chain view - * of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for - * details. - */ -void ChainMonitor_block_disconnected(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t disconnected_height); - -/** - * Dispatches to per-channel monitors, which are responsible for updating their on-chain view - * of a channel based on transactions unconfirmed as a result of a chain reorganization. See - * [`ChannelMonitor::transaction_unconfirmed`] for details. - * - * Used instead of [`block_disconnected`] by clients that are notified of transactions rather - * than blocks. May be called before or after [`update_best_block`] for transactions in the - * corresponding block. See [`update_best_block`] for further calling expectations. - * - * [`block_disconnected`]: Self::block_disconnected - * [`update_best_block`]: Self::update_best_block - */ -void ChainMonitor_transaction_unconfirmed(const struct LDKChainMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32]); - -/** - * Returns the set of txids that should be monitored for re-organization out of the chain. - */ -MUST_USE_RES struct LDKCVec_TxidZ ChainMonitor_get_relevant_txids(const struct LDKChainMonitor *NONNULL_PTR this_arg); - /** * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. * @@ -10648,11 +10680,9 @@ void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_P * outputs to watch. See [`block_connected`] for details. * * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. May be called before or after [`update_best_block`] for transactions in the - * corresponding block. See [`update_best_block`] for further calling expectations. + * blocks. See [`chain::Confirm`] for calling expectations. * * [`block_connected`]: Self::block_connected - * [`update_best_block`]: Self::update_best_block */ MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); @@ -10660,11 +10690,9 @@ MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_conf * Processes a transaction that was reorganized out of the chain. * * Used instead of [`block_disconnected`] by clients that are notified of transactions rather - * than blocks. May be called before or after [`update_best_block`] for transactions in the - * corresponding block. See [`update_best_block`] for further calling expectations. + * than blocks. See [`chain::Confirm`] for calling expectations. * * [`block_disconnected`]: Self::block_disconnected - * [`update_best_block`]: Self::update_best_block */ void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); @@ -10673,19 +10701,11 @@ void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONN * [`block_connected`] for details. * * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. May be called before or after [`transactions_confirmed`] for the corresponding - * block. - * - * Must be called after new blocks become available for the most recent block. Intermediary - * blocks, however, may be safely skipped. In the event of a chain re-organization, this only - * needs to be called for the most recent block assuming `transaction_unconfirmed` is called - * for any affected transactions. + * blocks. See [`chain::Confirm`] for calling expectations. * * [`block_connected`]: Self::block_connected - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_update_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** * Returns the set of txids that should be monitored for re-organization out of the chain. @@ -11608,83 +11628,10 @@ struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChanne struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Updates channel state to take note of transactions which were confirmed in the given block - * at the given height. - * - * Note that you must still call (or have called) [`update_best_block`] with the block - * information which is included here. - * - * This method may be called before or after [`update_best_block`] for a given block's - * transaction data and may be called multiple times with additional transaction data for a - * given block. - * - * This method may be called for a previous block after an [`update_best_block`] call has - * been made for a later block, however it must *not* be called with transaction data from a - * block which is no longer in the best chain (ie where [`update_best_block`] has already - * been informed about a blockchain reorganization which no longer includes the block which - * corresponds to `header`). - * - * [`update_best_block`]: `Self::update_best_block` - */ -void ChannelManager_transactions_confirmed(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKCVec_C2Tuple_usizeTransactionZZ txdata); - -/** - * Updates channel state with the current best blockchain tip. You should attempt to call this - * quickly after a new block becomes available, however if multiple new blocks become - * available at the same time, only a single `update_best_block()` call needs to be made. - * - * This method should also be called immediately after any block disconnections, once at the - * reorganization fork point, and once with the new chain tip. Calling this method at the - * blockchain reorganization fork point ensures we learn when a funding transaction which was - * previously confirmed is reorganized out of the blockchain, ensuring we do not continue to - * accept payments which cannot be enforced on-chain. - * - * In both the block-connection and block-disconnection case, this method may be called either - * once per block connected or disconnected, or simply at the fork point and new tip(s), - * skipping any intermediary blocks. - */ -void ChannelManager_update_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height); - -/** - * Gets the set of txids which should be monitored for their confirmation state. - * - * If you're providing information about reorganizations via [`transaction_unconfirmed`], this - * is the set of transactions which you may need to call [`transaction_unconfirmed`] for. - * - * This may be useful to poll to determine the set of transactions which must be registered - * with an Electrum server or for which an Electrum server needs to be polled to determine - * transaction confirmation state. - * - * This may update after any [`transactions_confirmed`] or [`block_connected`] call. - * - * Note that this is NOT the set of transactions which must be included in calls to - * [`transactions_confirmed`] if they are confirmed, but a small subset of it. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - * [`block_connected`]: chain::Listen::block_connected - */ -MUST_USE_RES struct LDKCVec_TxidZ ChannelManager_get_relevant_txids(const struct LDKChannelManager *NONNULL_PTR this_arg); - -/** - * Marks a transaction as having been reorganized out of the blockchain. - * - * If a transaction is included in [`get_relevant_txids`], and is no longer in the main branch - * of the blockchain, this function should be called to indicate that the transaction should - * be considered reorganized out. - * - * Once this is called, the given transaction will no longer appear on [`get_relevant_txids`], - * though this may be called repeatedly for a given transaction without issue. - * - * Note that if the transaction is confirmed on the main chain in a different block (indicated - * via a call to [`transactions_confirmed`]), it may re-appear in [`get_relevant_txids`], thus - * be very wary of race-conditions wherein the final state of a transaction indicated via - * these APIs is not the same as its state on the blockchain. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`get_relevant_txids`]: Self::get_relevant_txids + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -void ChannelManager_transaction_unconfirmed(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*txid)[32]); +struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); /** * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index a40d840..269e76a 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -567,6 +567,21 @@ public: const LDKListen* operator &() const { return &self; } const LDKListen* operator ->() const { return &self; } }; +class Confirm { +private: + LDKConfirm self; +public: + Confirm(const Confirm&) = delete; + Confirm(Confirm&& o) : self(o.self) { memset(&o, 0, sizeof(Confirm)); } + Confirm(LDKConfirm&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKConfirm)); } + operator LDKConfirm() && { LDKConfirm res = self; memset(&self, 0, sizeof(LDKConfirm)); return res; } + ~Confirm() { Confirm_free(self); } + Confirm& operator=(Confirm&& o) { Confirm_free(self); self = o.self; memset(&o, 0, sizeof(Confirm)); return *this; } + LDKConfirm* operator &() { return &self; } + LDKConfirm* operator ->() { return &self; } + const LDKConfirm* operator &() const { return &self; } + const LDKConfirm* operator ->() const { return &self; } +}; class Watch { private: LDKWatch self; diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index 9b8e84b..5450998 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -34,8 +34,7 @@ unsafe impl Send for BroadcasterInterface {} use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface; impl rustBroadcasterInterface for BroadcasterInterface { fn broadcast_transaction(&self, tx: &bitcoin::blockdata::transaction::Transaction) { - let mut local_tx = ::bitcoin::consensus::encode::serialize(tx); - (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_tx)) + (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(tx)) } } diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index 3e237df..c66edd7 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -79,90 +79,6 @@ impl ChainMonitor { ret } } -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel and reacting accordingly based on transactions in the connected block. See -/// [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will -/// be returned by [`chain::Watch::release_pending_monitor_events`]. -/// -/// Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent -/// calls must not exclude any transactions matching the new outputs nor any in-block -/// descendants of such transactions. It is not necessary to re-fetch the block to obtain -/// updated `txdata`. -#[no_mangle] -pub extern "C" fn ChainMonitor_block_connected(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel and reacting accordingly to newly confirmed transactions. For details, see -/// [`ChannelMonitor::transactions_confirmed`]. -/// -/// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. -/// -/// [`block_connected`]: Self::block_connected -/// [`update_best_block`]: Self::update_best_block -#[no_mangle] -pub extern "C" fn ChainMonitor_transactions_confirmed(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel and reacting accordingly based on the new chain tip. For details, see -/// [`ChannelMonitor::update_best_block`]. -/// -/// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`transactions_confirmed`] for the corresponding -/// block. -/// -/// Must be called after new blocks become available for the most recent block. Intermediary -/// blocks, however, may be safely skipped. In the event of a chain re-organization, this only -/// needs to be called for the most recent block assuming `transaction_unconfirmed` is called -/// for any affected transactions. -/// -/// [`block_connected`]: Self::block_connected -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed -#[no_mangle] -pub extern "C" fn ChainMonitor_update_best_block(this_arg: &ChainMonitor, header: *const [u8; 80], mut height: u32) { - unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for -/// details. -#[no_mangle] -pub extern "C" fn ChainMonitor_block_disconnected(this_arg: &ChainMonitor, header: *const [u8; 80], mut disconnected_height: u32) { - unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), disconnected_height) -} - -/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view -/// of a channel based on transactions unconfirmed as a result of a chain reorganization. See -/// [`ChannelMonitor::transaction_unconfirmed`] for details. -/// -/// Used instead of [`block_disconnected`] by clients that are notified of transactions rather -/// than blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. -/// -/// [`block_disconnected`]: Self::block_disconnected -/// [`update_best_block`]: Self::update_best_block -#[no_mangle] -pub extern "C" fn ChainMonitor_transaction_unconfirmed(this_arg: &ChainMonitor, txid: *const [u8; 32]) { - unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) -} - -/// Returns the set of txids that should be monitored for re-organization out of the chain. -#[must_use] -#[no_mangle] -pub extern "C" fn ChainMonitor_get_relevant_txids(this_arg: &ChainMonitor) -> crate::c_types::derived::CVec_TxidZ { - let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; - local_ret.into() -} - /// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. /// /// When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index 2c4c5c3..e145f3d 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -83,7 +83,7 @@ impl ChannelMonitorUpdate { #[no_mangle] pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_id; - (*inner_val) + *inner_val } /// The sequence number of this update. Updates *must* be replayed in-order according to this /// sequence number (and updates may panic if they are not). The update_id values are strictly @@ -632,7 +632,7 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &Channel #[no_mangle] pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &ChannelMonitor, logger: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ { let mut ret = unsafe { &*this_arg.inner }.get_latest_holder_commitment_txn(logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::Transaction::from_bitcoin(&item) }); }; local_ret.into() } @@ -667,11 +667,9 @@ pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, h /// outputs to watch. See [`block_connected`] for details. /// /// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. +/// blocks. See [`chain::Confirm`] for calling expectations. /// /// [`block_connected`]: Self::block_connected -/// [`update_best_block`]: Self::update_best_block #[must_use] #[no_mangle] pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { @@ -684,11 +682,9 @@ pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &ChannelMonito /// Processes a transaction that was reorganized out of the chain. /// /// Used instead of [`block_disconnected`] by clients that are notified of transactions rather -/// than blocks. May be called before or after [`update_best_block`] for transactions in the -/// corresponding block. See [`update_best_block`] for further calling expectations. +/// than blocks. See [`chain::Confirm`] for calling expectations. /// /// [`block_disconnected`]: Self::block_disconnected -/// [`update_best_block`]: Self::update_best_block #[no_mangle] pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &ChannelMonitor, txid: *const [u8; 32], mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) { unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), broadcaster, fee_estimator, logger) @@ -698,21 +694,13 @@ pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &ChannelMonit /// [`block_connected`] for details. /// /// Used instead of [`block_connected`] by clients that are notified of transactions rather than -/// blocks. May be called before or after [`transactions_confirmed`] for the corresponding -/// block. -/// -/// Must be called after new blocks become available for the most recent block. Intermediary -/// blocks, however, may be safely skipped. In the event of a chain re-organization, this only -/// needs to be called for the most recent block assuming `transaction_unconfirmed` is called -/// for any affected transactions. +/// blocks. See [`chain::Confirm`] for calling expectations. /// /// [`block_connected`]: Self::block_connected -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_update_best_block(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { - let mut ret = unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger); +pub extern "C" fn ChannelMonitor_best_block_updated(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { + let mut ret = unsafe { &*this_arg.inner }.best_block_updated(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs index dae2a63..09c70f4 100644 --- a/lightning-c-bindings/src/lightning/chain/keysinterface.rs +++ b/lightning-c-bindings/src/lightning/chain/keysinterface.rs @@ -64,7 +64,7 @@ impl DelayedPaymentOutputDescriptor { #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The outpoint which is spendable #[no_mangle] @@ -75,7 +75,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut Del #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Per commitment point to derive delayed_payment_key by key holder #[no_mangle] @@ -87,7 +87,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_p #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; - (*inner_val) + *inner_val } /// The nSequence value which must be set in the spending input to satisfy the OP_CSV in /// the witness_script. @@ -105,7 +105,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut Delay #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The revocation point specific to the commitment transaction which was broadcast. Used to /// derive the witnessScript for this output. @@ -119,7 +119,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id; - &(*inner_val) + inner_val } /// Arbitrary identification information returned by a call to /// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in @@ -132,7 +132,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: & #[no_mangle] pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; - (*inner_val) + *inner_val } /// The value of the channel which this output originated from, possibly indirectly. #[no_mangle] @@ -222,7 +222,7 @@ impl StaticPaymentOutputDescriptor { #[no_mangle] pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The outpoint which is spendable #[no_mangle] @@ -240,7 +240,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut Static #[no_mangle] pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id; - &(*inner_val) + inner_val } /// Arbitrary identification information returned by a call to /// `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in @@ -253,7 +253,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &m #[no_mangle] pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; - (*inner_val) + *inner_val } /// The value of the channel which this transactions spends. #[no_mangle] @@ -630,21 +630,18 @@ impl rustBaseSign for BaseSign { 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::lightning::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 ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(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(<*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::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false }); + let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::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(<*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 ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(closing_tx)); 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 } @@ -731,21 +728,18 @@ impl lightning::chain::keysinterface::BaseSign for Sign { 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::lightning::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.BaseSign.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 ret = (self.BaseSign.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(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(<*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.BaseSign.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::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false }); + let mut ret = (self.BaseSign.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::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(<*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.BaseSign.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_closing_tx)); + let mut ret = (self.BaseSign.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(closing_tx)); 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 } @@ -958,7 +952,7 @@ impl InMemorySigner { #[no_mangle] pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_key; - (*inner_val).as_ref() + inner_val.as_ref() } /// Private key of anchor tx #[no_mangle] @@ -969,7 +963,7 @@ pub extern "C" fn InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, #[no_mangle] pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_base_key; - (*inner_val).as_ref() + inner_val.as_ref() } /// Holder secret key for blinded revocation pubkey #[no_mangle] @@ -980,7 +974,7 @@ pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemory #[no_mangle] pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key; - (*inner_val).as_ref() + inner_val.as_ref() } /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions #[no_mangle] @@ -991,7 +985,7 @@ pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, #[no_mangle] pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_base_key; - (*inner_val).as_ref() + inner_val.as_ref() } /// Holder secret key used in HTLC tx #[no_mangle] @@ -1002,7 +996,7 @@ pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InM #[no_mangle] pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_base_key; - (*inner_val).as_ref() + inner_val.as_ref() } /// Holder htlc secret key used in commitment tx htlc outputs #[no_mangle] @@ -1013,7 +1007,7 @@ pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner #[no_mangle] pub extern "C" fn InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_seed; - &(*inner_val) + inner_val } /// Commitment seed #[no_mangle] @@ -1417,7 +1411,7 @@ pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &KeysManager, mu let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; let mut ret = unsafe { &*this_arg.inner }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&o); crate::c_types::Transaction::from_vec(local_ret_0) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index adc5984..64f548d 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -111,10 +111,13 @@ impl Drop for Access { } } } -/// The `Listen` trait is used to be notified of when blocks have been connected or disconnected -/// from the chain. +/// The `Listen` trait is used to notify when blocks have been connected or disconnected from the +/// chain. /// -/// Useful when needing to replay chain data upon startup or as new chain events occur. +/// Useful when needing to replay chain data upon startup or as new chain events occur. Clients +/// sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. +/// Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers +/// when needed. #[repr(C)] pub struct Listen { /// An opaque pointer which is passed to your function implementations as an argument. @@ -159,6 +162,130 @@ impl Drop for Listen { } } } +/// The `Confirm` trait is used to notify when transactions have been confirmed on chain or +/// unconfirmed during a chain reorganization. +/// +/// Clients sourcing chain data using a transaction-oriented API should prefer this interface over +/// [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity +/// related to registered transactions and outputs. Upon notification, it would pass along the +/// matching transactions using this interface. +/// +/// # Use +/// +/// The intended use is as follows: +/// - Call [`transactions_confirmed`] to process any on-chain activity of interest. +/// - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`] +/// that has been reorganized out of the chain. +/// - Call [`best_block_updated`] whenever a new chain tip becomes available. +/// +/// # Order +/// +/// Clients must call these methods in chain order. Specifically: +/// - Transactions confirmed in a block must be given before transactions confirmed in a later +/// block. +/// - Dependent transactions within the same block must be given in topological order, possibly in +/// separate calls. +/// - Unconfirmed transactions must be given after the original confirmations and before any +/// reconfirmation. +/// +/// See individual method documentation for further details. +/// +/// [`transactions_confirmed`]: Self::transactions_confirmed +/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed +/// [`best_block_updated`]: Self::best_block_updated +/// [`get_relevant_txids`]: Self::get_relevant_txids +#[repr(C)] +pub struct Confirm { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Processes transactions confirmed in a block with a given header and height. + /// + /// Should be called for any transactions registered by [`Filter::register_tx`] or any + /// transactions spending an output registered by [`Filter::register_output`]. Such transactions + /// appearing in the same block do not need to be included in the same call; instead, multiple + /// calls with additional transactions may be made so long as they are made in [chain order]. + /// + /// May be called before or after [`best_block_updated`] for the corresponding block. However, + /// in the event of a chain reorganization, it must not be called with a `header` that is no + /// longer in the chain as of the last call to [`best_block_updated`]. + /// + /// [chain order]: Self#order + /// [`best_block_updated`]: Self::best_block_updated + pub transactions_confirmed: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, height: u32), + /// Processes a transaction that is no longer confirmed as result of a chain reorganization. + /// + /// Should be called for any transaction returned by [`get_relevant_txids`] if it has been + /// reorganized out of the best chain. Once called, the given transaction should not be returned + /// by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`]. + /// + /// [`get_relevant_txids`]: Self::get_relevant_txids + /// [`transactions_confirmed`]: Self::transactions_confirmed + pub transaction_unconfirmed: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32]), + /// Processes an update to the best header connected at the given height. + /// + /// Should be called when a new header is available but may be skipped for intermediary blocks + /// if they become available at the same time. + pub best_block_updated: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32), + /// Returns transactions that should be monitored for reorganization out of the chain. + /// + /// Should include any transactions passed to [`transactions_confirmed`] that have insufficient + /// confirmations to be safe from a chain reorganization. Should not include any transactions + /// passed to [`transaction_unconfirmed`] unless later reconfirmed. + /// + /// May be called to determine the subset of transactions that must still be monitored for + /// reorganization. Will be idempotent between calls but may change as a result of calls to the + /// other interface methods. Thus, this is useful to determine which transactions may need to be + /// given to [`transaction_unconfirmed`]. + /// + /// [`transactions_confirmed`]: Self::transactions_confirmed + /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed + #[must_use] + pub get_relevant_txids: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_TxidZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} + +use lightning::chain::Confirm as rustConfirm; +impl rustConfirm for Confirm { + fn transactions_confirmed(&self, header: &bitcoin::blockdata::block::BlockHeader, txdata: &lightning::chain::transaction::TransactionData, height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = *item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; + (self.transactions_confirmed)(self.this_arg, &local_header, local_txdata.into(), height) + } + fn transaction_unconfirmed(&self, txid: &bitcoin::hash_types::Txid) { + (self.transaction_unconfirmed)(self.this_arg, txid.as_inner()) + } + fn best_block_updated(&self, header: &bitcoin::blockdata::block::BlockHeader, height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + (self.best_block_updated)(self.this_arg, &local_header, height) + } + fn get_relevant_txids(&self) -> Vec { + let mut ret = (self.get_relevant_txids)(self.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { ::bitcoin::hash_types::Txid::from_slice(&item.data[..]).unwrap() }); }; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl std::ops::Deref for Confirm { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn Confirm_free(this_ptr: Confirm) { } +impl Drop for Confirm { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} /// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as /// blocks are connected and disconnected. /// @@ -401,7 +528,7 @@ pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut #[no_mangle] pub extern "C" fn WatchedOutput_get_outpoint(this_ptr: &WatchedOutput) -> crate::lightning::chain::transaction::OutPoint { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Outpoint identifying the transaction output. #[no_mangle] @@ -412,7 +539,7 @@ pub extern "C" fn WatchedOutput_set_outpoint(this_ptr: &mut WatchedOutput, mut v #[no_mangle] pub extern "C" fn WatchedOutput_get_script_pubkey(this_ptr: &WatchedOutput) -> crate::c_types::u8slice { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.script_pubkey; - crate::c_types::u8slice::from_slice(&(*inner_val)[..]) + crate::c_types::u8slice::from_slice(&inner_val[..]) } /// Spending condition of the transaction output. #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs index db30cdf..b4ea08c 100644 --- a/lightning-c-bindings/src/lightning/chain/transaction.rs +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -64,7 +64,7 @@ impl OutPoint { #[no_mangle] pub extern "C" fn OutPoint_get_txid(this_ptr: &OutPoint) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.txid; - (*inner_val).as_inner() + inner_val.as_inner() } /// The referenced transaction's txid. #[no_mangle] @@ -75,7 +75,7 @@ pub extern "C" fn OutPoint_set_txid(this_ptr: &mut OutPoint, mut val: crate::c_t #[no_mangle] pub extern "C" fn OutPoint_get_index(this_ptr: &OutPoint) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.index; - (*inner_val) + *inner_val } /// The index of the referenced output in its transaction's vout. #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index fe989bd..6752123 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -138,7 +138,7 @@ impl TxCreationKeys { #[no_mangle] pub extern "C" fn TxCreationKeys_get_per_commitment_point(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The broadcaster's per-commitment public key which was used to derive the other keys. #[no_mangle] @@ -151,7 +151,7 @@ pub extern "C" fn TxCreationKeys_set_per_commitment_point(this_ptr: &mut TxCreat #[no_mangle] pub extern "C" fn TxCreationKeys_get_revocation_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_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 @@ -164,7 +164,7 @@ pub extern "C" fn TxCreationKeys_set_revocation_key(this_ptr: &mut TxCreationKey #[no_mangle] pub extern "C" fn TxCreationKeys_get_broadcaster_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_htlc_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Broadcaster's HTLC Key #[no_mangle] @@ -175,7 +175,7 @@ pub extern "C" fn TxCreationKeys_set_broadcaster_htlc_key(this_ptr: &mut TxCreat #[no_mangle] pub extern "C" fn TxCreationKeys_get_countersignatory_htlc_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.countersignatory_htlc_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Countersignatory's HTLC Key #[no_mangle] @@ -186,7 +186,7 @@ pub extern "C" fn TxCreationKeys_set_countersignatory_htlc_key(this_ptr: &mut Tx #[no_mangle] pub extern "C" fn TxCreationKeys_get_broadcaster_delayed_payment_key(this_ptr: &TxCreationKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.broadcaster_delayed_payment_key; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) #[no_mangle] @@ -290,7 +290,7 @@ impl ChannelPublicKeys { #[no_mangle] pub extern "C" fn ChannelPublicKeys_get_funding_pubkey(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The public key which is used to sign all commitment transactions, as it appears in the /// on-chain channel lock-in 2-of-2 multisig output. @@ -305,7 +305,7 @@ pub extern "C" fn ChannelPublicKeys_set_funding_pubkey(this_ptr: &mut ChannelPub #[no_mangle] pub extern "C" fn ChannelPublicKeys_get_revocation_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The base point which is used (with derive_public_revocation_key) to derive per-commitment /// revocation keys. This is combined with the per-commitment-secret generated by the @@ -321,7 +321,7 @@ pub extern "C" fn ChannelPublicKeys_set_revocation_basepoint(this_ptr: &mut Chan #[no_mangle] pub extern "C" fn ChannelPublicKeys_get_payment_point(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_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 @@ -336,7 +336,7 @@ pub extern "C" fn ChannelPublicKeys_set_payment_point(this_ptr: &mut ChannelPubl #[no_mangle] pub extern "C" fn ChannelPublicKeys_get_delayed_payment_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_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 @@ -350,7 +350,7 @@ pub extern "C" fn ChannelPublicKeys_set_delayed_payment_basepoint(this_ptr: &mut #[no_mangle] pub extern "C" fn ChannelPublicKeys_get_htlc_basepoint(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_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. @@ -490,7 +490,7 @@ impl HTLCOutputInCommitment { #[no_mangle] pub extern "C" fn HTLCOutputInCommitment_get_offered(this_ptr: &HTLCOutputInCommitment) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.offered; - (*inner_val) + *inner_val } /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). /// Note that this is not the same as whether it is ountbound *from us*. To determine that you @@ -505,7 +505,7 @@ pub extern "C" fn HTLCOutputInCommitment_set_offered(this_ptr: &mut HTLCOutputIn #[no_mangle] pub extern "C" fn HTLCOutputInCommitment_get_amount_msat(this_ptr: &HTLCOutputInCommitment) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat; - (*inner_val) + *inner_val } /// The value, in msat, of the HTLC. The value as it appears in the commitment transaction is /// this divided by 1000. @@ -517,7 +517,7 @@ pub extern "C" fn HTLCOutputInCommitment_set_amount_msat(this_ptr: &mut HTLCOutp #[no_mangle] pub extern "C" fn HTLCOutputInCommitment_get_cltv_expiry(this_ptr: &HTLCOutputInCommitment) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry; - (*inner_val) + *inner_val } /// The CLTV lock-time at which this HTLC expires. #[no_mangle] @@ -528,7 +528,7 @@ pub extern "C" fn HTLCOutputInCommitment_set_cltv_expiry(this_ptr: &mut HTLCOutp #[no_mangle] pub extern "C" fn HTLCOutputInCommitment_get_payment_hash(this_ptr: &HTLCOutputInCommitment) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash; - &(*inner_val).0 + &inner_val.0 } /// The hash of the preimage which unlocks this HTLC. #[no_mangle] @@ -620,8 +620,7 @@ pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::Pub #[no_mangle] pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); - let mut local_ret = ::bitcoin::consensus::encode::serialize(&ret); - crate::c_types::Transaction::from_vec(local_ret) + crate::c_types::Transaction::from_bitcoin(&ret) } @@ -677,7 +676,7 @@ impl ChannelTransactionParameters { #[no_mangle] pub extern "C" fn ChannelTransactionParameters_get_holder_pubkeys(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.holder_pubkeys; - crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Holder public keys #[no_mangle] @@ -688,7 +687,7 @@ pub extern "C" fn ChannelTransactionParameters_set_holder_pubkeys(this_ptr: &mut #[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) + *inner_val } /// The contest delay selected by the holder, which applies to counterparty-broadcast transactions #[no_mangle] @@ -700,7 +699,7 @@ pub extern "C" fn ChannelTransactionParameters_set_holder_selected_contest_delay #[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) + *inner_val } /// Whether the holder is the initiator of this channel. /// This is an input to the commitment number obscure factor computation. @@ -818,7 +817,7 @@ impl CounterpartyChannelTransactionParameters { #[no_mangle] pub extern "C" fn CounterpartyChannelTransactionParameters_get_pubkeys(this_ptr: &CounterpartyChannelTransactionParameters) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkeys; - crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Counter-party public keys #[no_mangle] @@ -829,7 +828,7 @@ pub extern "C" fn CounterpartyChannelTransactionParameters_set_pubkeys(this_ptr: #[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) + *inner_val } /// The contest delay selected by the counterparty, which applies to holder-broadcast transactions #[no_mangle] @@ -1070,7 +1069,7 @@ impl HolderCommitmentTransaction { #[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)) + crate::c_types::Signature::from_rust(&inner_val) } /// Our counterparty's signature for the transaction #[no_mangle] @@ -1177,8 +1176,7 @@ impl BuiltCommitmentTransaction { #[no_mangle] 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) + crate::c_types::Transaction::from_bitcoin(inner_val) } /// The commitment transaction #[no_mangle] @@ -1192,7 +1190,7 @@ pub extern "C" fn BuiltCommitmentTransaction_set_transaction(this_ptr: &mut Buil #[no_mangle] 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() + inner_val.as_inner() } /// The txid for the commitment transaction. /// diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 9530c75..90952e7 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -154,7 +154,7 @@ impl ChainParameters { #[no_mangle] pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.network; - crate::bitcoin::network::Network::from_bitcoin((*inner_val)) + crate::bitcoin::network::Network::from_bitcoin(inner_val) } /// The network for determining the `chain_hash` in Lightning messages. #[no_mangle] @@ -167,7 +167,7 @@ pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mu #[no_mangle] pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::ln::channelmanager::BestBlock { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.best_block; - crate::lightning::ln::channelmanager::BestBlock { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::channelmanager::BestBlock { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The hash and height of the latest block successfully connected. /// @@ -351,7 +351,7 @@ impl ChannelDetails { #[no_mangle] pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes, /// thereafter this is the txid of the funding transaction xor the funding transaction output). @@ -380,7 +380,7 @@ pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDeta #[no_mangle] pub extern "C" fn ChannelDetails_get_remote_network_id(this_ptr: &ChannelDetails) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.remote_network_id; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The node_id of our counterparty #[no_mangle] @@ -393,7 +393,7 @@ pub extern "C" fn ChannelDetails_set_remote_network_id(this_ptr: &mut ChannelDet #[no_mangle] pub extern "C" fn ChannelDetails_get_counterparty_features(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::InitFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// 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 @@ -406,7 +406,7 @@ pub extern "C" fn ChannelDetails_set_counterparty_features(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis; - (*inner_val) + *inner_val } /// The value, in satoshis, of this channel as appears in the funding output #[no_mangle] @@ -417,7 +417,7 @@ pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut Chann #[no_mangle] pub extern "C" fn ChannelDetails_get_user_id(this_ptr: &ChannelDetails) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.user_id; - (*inner_val) + *inner_val } /// The user_id passed in to create_channel, or 0 if the channel was inbound. #[no_mangle] @@ -431,7 +431,7 @@ pub extern "C" fn ChannelDetails_set_user_id(this_ptr: &mut ChannelDetails, mut #[no_mangle] pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outbound_capacity_msat; - (*inner_val) + *inner_val } /// The available outbound capacity for sending HTLCs to the remote peer. This does not include /// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not @@ -449,7 +449,7 @@ pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut Chann #[no_mangle] pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.inbound_capacity_msat; - (*inner_val) + *inner_val } /// The available inbound capacity for the remote peer to send HTLCs to us. This does not /// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not @@ -465,7 +465,7 @@ pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelDetails_get_is_live(this_ptr: &ChannelDetails) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_live; - (*inner_val) + *inner_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. @@ -1030,91 +1030,45 @@ extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, >::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } -/// Updates channel state to take note of transactions which were confirmed in the given block -/// at the given height. -/// -/// Note that you must still call (or have called) [`update_best_block`] with the block -/// information which is included here. -/// -/// This method may be called before or after [`update_best_block`] for a given block's -/// transaction data and may be called multiple times with additional transaction data for a -/// given block. -/// -/// This method may be called for a previous block after an [`update_best_block`] call has -/// been made for a later block, however it must *not* be called with transaction data from a -/// block which is no longer in the best chain (ie where [`update_best_block`] has already -/// been informed about a blockchain reorganization which no longer includes the block which -/// corresponds to `header`). -/// -/// [`update_best_block`]: `Self::update_best_block` -#[no_mangle] -pub extern "C" fn ChannelManager_transactions_confirmed(this_arg: &ChannelManager, header: *const [u8; 80], mut height: u32, mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ) { - let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - unsafe { &*this_arg.inner }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..]) +impl From for crate::lightning::chain::Confirm { + 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_Confirm(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = std::ptr::null_mut(); + ret.free = Some(ChannelManager_free_void); + ret + } } - -/// Updates channel state with the current best blockchain tip. You should attempt to call this -/// quickly after a new block becomes available, however if multiple new blocks become -/// available at the same time, only a single `update_best_block()` call needs to be made. -/// -/// This method should also be called immediately after any block disconnections, once at the -/// reorganization fork point, and once with the new chain tip. Calling this method at the -/// blockchain reorganization fork point ensures we learn when a funding transaction which was -/// previously confirmed is reorganized out of the blockchain, ensuring we do not continue to -/// accept payments which cannot be enforced on-chain. -/// -/// In both the block-connection and block-disconnection case, this method may be called either -/// once per block connected or disconnected, or simply at the fork point and new tip(s), -/// skipping any intermediary blocks. +/// Constructs a new Confirm which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is #[no_mangle] -pub extern "C" fn ChannelManager_update_best_block(this_arg: &ChannelManager, header: *const [u8; 80], mut height: u32) { - unsafe { &*this_arg.inner }.update_best_block(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate::lightning::chain::Confirm { + crate::lightning::chain::Confirm { + this_arg: unsafe { (*this_arg).inner as *mut c_void }, + free: None, + transactions_confirmed: ChannelManager_Confirm_transactions_confirmed, + transaction_unconfirmed: ChannelManager_Confirm_transaction_unconfirmed, + best_block_updated: ChannelManager_Confirm_best_block_updated, + get_relevant_txids: ChannelManager_Confirm_get_relevant_txids, + } } -/// Gets the set of txids which should be monitored for their confirmation state. -/// -/// If you're providing information about reorganizations via [`transaction_unconfirmed`], this -/// is the set of transactions which you may need to call [`transaction_unconfirmed`] for. -/// -/// This may be useful to poll to determine the set of transactions which must be registered -/// with an Electrum server or for which an Electrum server needs to be polled to determine -/// transaction confirmation state. -/// -/// This may update after any [`transactions_confirmed`] or [`block_connected`] call. -/// -/// Note that this is NOT the set of transactions which must be included in calls to -/// [`transactions_confirmed`] if they are confirmed, but a small subset of it. -/// -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`transaction_unconfirmed`]: Self::transaction_unconfirmed -/// [`block_connected`]: chain::Listen::block_connected +extern "C" fn ChannelManager_Confirm_transactions_confirmed(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + >::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) +} +extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { + >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} #[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_get_relevant_txids(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_TxidZ { - let mut ret = unsafe { &*this_arg.inner }.get_relevant_txids(); +extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_TxidZ { + let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); }; local_ret.into() } - -/// Marks a transaction as having been reorganized out of the blockchain. -/// -/// If a transaction is included in [`get_relevant_txids`], and is no longer in the main branch -/// of the blockchain, this function should be called to indicate that the transaction should -/// be considered reorganized out. -/// -/// Once this is called, the given transaction will no longer appear on [`get_relevant_txids`], -/// though this may be called repeatedly for a given transaction without issue. -/// -/// Note that if the transaction is confirmed on the main chain in a different block (indicated -/// via a call to [`transactions_confirmed`]), it may re-appear in [`get_relevant_txids`], thus -/// be very wary of race-conditions wherein the final state of a transaction indicated via -/// these APIs is not the same as its state on the blockchain. -/// -/// [`transactions_confirmed`]: Self::transactions_confirmed -/// [`get_relevant_txids`]: Self::get_relevant_txids -#[no_mangle] -pub extern "C" fn ChannelManager_transaction_unconfirmed(this_arg: &ChannelManager, txid: *const [u8; 32]) { - unsafe { &*this_arg.inner }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) +extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) { + >::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) } /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool @@ -1327,7 +1281,7 @@ impl ChannelManagerReadArgs { #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::KeysInterface { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.keys_manager; - &(*inner_val) + inner_val } /// The keys provider which will give us relevant keys. Some keys will be loaded during /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel @@ -1342,7 +1296,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut Channel #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::FeeEstimator { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_estimator; - &(*inner_val) + inner_val } /// The fee_estimator for use in the ChannelManager in the future. /// @@ -1359,7 +1313,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_monitor; - &(*inner_val) + inner_val } /// The chain::Watch for use in the ChannelManager in the future. /// @@ -1376,7 +1330,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::BroadcasterInterface { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.tx_broadcaster; - &(*inner_val) + inner_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 @@ -1390,7 +1344,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut Chann #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::util::logger::Logger { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.logger; - &(*inner_val) + inner_val } /// The Logger for use in the ChannelManager and which may be used to log information during /// deserialization. @@ -1403,7 +1357,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManage #[no_mangle] pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::lightning::util::config::UserConfig { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.default_config; - crate::lightning::util::config::UserConfig { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::util::config::UserConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Default settings used for new channels. Any existing channels will continue to use the /// runtime settings which were stored when the ChannelManager was serialized. diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index a005cf4..97c516a 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -140,7 +140,7 @@ impl Init { #[no_mangle] pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The relevant features which the sender supports #[no_mangle] @@ -223,7 +223,7 @@ impl ErrorMessage { #[no_mangle] pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID involved in the error #[no_mangle] @@ -237,7 +237,7 @@ pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut v #[no_mangle] pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data; - (*inner_val).as_str().into() + inner_val.as_str().into() } /// A possibly human-readable error description. /// The string should be sanitized before it is used (e.g. emitted to logs @@ -324,7 +324,7 @@ impl Ping { #[no_mangle] pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen; - (*inner_val) + *inner_val } /// The desired response length #[no_mangle] @@ -336,7 +336,7 @@ pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) { #[no_mangle] pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen; - (*inner_val) + *inner_val } /// The ping packet size. /// This field is not sent on the wire. byteslen zeros are sent. @@ -422,7 +422,7 @@ impl Pong { #[no_mangle] pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen; - (*inner_val) + *inner_val } /// The pong packet size. /// This field is not sent on the wire. byteslen zeros are sent. @@ -506,7 +506,7 @@ impl OpenChannel { #[no_mangle] pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -517,7 +517,7 @@ pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val #[no_mangle] pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id; - &(*inner_val) + inner_val } /// A temporary channel ID, until the funding outpoint is announced #[no_mangle] @@ -528,7 +528,7 @@ pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChanne #[no_mangle] pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis; - (*inner_val) + *inner_val } /// The channel value #[no_mangle] @@ -539,7 +539,7 @@ pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, m #[no_mangle] pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat; - (*inner_val) + *inner_val } /// The amount to push to the counterparty as part of the open, in milli-satoshi #[no_mangle] @@ -550,7 +550,7 @@ pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: #[no_mangle] pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis; - (*inner_val) + *inner_val } /// The threshold below which outputs on transactions broadcast by sender will be omitted #[no_mangle] @@ -561,7 +561,7 @@ pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel #[no_mangle] pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat; - (*inner_val) + *inner_val } /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi #[no_mangle] @@ -572,7 +572,7 @@ pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut O #[no_mangle] pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis; - (*inner_val) + *inner_val } /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] @@ -583,7 +583,7 @@ pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenCh #[no_mangle] pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum HTLC size incoming to sender, in milli-satoshi #[no_mangle] @@ -594,7 +594,7 @@ pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, #[no_mangle] pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw; - (*inner_val) + *inner_val } /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee #[no_mangle] @@ -605,7 +605,7 @@ pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; - (*inner_val) + *inner_val } /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction #[no_mangle] @@ -616,7 +616,7 @@ pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs; - (*inner_val) + *inner_val } /// The maximum number of inbound HTLCs towards sender #[no_mangle] @@ -627,7 +627,7 @@ pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, #[no_mangle] pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The sender's key controlling the funding transaction #[no_mangle] @@ -638,7 +638,7 @@ pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] @@ -649,7 +649,7 @@ pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChanne #[no_mangle] pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// A payment key to sender for transactions broadcast by counterparty #[no_mangle] @@ -660,7 +660,7 @@ pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a payment key to sender for transactions broadcast by sender #[no_mangle] @@ -671,7 +671,7 @@ pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenC #[no_mangle] pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive an HTLC payment key to sender #[no_mangle] @@ -682,7 +682,7 @@ pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The first to-be-broadcast-by-sender transaction's per commitment point #[no_mangle] @@ -693,7 +693,7 @@ pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut Open #[no_mangle] pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags; - (*inner_val) + *inner_val } /// Channel flags #[no_mangle] @@ -768,7 +768,7 @@ impl AcceptChannel { #[no_mangle] pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id; - &(*inner_val) + inner_val } /// A temporary channel ID, until the funding outpoint is announced #[no_mangle] @@ -779,7 +779,7 @@ pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptCh #[no_mangle] pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis; - (*inner_val) + *inner_val } /// The threshold below which outputs on transactions broadcast by sender will be omitted #[no_mangle] @@ -790,7 +790,7 @@ pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptCha #[no_mangle] pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat; - (*inner_val) + *inner_val } /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi #[no_mangle] @@ -801,7 +801,7 @@ pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut #[no_mangle] pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis; - (*inner_val) + *inner_val } /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] @@ -812,7 +812,7 @@ pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut Acce #[no_mangle] pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum HTLC size incoming to sender, in milli-satoshi #[no_mangle] @@ -823,7 +823,7 @@ pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChann #[no_mangle] pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth; - (*inner_val) + *inner_val } /// Minimum depth of the funding transaction before the channel is considered open #[no_mangle] @@ -834,7 +834,7 @@ pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; - (*inner_val) + *inner_val } /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction #[no_mangle] @@ -845,7 +845,7 @@ pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs; - (*inner_val) + *inner_val } /// The maximum number of inbound HTLCs towards sender #[no_mangle] @@ -856,7 +856,7 @@ pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChan #[no_mangle] pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The sender's key controlling the funding transaction #[no_mangle] @@ -867,7 +867,7 @@ pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] @@ -878,7 +878,7 @@ pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptCh #[no_mangle] pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// A payment key to sender for transactions broadcast by counterparty #[no_mangle] @@ -889,7 +889,7 @@ pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a payment key to sender for transactions broadcast by sender #[no_mangle] @@ -900,7 +900,7 @@ pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut Acc #[no_mangle] pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty #[no_mangle] @@ -911,7 +911,7 @@ pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The first to-be-broadcast-by-sender transaction's per commitment point #[no_mangle] @@ -986,7 +986,7 @@ impl FundingCreated { #[no_mangle] pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id; - &(*inner_val) + inner_val } /// A temporary channel ID, until the funding is established #[no_mangle] @@ -997,7 +997,7 @@ pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut Funding #[no_mangle] pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid; - (*inner_val).as_inner() + inner_val.as_inner() } /// The funding transaction ID #[no_mangle] @@ -1008,7 +1008,7 @@ pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, #[no_mangle] pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index; - (*inner_val) + *inner_val } /// The specific output index funding this channel #[no_mangle] @@ -1019,7 +1019,7 @@ pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut Funding #[no_mangle] pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// The signature of the channel initiator (funder) on the funding transaction #[no_mangle] @@ -1105,7 +1105,7 @@ impl FundingSigned { #[no_mangle] pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1116,7 +1116,7 @@ pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut #[no_mangle] pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// The signature of the channel acceptor (fundee) on the funding transaction #[no_mangle] @@ -1200,7 +1200,7 @@ impl FundingLocked { #[no_mangle] pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1211,7 +1211,7 @@ pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut #[no_mangle] pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The per-commitment point of the second commitment transaction #[no_mangle] @@ -1295,7 +1295,7 @@ impl Shutdown { #[no_mangle] pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1307,7 +1307,7 @@ pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crat #[no_mangle] pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey; - crate::c_types::u8slice::from_slice(&(*inner_val)[..]) + crate::c_types::u8slice::from_slice(&inner_val[..]) } /// The destination of this peer's funds on closing. /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. @@ -1392,7 +1392,7 @@ impl ClosingSigned { #[no_mangle] pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1403,7 +1403,7 @@ pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut #[no_mangle] pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis; - (*inner_val) + *inner_val } /// The proposed total fee for the closing transaction #[no_mangle] @@ -1414,7 +1414,7 @@ pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, m #[no_mangle] pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature on the closing transaction #[no_mangle] @@ -1499,7 +1499,7 @@ impl UpdateAddHTLC { #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1510,7 +1510,7 @@ pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1521,7 +1521,7 @@ pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut va #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat; - (*inner_val) + *inner_val } /// The HTLC value in milli-satoshi #[no_mangle] @@ -1532,7 +1532,7 @@ pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mu #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash; - &(*inner_val).0 + &inner_val.0 } /// The payment hash, the pre-image of which controls HTLC redemption #[no_mangle] @@ -1543,7 +1543,7 @@ pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, m #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry; - (*inner_val) + *inner_val } /// The expiry height of the HTLC #[no_mangle] @@ -1618,7 +1618,7 @@ impl UpdateFulfillHTLC { #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1629,7 +1629,7 @@ pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillH #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1640,7 +1640,7 @@ pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage; - &(*inner_val).0 + &inner_val.0 } /// The pre-image of the payment hash, allowing HTLC redemption #[no_mangle] @@ -1725,7 +1725,7 @@ impl UpdateFailHTLC { #[no_mangle] pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1736,7 +1736,7 @@ pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, m #[no_mangle] pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1811,7 +1811,7 @@ impl UpdateFailMalformedHTLC { #[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1822,7 +1822,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFa #[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1833,7 +1833,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailM #[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code; - (*inner_val) + *inner_val } /// The failure code #[no_mangle] @@ -1908,7 +1908,7 @@ impl CommitmentSigned { #[no_mangle] pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1919,7 +1919,7 @@ pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigne #[no_mangle] pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature on the commitment transaction #[no_mangle] @@ -2011,7 +2011,7 @@ impl RevokeAndACK { #[no_mangle] pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2022,7 +2022,7 @@ pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut v #[no_mangle] pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret; - &(*inner_val) + inner_val } /// The secret corresponding to the per-commitment point #[no_mangle] @@ -2033,7 +2033,7 @@ pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAn #[no_mangle] pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The next sender-broadcast commitment transaction's per-commitment point #[no_mangle] @@ -2118,7 +2118,7 @@ impl UpdateFee { #[no_mangle] pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2129,7 +2129,7 @@ pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: cr #[no_mangle] pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw; - (*inner_val) + *inner_val } /// Fee rate per 1000-weight of the transaction #[no_mangle] @@ -2217,7 +2217,7 @@ impl DataLossProtect { #[no_mangle] pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret; - &(*inner_val) + inner_val } /// Proof that the sender knows the per-commitment secret of a specific commitment transaction /// belonging to the recipient @@ -2229,7 +2229,7 @@ pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: #[no_mangle] pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The sender's per-commitment point for their current commitment transaction #[no_mangle] @@ -2313,7 +2313,7 @@ impl ChannelReestablish { #[no_mangle] pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2324,7 +2324,7 @@ pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReesta #[no_mangle] pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number; - (*inner_val) + *inner_val } /// The next commitment number for the sender #[no_mangle] @@ -2335,7 +2335,7 @@ pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: #[no_mangle] pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number; - (*inner_val) + *inner_val } /// The next commitment number for the recipient #[no_mangle] @@ -2410,7 +2410,7 @@ impl AnnouncementSignatures { #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2421,7 +2421,7 @@ pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut Announcem #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short channel ID #[no_mangle] @@ -2432,7 +2432,7 @@ pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut Ann #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature by the node key #[no_mangle] @@ -2443,7 +2443,7 @@ pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut Annou #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature by the funding key #[no_mangle] @@ -2736,7 +2736,7 @@ impl UnsignedNodeAnnouncement { #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The advertised features #[no_mangle] @@ -2747,7 +2747,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedN #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp; - (*inner_val) + *inner_val } /// A strictly monotonic announcement counter, with gaps allowed #[no_mangle] @@ -2759,7 +2759,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut Unsigned #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The node_id this announcement originated from (don't rebroadcast the node_announcement back /// to this node). @@ -2771,7 +2771,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNo #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb; - &(*inner_val) + inner_val } /// An RGB color for UI purposes #[no_mangle] @@ -2783,7 +2783,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAn #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias; - &(*inner_val) + inner_val } /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee /// of uniqueness. @@ -2865,7 +2865,7 @@ impl NodeAnnouncement { #[no_mangle] pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// The signature by the node key #[no_mangle] @@ -2876,7 +2876,7 @@ pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement #[no_mangle] pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; - crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The actual content of the announcement #[no_mangle] @@ -2960,7 +2960,7 @@ impl UnsignedChannelAnnouncement { #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The advertised channel features #[no_mangle] @@ -2971,7 +2971,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut Unsign #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -2982,7 +2982,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut Unsi #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short channel ID #[no_mangle] @@ -2993,7 +2993,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mu #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// One of the two node_ids which are endpoints of this channel #[no_mangle] @@ -3004,7 +3004,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut Unsig #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The other of the two node_ids which are endpoints of this channel #[no_mangle] @@ -3015,7 +3015,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut Unsig #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The funding key for the first node #[no_mangle] @@ -3026,7 +3026,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut U #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The funding key for the second node #[no_mangle] @@ -3101,7 +3101,7 @@ impl ChannelAnnouncement { #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Authentication of the announcement by the first public node #[no_mangle] @@ -3112,7 +3112,7 @@ pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Authentication of the announcement by the second public node #[no_mangle] @@ -3123,7 +3123,7 @@ pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Proof of funding UTXO ownership by the first public node #[no_mangle] @@ -3134,7 +3134,7 @@ pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut Cha #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Proof of funding UTXO ownership by the second public node #[no_mangle] @@ -3145,7 +3145,7 @@ pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut Cha #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; - crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The actual announcement #[no_mangle] @@ -3232,7 +3232,7 @@ impl UnsignedChannelUpdate { #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -3243,7 +3243,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedCh #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short channel ID #[no_mangle] @@ -3254,7 +3254,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut Unsi #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp; - (*inner_val) + *inner_val } /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel #[no_mangle] @@ -3265,7 +3265,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedCha #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags; - (*inner_val) + *inner_val } /// Channel flags #[no_mangle] @@ -3283,7 +3283,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannel #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) + *inner_val } /// The number of blocks such that if: /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` @@ -3301,7 +3301,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut Uns #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum HTLC size incoming to sender, in milli-satoshi #[no_mangle] @@ -3312,7 +3312,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut Uns #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat; - (*inner_val) + *inner_val } /// The base HTLC fee charged by sender, in milli-satoshi #[no_mangle] @@ -3323,7 +3323,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut Unsigne #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths; - (*inner_val) + *inner_val } /// The amount to fee multiplier, in micro-satoshi #[no_mangle] @@ -3398,7 +3398,7 @@ impl ChannelUpdate { #[no_mangle] pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature of the channel update #[no_mangle] @@ -3409,7 +3409,7 @@ pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut #[no_mangle] pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; - crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The actual channel update #[no_mangle] @@ -3496,7 +3496,7 @@ impl QueryChannelRange { #[no_mangle] pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -3507,7 +3507,7 @@ pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRa #[no_mangle] pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; - (*inner_val) + *inner_val } /// The height of the first block for the channel UTXOs being queried #[no_mangle] @@ -3518,7 +3518,7 @@ pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChann #[no_mangle] pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; - (*inner_val) + *inner_val } /// The number of blocks to include in the query results #[no_mangle] @@ -3609,7 +3609,7 @@ impl ReplyChannelRange { #[no_mangle] pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -3620,7 +3620,7 @@ pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRa #[no_mangle] pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; - (*inner_val) + *inner_val } /// The height of the first block in the range of the reply #[no_mangle] @@ -3631,7 +3631,7 @@ pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChann #[no_mangle] pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; - (*inner_val) + *inner_val } /// The number of blocks included in the range of the reply #[no_mangle] @@ -3642,7 +3642,7 @@ pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyCha #[no_mangle] pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete; - (*inner_val) + *inner_val } /// True when this is the final reply for a query #[no_mangle] @@ -3743,7 +3743,7 @@ impl QueryShortChannelIds { #[no_mangle] pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -3837,7 +3837,7 @@ impl ReplyShortChannelIdsEnd { #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain that was queried #[no_mangle] @@ -3849,7 +3849,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplySho #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information; - (*inner_val) + *inner_val } /// Indicates if the query recipient maintains up-to-date channel /// information for the chain_hash @@ -3936,7 +3936,7 @@ impl GossipTimestampFilter { #[no_mangle] pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain for channel and node information #[no_mangle] @@ -3947,7 +3947,7 @@ pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTime #[no_mangle] pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp; - (*inner_val) + *inner_val } /// The starting unix timestamp #[no_mangle] @@ -3958,7 +3958,7 @@ pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut Gossi #[no_mangle] pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range; - (*inner_val) + *inner_val } /// The range of information in seconds #[no_mangle] @@ -4144,7 +4144,7 @@ impl LightningError { #[no_mangle] pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err; - (*inner_val).as_str().into() + inner_val.as_str().into() } /// A human-readable message describing the error #[no_mangle] @@ -4155,7 +4155,7 @@ pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: #[no_mangle] pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action; - crate::lightning::ln::msgs::ErrorAction::from_native(&(*inner_val)) + crate::lightning::ln::msgs::ErrorAction::from_native(inner_val) } /// The action which should be taken against the offending peer. #[no_mangle] @@ -4277,7 +4277,7 @@ pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdat #[no_mangle] pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed; - crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Finally, the commitment_signed message which should be sent #[no_mangle] @@ -4704,7 +4704,7 @@ impl rustRoutingMessageHandler for RoutingMessageHandler { local_ret } fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) { - (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(&update)) + (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update)) } 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); diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index d1c07e6..6cc942d 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -435,7 +435,7 @@ impl MessageHandler { #[no_mangle] pub extern "C" fn MessageHandler_get_chan_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::msgs::ChannelMessageHandler { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chan_handler; - &(*inner_val) + inner_val } /// A message handler which handles messages specific to channels. Usually this is just a /// ChannelManager object or a ErroringMessageHandler. @@ -448,7 +448,7 @@ pub extern "C" fn MessageHandler_set_chan_handler(this_ptr: &mut MessageHandler, #[no_mangle] pub extern "C" fn MessageHandler_get_route_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::msgs::RoutingMessageHandler { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.route_handler; - &(*inner_val) + inner_val } /// A message handler which handles messages updating our knowledge of the network channel /// graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. @@ -624,7 +624,7 @@ impl PeerHandleError { #[no_mangle] pub extern "C" fn PeerHandleError_get_no_connection_possible(this_ptr: &PeerHandleError) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.no_connection_possible; - (*inner_val) + *inner_val } /// Used to indicate that we probably can't make any future connections to this peer, implying /// we should go ahead and force-close any channels we have with it. diff --git a/lightning-c-bindings/src/lightning/routing/network_graph.rs b/lightning-c-bindings/src/lightning/routing/network_graph.rs index 5f719e9..27e71ed 100644 --- a/lightning-c-bindings/src/lightning/routing/network_graph.rs +++ b/lightning-c-bindings/src/lightning/routing/network_graph.rs @@ -400,7 +400,7 @@ impl DirectionalChannelInfo { #[no_mangle] pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update; - (*inner_val) + *inner_val } /// When the last update to the channel direction was issued. /// Value is opaque, as set in the announcement. @@ -412,7 +412,7 @@ pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut Directio #[no_mangle] pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.enabled; - (*inner_val) + *inner_val } /// Whether the channel can be currently used for payments (in this one direction). #[no_mangle] @@ -423,7 +423,7 @@ pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalC #[no_mangle] pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) + *inner_val } /// The difference in CLTV values that you must have when routing through this channel. #[no_mangle] @@ -434,7 +434,7 @@ pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut Di #[no_mangle] pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum value, which must be relayed to the next hop via the channel #[no_mangle] @@ -458,7 +458,7 @@ pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut Di #[no_mangle] pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees; - crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::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] @@ -585,7 +585,7 @@ impl ChannelInfo { #[no_mangle] pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Protocol features of a channel communicated during its announcement #[no_mangle] @@ -596,7 +596,7 @@ pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: #[no_mangle] pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_one; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Source node of the first direction of a channel #[no_mangle] @@ -620,7 +620,7 @@ pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val #[no_mangle] pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_two; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Source node of the second direction of a channel #[no_mangle] @@ -774,7 +774,7 @@ impl RoutingFees { #[no_mangle] pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.base_msat; - (*inner_val) + *inner_val } /// Flat routing fee in satoshis #[no_mangle] @@ -786,7 +786,7 @@ pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: #[no_mangle] pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.proportional_millionths; - (*inner_val) + *inner_val } /// Liquidity-based routing fee in millionths of a routed amount. /// In other words, 10000 is 1%. @@ -887,7 +887,7 @@ impl NodeAnnouncementInfo { #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Protocol features the node announced support for #[no_mangle] @@ -899,7 +899,7 @@ pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncem #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.last_update; - (*inner_val) + *inner_val } /// When the last known update to the node state was issued. /// Value is opaque, as set in the announcement. @@ -911,7 +911,7 @@ pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnoun #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb; - &(*inner_val) + inner_val } /// Color assigned to the node #[no_mangle] @@ -924,7 +924,7 @@ pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementIn #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias; - &(*inner_val) + inner_val } /// Moniker assigned to the node. /// May be invalid or malicious (eg control chars), diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index 81b9bef..5a060c1 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -64,7 +64,7 @@ impl RouteHop { #[no_mangle] pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The node_id of the node at this hop. #[no_mangle] @@ -76,7 +76,7 @@ pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c #[no_mangle] pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// 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. @@ -88,7 +88,7 @@ pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: c #[no_mangle] pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The channel that should be used from the previous hop to reach this node. #[no_mangle] @@ -100,7 +100,7 @@ pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val #[no_mangle] pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The channel_announcement features of the channel that should be used from the previous hop /// to reach this node. @@ -114,7 +114,7 @@ pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val #[no_mangle] pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_msat; - (*inner_val) + *inner_val } /// The fee taken on this hop (for paying for the use of the *next* channel in the path). /// For the last hop, this should be the full value of the payment (might be more than @@ -128,7 +128,7 @@ pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) { #[no_mangle] pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) + *inner_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. @@ -318,7 +318,7 @@ impl RouteHintHop { #[no_mangle] pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.src_node_id; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The node_id of the non-target end of the route #[no_mangle] @@ -329,7 +329,7 @@ pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut #[no_mangle] pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short_channel_id of this channel #[no_mangle] @@ -340,7 +340,7 @@ pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, #[no_mangle] pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::network_graph::RoutingFees { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fees; - crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The fees which must be paid to use this channel #[no_mangle] @@ -351,7 +351,7 @@ pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: cr #[no_mangle] pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) + *inner_val } /// The difference in CLTV values between this node and the next node. #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index 8ee8561..a5d0391 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -68,7 +68,7 @@ impl ChannelHandshakeConfig { #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHandshakeConfig) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth; - (*inner_val) + *inner_val } /// Confirmations we will wait for before considering the channel locked in. /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the @@ -97,7 +97,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_to_self_delay; - (*inner_val) + *inner_val } /// Set to the number of blocks we require our counterparty to wait to claim their money (ie /// the number of blocks we have to punish our counterparty if they broadcast a revoked @@ -128,7 +128,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut Ch #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_htlc_minimum_msat; - (*inner_val) + *inner_val } /// Set to the smallest value HTLC we will accept to process. /// @@ -238,7 +238,7 @@ impl ChannelHandshakeLimits { #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_funding_satoshis; - (*inner_val) + *inner_val } /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so /// only applies to inbound channels. @@ -255,7 +255,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_minimum_msat; - (*inner_val) + *inner_val } /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows /// you to limit the maximum minimum-size they can require. @@ -272,7 +272,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mu #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_max_htlc_value_in_flight_msat; - (*inner_val) + *inner_val } /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. @@ -290,7 +290,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(t #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_channel_reserve_satoshis; - (*inner_val) + *inner_val } /// The remote node will require we keep a certain amount in direct payment to ourselves at all /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to @@ -308,7 +308,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_p #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_max_accepted_htlcs; - (*inner_val) + *inner_val } /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given /// time. This allows you to set a minimum such value. @@ -330,7 +330,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &m #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_dust_limit_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_dust_limit_satoshis; - (*inner_val) + *inner_val } /// Outputs below a certain value will not be added to on-chain transactions. The dust value is /// required to always be higher than this value so this only applies to HTLC outputs (and @@ -353,7 +353,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_dust_limit_satoshis(this_ptr: & #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_dust_limit_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_dust_limit_satoshis; - (*inner_val) + *inner_val } /// Maximum allowed threshold above which outputs will not be generated in their commitment /// transactions. @@ -373,7 +373,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_dust_limit_satoshis(this_ptr: & #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_minimum_depth; - (*inner_val) + *inner_val } /// Before a channel is usable the funding transaction will need to be confirmed by at least a /// certain number of blocks, specified by the node which is not the funder (as the funder can @@ -393,7 +393,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut Ch #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.force_announced_channel_preference; - (*inner_val) + *inner_val } /// Set to force the incoming channel to match our announced channel preference in /// ChannelConfig. @@ -414,7 +414,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference( #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.their_to_self_delay; - (*inner_val) + *inner_val } /// Set to the amount of time we're willing to wait to claim money back to us. /// @@ -523,7 +523,7 @@ impl ChannelConfig { #[no_mangle] pub extern "C" fn ChannelConfig_get_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths; - (*inner_val) + *inner_val } /// Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. /// This may be allowed to change at runtime in a later update, however doing so must result in @@ -556,7 +556,7 @@ pub extern "C" fn ChannelConfig_set_fee_proportional_millionths(this_ptr: &mut C #[no_mangle] pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) + *inner_val } /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over /// the channel this config applies to. @@ -595,7 +595,7 @@ pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConf #[no_mangle] pub extern "C" fn ChannelConfig_get_announced_channel(this_ptr: &ChannelConfig) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announced_channel; - (*inner_val) + *inner_val } /// Set to announce the channel publicly and notify all nodes that they can route via this /// channel. @@ -626,7 +626,7 @@ pub extern "C" fn ChannelConfig_set_announced_channel(this_ptr: &mut ChannelConf #[no_mangle] pub extern "C" fn ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelConfig) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commit_upfront_shutdown_pubkey; - (*inner_val) + *inner_val } /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty /// supports it, they will then enforce the mutual-close output to us matches what we provided @@ -747,7 +747,7 @@ impl UserConfig { #[no_mangle] pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.own_channel_config; - crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Channel config that we propose to our counterparty. #[no_mangle] @@ -758,7 +758,7 @@ pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, m #[no_mangle] pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.peer_channel_config_limits; - crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Limits applied to our counterparty's proposed channel config settings. #[no_mangle] @@ -769,7 +769,7 @@ pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserC #[no_mangle] pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_options; - crate::lightning::util::config::ChannelConfig { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::util::config::ChannelConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Channel config which affects behavior during channel lifetime. #[no_mangle]