1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Structs and traits which allow other parts of rust-lightning to interact with the blockchain.
12 use bitcoin::hashes::Hash;
13 use crate::c_types::*;
15 pub mod chaininterface;
17 pub mod channelmonitor;
19 pub mod keysinterface;
20 /// An error when accessing the chain via [`Access`].
24 pub enum AccessError {
25 /// The requested chain is unknown.
27 /// The requested transaction doesn't exist or hasn't confirmed.
30 use lightning::chain::AccessError as nativeAccessError;
33 pub(crate) fn to_native(&self) -> nativeAccessError {
35 AccessError::UnknownChain => nativeAccessError::UnknownChain,
36 AccessError::UnknownTx => nativeAccessError::UnknownTx,
40 pub(crate) fn into_native(self) -> nativeAccessError {
42 AccessError::UnknownChain => nativeAccessError::UnknownChain,
43 AccessError::UnknownTx => nativeAccessError::UnknownTx,
47 pub(crate) fn from_native(native: &nativeAccessError) -> Self {
49 nativeAccessError::UnknownChain => AccessError::UnknownChain,
50 nativeAccessError::UnknownTx => AccessError::UnknownTx,
54 pub(crate) fn native_into(native: nativeAccessError) -> Self {
56 nativeAccessError::UnknownChain => AccessError::UnknownChain,
57 nativeAccessError::UnknownTx => AccessError::UnknownTx,
61 /// Creates a copy of the AccessError
63 pub extern "C" fn AccessError_clone(orig: &AccessError) -> AccessError {
66 /// The `Access` trait defines behavior for accessing chain data and state, such as blocks and
70 /// An opaque pointer which is passed to your function implementations as an argument.
71 /// This has no meaning in the LDK, and can be NULL or any other value.
72 pub this_arg: *mut c_void,
73 /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
74 /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output
77 /// [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
79 pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::c_types::derived::CResult_TxOutAccessErrorZ,
80 /// Frees any resources associated with this object given its this_arg pointer.
81 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
82 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
84 unsafe impl Send for Access {}
85 unsafe impl Sync for Access {}
87 use lightning::chain::Access as rustAccess;
88 impl rustAccess for Access {
89 fn get_utxo(&self, genesis_hash: &bitcoin::hash_types::BlockHash, short_channel_id: u64) -> Result<bitcoin::blockdata::transaction::TxOut, lightning::chain::AccessError> {
90 let mut ret = (self.get_utxo)(self.this_arg, genesis_hash.as_inner(), short_channel_id);
91 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })};
96 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
97 // directly as a Deref trait in higher-level structs:
98 impl std::ops::Deref for Access {
100 fn deref(&self) -> &Self {
104 /// Calls the free function if one is set
106 pub extern "C" fn Access_free(this_ptr: Access) { }
107 impl Drop for Access {
109 if let Some(f) = self.free {
114 /// The `Listen` trait is used to notify when blocks have been connected or disconnected from the
117 /// Useful when needing to replay chain data upon startup or as new chain events occur. Clients
118 /// sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`].
119 /// Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers
123 /// An opaque pointer which is passed to your function implementations as an argument.
124 /// This has no meaning in the LDK, and can be NULL or any other value.
125 pub this_arg: *mut c_void,
126 /// Notifies the listener that a block was added at the given height.
127 pub block_connected: extern "C" fn (this_arg: *const c_void, block: crate::c_types::u8slice, height: u32),
128 /// Notifies the listener that a block was removed at the given height.
129 pub block_disconnected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32),
130 /// Frees any resources associated with this object given its this_arg pointer.
131 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
132 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
135 use lightning::chain::Listen as rustListen;
136 impl rustListen for Listen {
137 fn block_connected(&self, block: &bitcoin::blockdata::block::Block, height: u32) {
138 let mut local_block = ::bitcoin::consensus::encode::serialize(block);
139 (self.block_connected)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block), height)
141 fn block_disconnected(&self, header: &bitcoin::blockdata::block::BlockHeader, height: u32) {
142 let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
143 (self.block_disconnected)(self.this_arg, &local_header, height)
147 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
148 // directly as a Deref trait in higher-level structs:
149 impl std::ops::Deref for Listen {
151 fn deref(&self) -> &Self {
155 /// Calls the free function if one is set
157 pub extern "C" fn Listen_free(this_ptr: Listen) { }
158 impl Drop for Listen {
160 if let Some(f) = self.free {
165 /// The `Confirm` trait is used to notify when transactions have been confirmed on chain or
166 /// unconfirmed during a chain reorganization.
168 /// Clients sourcing chain data using a transaction-oriented API should prefer this interface over
169 /// [`Listen`]. For instance, an Electrum client may implement [`Filter`] by subscribing to activity
170 /// related to registered transactions and outputs. Upon notification, it would pass along the
171 /// matching transactions using this interface.
175 /// The intended use is as follows:
176 /// - Call [`transactions_confirmed`] to process any on-chain activity of interest.
177 /// - Call [`transaction_unconfirmed`] to process any transaction returned by [`get_relevant_txids`]
178 /// that has been reorganized out of the chain.
179 /// - Call [`best_block_updated`] whenever a new chain tip becomes available.
183 /// Clients must call these methods in chain order. Specifically:
184 /// - Transactions confirmed in a block must be given before transactions confirmed in a later
186 /// - Dependent transactions within the same block must be given in topological order, possibly in
188 /// - Unconfirmed transactions must be given after the original confirmations and before any
191 /// See individual method documentation for further details.
193 /// [`transactions_confirmed`]: Self::transactions_confirmed
194 /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
195 /// [`best_block_updated`]: Self::best_block_updated
196 /// [`get_relevant_txids`]: Self::get_relevant_txids
199 /// An opaque pointer which is passed to your function implementations as an argument.
200 /// This has no meaning in the LDK, and can be NULL or any other value.
201 pub this_arg: *mut c_void,
202 /// Processes transactions confirmed in a block with a given header and height.
204 /// Should be called for any transactions registered by [`Filter::register_tx`] or any
205 /// transactions spending an output registered by [`Filter::register_output`]. Such transactions
206 /// appearing in the same block do not need to be included in the same call; instead, multiple
207 /// calls with additional transactions may be made so long as they are made in [chain order].
209 /// May be called before or after [`best_block_updated`] for the corresponding block. However,
210 /// in the event of a chain reorganization, it must not be called with a `header` that is no
211 /// longer in the chain as of the last call to [`best_block_updated`].
213 /// [chain order]: Self#order
214 /// [`best_block_updated`]: Self::best_block_updated
215 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),
216 /// Processes a transaction that is no longer confirmed as result of a chain reorganization.
218 /// Should be called for any transaction returned by [`get_relevant_txids`] if it has been
219 /// reorganized out of the best chain. Once called, the given transaction should not be returned
220 /// by [`get_relevant_txids`] unless it has been reconfirmed via [`transactions_confirmed`].
222 /// [`get_relevant_txids`]: Self::get_relevant_txids
223 /// [`transactions_confirmed`]: Self::transactions_confirmed
224 pub transaction_unconfirmed: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32]),
225 /// Processes an update to the best header connected at the given height.
227 /// Should be called when a new header is available but may be skipped for intermediary blocks
228 /// if they become available at the same time.
229 pub best_block_updated: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32),
230 /// Returns transactions that should be monitored for reorganization out of the chain.
232 /// Should include any transactions passed to [`transactions_confirmed`] that have insufficient
233 /// confirmations to be safe from a chain reorganization. Should not include any transactions
234 /// passed to [`transaction_unconfirmed`] unless later reconfirmed.
236 /// May be called to determine the subset of transactions that must still be monitored for
237 /// reorganization. Will be idempotent between calls but may change as a result of calls to the
238 /// other interface methods. Thus, this is useful to determine which transactions may need to be
239 /// given to [`transaction_unconfirmed`].
241 /// [`transactions_confirmed`]: Self::transactions_confirmed
242 /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed
244 pub get_relevant_txids: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_TxidZ,
245 /// Frees any resources associated with this object given its this_arg pointer.
246 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
247 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
250 use lightning::chain::Confirm as rustConfirm;
251 impl rustConfirm for Confirm {
252 fn transactions_confirmed(&self, header: &bitcoin::blockdata::block::BlockHeader, txdata: &lightning::chain::transaction::TransactionData, height: u32) {
253 let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
254 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 }); };
255 (self.transactions_confirmed)(self.this_arg, &local_header, local_txdata.into(), height)
257 fn transaction_unconfirmed(&self, txid: &bitcoin::hash_types::Txid) {
258 (self.transaction_unconfirmed)(self.this_arg, txid.as_inner())
260 fn best_block_updated(&self, header: &bitcoin::blockdata::block::BlockHeader, height: u32) {
261 let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
262 (self.best_block_updated)(self.this_arg, &local_header, height)
264 fn get_relevant_txids(&self) -> Vec<bitcoin::hash_types::Txid> {
265 let mut ret = (self.get_relevant_txids)(self.this_arg);
266 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() }); };
271 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
272 // directly as a Deref trait in higher-level structs:
273 impl std::ops::Deref for Confirm {
275 fn deref(&self) -> &Self {
279 /// Calls the free function if one is set
281 pub extern "C" fn Confirm_free(this_ptr: Confirm) { }
282 impl Drop for Confirm {
284 if let Some(f) = self.free {
289 /// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
290 /// blocks are connected and disconnected.
292 /// Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
293 /// responsible for maintaining a set of monitors such that they can be updated accordingly as
294 /// channel state changes and HTLCs are resolved. See method documentation for specific
297 /// Implementations **must** ensure that updates are successfully applied and persisted upon method
298 /// completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
299 /// without taking any further action such as persisting the current state.
301 /// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
302 /// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
303 /// could result in a revoked transaction being broadcast, allowing the counterparty to claim all
304 /// funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
305 /// multiple instances.
307 /// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
308 /// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
309 /// [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure
312 /// An opaque pointer which is passed to your function implementations as an argument.
313 /// This has no meaning in the LDK, and can be NULL or any other value.
314 pub this_arg: *mut c_void,
315 /// Watches a channel identified by `funding_txo` using `monitor`.
317 /// Implementations are responsible for watching the chain for the funding transaction along
318 /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
319 /// calling [`block_connected`] and [`block_disconnected`] on the monitor.
321 /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
322 /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
323 /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
325 pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
326 /// Updates a channel identified by `funding_txo` by applying `update` to its monitor.
328 /// Implementations must call [`update_monitor`] with the given update. See
329 /// [`ChannelMonitorUpdateErr`] for invariants around returning an error.
331 /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor
332 /// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
334 pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
335 /// Returns any monitor events since the last call. Subsequent calls must only return new
338 pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ,
339 /// Frees any resources associated with this object given its this_arg pointer.
340 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
341 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
343 unsafe impl Send for Watch {}
344 unsafe impl Sync for Watch {}
346 use lightning::chain::Watch as rustWatch;
347 impl rustWatch<crate::lightning::chain::keysinterface::Sign> for Watch {
348 fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::chain::keysinterface::Sign>) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> {
349 let mut ret = (self.watch_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
350 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })};
353 fn update_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, update: lightning::chain::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> {
354 let mut ret = (self.update_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(update)), is_owned: true });
355 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })};
358 fn release_pending_monitor_events(&self) -> Vec<lightning::chain::channelmonitor::MonitorEvent> {
359 let mut ret = (self.release_pending_monitor_events)(self.this_arg);
360 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
365 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
366 // directly as a Deref trait in higher-level structs:
367 impl std::ops::Deref for Watch {
369 fn deref(&self) -> &Self {
373 /// Calls the free function if one is set
375 pub extern "C" fn Watch_free(this_ptr: Watch) { }
376 impl Drop for Watch {
378 if let Some(f) = self.free {
383 /// The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
386 /// This is useful in order to have a [`Watch`] implementation convey to a chain source which
387 /// transactions to be notified of. Notification may take the form of pre-filtering blocks or, in
388 /// the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If
389 /// receiving full blocks from a chain source, any further filtering is unnecessary.
391 /// After an output has been registered, subsequent block retrievals from the chain source must not
392 /// exclude any transactions matching the new criteria nor any in-block descendants of such
395 /// Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter`
396 /// should not block on I/O. Implementations should instead queue the newly monitored data to be
397 /// processed later. Then, in order to block until the data has been processed, any [`Watch`]
398 /// invocation that has called the `Filter` must return [`TemporaryFailure`].
400 /// [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure
401 /// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
402 /// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
405 /// An opaque pointer which is passed to your function implementations as an argument.
406 /// This has no meaning in the LDK, and can be NULL or any other value.
407 pub this_arg: *mut c_void,
408 /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
409 /// a spending condition.
410 pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice),
411 /// Registers interest in spends of a transaction output.
413 /// Optionally, when `output.block_hash` is set, should return any transaction spending the
414 /// output that is found in the corresponding block along with its index.
416 /// This return value is useful for Electrum clients in order to supply in-block descendant
417 /// transactions which otherwise were not included. This is not necessary for other clients if
418 /// such descendant transactions were already included (e.g., when a BIP 157 client provides the
421 pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::lightning::chain::WatchedOutput) -> crate::c_types::derived::COption_C2Tuple_usizeTransactionZZ,
422 /// Frees any resources associated with this object given its this_arg pointer.
423 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
424 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
426 unsafe impl Send for Filter {}
427 unsafe impl Sync for Filter {}
429 use lightning::chain::Filter as rustFilter;
430 impl rustFilter for Filter {
431 fn register_tx(&self, txid: &bitcoin::hash_types::Txid, script_pubkey: &bitcoin::blockdata::script::Script) {
432 (self.register_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pubkey[..]))
434 fn register_output(&self, output: lightning::chain::WatchedOutput) -> Option<(usize, bitcoin::blockdata::transaction::Transaction)> {
435 let mut ret = (self.register_output)(self.this_arg, crate::lightning::chain::WatchedOutput { inner: Box::into_raw(Box::new(output)), is_owned: true });
436 let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_bitcoin()); local_ret_0 }) } else { None };
441 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
442 // directly as a Deref trait in higher-level structs:
443 impl std::ops::Deref for Filter {
445 fn deref(&self) -> &Self {
449 /// Calls the free function if one is set
451 pub extern "C" fn Filter_free(this_ptr: Filter) { }
452 impl Drop for Filter {
454 if let Some(f) = self.free {
460 use lightning::chain::WatchedOutput as nativeWatchedOutputImport;
461 type nativeWatchedOutput = nativeWatchedOutputImport;
463 /// A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
465 /// Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
466 /// spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
467 /// the return value of [`Filter::register_output`].
469 /// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
470 /// may have been spent there. See [`Filter::register_output`] for details.
472 /// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
473 /// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
476 pub struct WatchedOutput {
477 /// A pointer to the opaque Rust object.
479 /// Nearly everywhere, inner must be non-null, however in places where
480 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
481 pub inner: *mut nativeWatchedOutput,
482 /// Indicates that this is the only struct which contains the same pointer.
484 /// Rust functions which take ownership of an object provided via an argument require
485 /// this to be true and invalidate the object pointed to by inner.
489 impl Drop for WatchedOutput {
491 if self.is_owned && !<*mut nativeWatchedOutput>::is_null(self.inner) {
492 let _ = unsafe { Box::from_raw(self.inner) };
496 /// Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL.
498 pub extern "C" fn WatchedOutput_free(this_obj: WatchedOutput) { }
500 /// Used only if an object of this type is returned as a trait impl by a method
501 extern "C" fn WatchedOutput_free_void(this_ptr: *mut c_void) {
502 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWatchedOutput); }
505 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
507 pub(crate) fn take_inner(mut self) -> *mut nativeWatchedOutput {
508 assert!(self.is_owned);
509 let ret = self.inner;
510 self.inner = std::ptr::null_mut();
514 /// First block where the transaction output may have been spent.
516 pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::ThirtyTwoBytes {
517 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.block_hash;
518 let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).into_inner() } } };
521 /// First block where the transaction output may have been spent.
523 pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::ThirtyTwoBytes) {
524 let mut local_val = if val.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap() }) };
525 unsafe { &mut *this_ptr.inner }.block_hash = local_val;
527 /// Outpoint identifying the transaction output.
529 pub extern "C" fn WatchedOutput_get_outpoint(this_ptr: &WatchedOutput) -> crate::lightning::chain::transaction::OutPoint {
530 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint;
531 crate::lightning::chain::transaction::OutPoint { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
533 /// Outpoint identifying the transaction output.
535 pub extern "C" fn WatchedOutput_set_outpoint(this_ptr: &mut WatchedOutput, mut val: crate::lightning::chain::transaction::OutPoint) {
536 unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
538 /// Spending condition of the transaction output.
540 pub extern "C" fn WatchedOutput_get_script_pubkey(this_ptr: &WatchedOutput) -> crate::c_types::u8slice {
541 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.script_pubkey;
542 crate::c_types::u8slice::from_slice(&inner_val[..])
544 /// Spending condition of the transaction output.
546 pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::CVec_u8Z) {
547 unsafe { &mut *this_ptr.inner }.script_pubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
549 /// Constructs a new WatchedOutput given each field
552 pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput {
553 let mut local_block_hash_arg = if block_hash_arg.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&block_hash_arg.data[..]).unwrap() }) };
554 WatchedOutput { inner: Box::into_raw(Box::new(nativeWatchedOutput {
555 block_hash: local_block_hash_arg,
556 outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
557 script_pubkey: ::bitcoin::blockdata::script::Script::from(script_pubkey_arg.into_rust()),
558 })), is_owned: true }