bool result_ok;
} LDKCResult_TxOutAccessErrorZ;
+typedef enum LDKCOption_C2Tuple_usizeTransactionZZ_Tag {
+ LDKCOption_C2Tuple_usizeTransactionZZ_Some,
+ LDKCOption_C2Tuple_usizeTransactionZZ_None,
+ /**
+ * Must be last for serialization purposes
+ */
+ LDKCOption_C2Tuple_usizeTransactionZZ_Sentinel,
+} LDKCOption_C2Tuple_usizeTransactionZZ_Tag;
+
+typedef struct LDKCOption_C2Tuple_usizeTransactionZZ {
+ LDKCOption_C2Tuple_usizeTransactionZZ_Tag tag;
+ union {
+ struct {
+ struct LDKC2Tuple_usizeTransactionZ some;
+ };
+ };
+} LDKCOption_C2Tuple_usizeTransactionZZ;
+
/**
* A Rust str object, ie a reference to a UTF8-valid string.
* This is *not* null-terminated so cannot be used directly as a C string!
void (*free)(void *this_arg);
} LDKListen;
+
+
+/**
+ * A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
+ *
+ * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
+ * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
+ * the return value of [`Filter::register_output`].
+ *
+ * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
+ * may have been spent there. See [`Filter::register_output`] for details.
+ *
+ * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
+ * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
+ */
+typedef struct MUST_USE_STRUCT LDKWatchedOutput {
+ /**
+ * A pointer to the opaque Rust object.
+ * Nearly everywhere, inner must be non-null, however in places where
+ * the Rust equivalent takes an Option, it may be set to null to indicate None.
+ */
+ LDKnativeWatchedOutput *inner;
+ /**
+ * Indicates that this is the only struct which contains the same pointer.
+ * Rust functions which take ownership of an object provided via an argument require
+ * this to be true and invalidate the object pointed to by inner.
+ */
+ bool is_owned;
+} LDKWatchedOutput;
+
/**
* The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
* channels.
*/
void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey);
/**
- * Registers interest in spends of a transaction output identified by `outpoint` having
- * `script_pubkey` as the spending condition.
+ * Registers interest in spends of a transaction output.
+ *
+ * Optionally, when `output.block_hash` is set, should return any transaction spending the
+ * output that is found in the corresponding block along with its index.
+ *
+ * This return value is useful for Electrum clients in order to supply in-block descendant
+ * transactions which otherwise were not included. This is not necessary for other clients if
+ * such descendant transactions were already included (e.g., when a BIP 157 client provides the
+ * full block).
*/
- void (*register_output)(const void *this_arg, const struct LDKOutPoint *NONNULL_PTR outpoint, struct LDKu8slice script_pubkey);
+ struct LDKCOption_C2Tuple_usizeTransactionZZ (*register_output)(const void *this_arg, struct LDKWatchedOutput output);
/**
* 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.
struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig);
+void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res);
+
struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void);
struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e);
*/
void Filter_free(struct LDKFilter this_ptr);
+/**
+ * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL.
+ */
+void WatchedOutput_free(struct LDKWatchedOutput this_obj);
+
+/**
+ * First block where the transaction output may have been spent.
+ */
+struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr);
+
+/**
+ * First block where the transaction output may have been spent.
+ */
+void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
+
+/**
+ * Outpoint identifying the transaction output.
+ */
+struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr);
+
+/**
+ * Outpoint identifying the transaction output.
+ */
+void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val);
+
+/**
+ * Spending condition of the transaction output.
+ */
+struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr);
+
+/**
+ * Spending condition of the transaction output.
+ */
+void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val);
+
+/**
+ * Constructs a new WatchedOutput given each field
+ */
+MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg);
+
/**
* Calls the free function if one is set
*/
const LDKFilter* operator &() const { return &self; }
const LDKFilter* operator ->() const { return &self; }
};
+class WatchedOutput {
+private:
+ LDKWatchedOutput self;
+public:
+ WatchedOutput(const WatchedOutput&) = delete;
+ WatchedOutput(WatchedOutput&& o) : self(o.self) { memset(&o, 0, sizeof(WatchedOutput)); }
+ WatchedOutput(LDKWatchedOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatchedOutput)); }
+ operator LDKWatchedOutput() && { LDKWatchedOutput res = self; memset(&self, 0, sizeof(LDKWatchedOutput)); return res; }
+ ~WatchedOutput() { WatchedOutput_free(self); }
+ WatchedOutput& operator=(WatchedOutput&& o) { WatchedOutput_free(self); self = o.self; memset(&o, 0, sizeof(WatchedOutput)); return *this; }
+ LDKWatchedOutput* operator &() { return &self; }
+ LDKWatchedOutput* operator ->() { return &self; }
+ const LDKWatchedOutput* operator &() const { return &self; }
+ const LDKWatchedOutput* operator ->() const { return &self; }
+};
class BroadcasterInterface {
private:
LDKBroadcasterInterface self;
const LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() const { return &self; }
};
+class COption_C2Tuple_usizeTransactionZZ {
+private:
+ LDKCOption_C2Tuple_usizeTransactionZZ self;
+public:
+ COption_C2Tuple_usizeTransactionZZ(const COption_C2Tuple_usizeTransactionZZ&) = delete;
+ COption_C2Tuple_usizeTransactionZZ(COption_C2Tuple_usizeTransactionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_usizeTransactionZZ)); }
+ COption_C2Tuple_usizeTransactionZZ(LDKCOption_C2Tuple_usizeTransactionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_usizeTransactionZZ)); }
+ operator LDKCOption_C2Tuple_usizeTransactionZZ() && { LDKCOption_C2Tuple_usizeTransactionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_usizeTransactionZZ)); return res; }
+ ~COption_C2Tuple_usizeTransactionZZ() { COption_C2Tuple_usizeTransactionZZ_free(self); }
+ COption_C2Tuple_usizeTransactionZZ& operator=(COption_C2Tuple_usizeTransactionZZ&& o) { COption_C2Tuple_usizeTransactionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_usizeTransactionZZ)); return *this; }
+ LDKCOption_C2Tuple_usizeTransactionZZ* operator &() { return &self; }
+ LDKCOption_C2Tuple_usizeTransactionZZ* operator ->() { return &self; }
+ const LDKCOption_C2Tuple_usizeTransactionZZ* operator &() const { return &self; }
+ const LDKCOption_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; }
+};
class CResult_TransactionNoneZ {
private:
LDKCResult_TransactionNoneZ self;
typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate;
struct nativeChannelMonitorOpaque;
typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor;
+struct nativeWatchedOutputOpaque;
+typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput;
struct nativeChannelManagerOpaque;
typedef struct nativeChannelManagerOpaque LDKnativeChannelManager;
struct nativeChainParametersOpaque;
#[no_mangle]
pub extern "C" fn CResult_TxOutAccessErrorZ_clone(orig: &CResult_TxOutAccessErrorZ) -> CResult_TxOutAccessErrorZ { orig.clone() }
#[repr(C)]
+pub enum COption_C2Tuple_usizeTransactionZZ {
+ Some(crate::c_types::derived::C2Tuple_usizeTransactionZ),
+ None
+}
+impl COption_C2Tuple_usizeTransactionZZ {
+ #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
+ if let Self::Some(_) = self { true } else { false }
+ }
+ #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_usizeTransactionZ {
+ if let Self::Some(v) = self { v } else { unreachable!() }
+ }
+}
+#[no_mangle]
+pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_free(_res: COption_C2Tuple_usizeTransactionZZ) { }
+#[repr(C)]
pub union CResult_NoneAPIErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
pub result: *mut std::ffi::c_void,
/// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
/// a spending condition.
pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice),
- /// Registers interest in spends of a transaction output identified by `outpoint` having
- /// `script_pubkey` as the spending condition.
- pub register_output: extern "C" fn (this_arg: *const c_void, outpoint: &crate::chain::transaction::OutPoint, script_pubkey: crate::c_types::u8slice),
+ /// Registers interest in spends of a transaction output.
+ ///
+ /// Optionally, when `output.block_hash` is set, should return any transaction spending the
+ /// output that is found in the corresponding block along with its index.
+ ///
+ /// This return value is useful for Electrum clients in order to supply in-block descendant
+ /// transactions which otherwise were not included. This is not necessary for other clients if
+ /// such descendant transactions were already included (e.g., when a BIP 157 client provides the
+ /// full block).
+ #[must_use]
+ pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::chain::WatchedOutput) -> crate::c_types::derived::COption_C2Tuple_usizeTransactionZZ,
/// 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<extern "C" fn(this_arg: *mut c_void)>,
fn register_tx(&self, txid: &bitcoin::hash_types::Txid, script_pubkey: &bitcoin::blockdata::script::Script) {
(self.register_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pubkey[..]))
}
- fn register_output(&self, outpoint: &lightning::chain::transaction::OutPoint, script_pubkey: &bitcoin::blockdata::script::Script) {
- (self.register_output)(self.this_arg, &crate::chain::transaction::OutPoint { inner: unsafe { (outpoint as *const _) as *mut _ }, is_owned: false }, crate::c_types::u8slice::from_slice(&script_pubkey[..]))
+ fn register_output(&self, output: lightning::chain::WatchedOutput) -> Option<(usize, bitcoin::blockdata::transaction::Transaction)> {
+ let mut ret = (self.register_output)(self.this_arg, crate::chain::WatchedOutput { inner: Box::into_raw(Box::new(output)), is_owned: true });
+ 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 };
+ local_ret
}
}
}
}
}
+
+use lightning::chain::WatchedOutput as nativeWatchedOutputImport;
+type nativeWatchedOutput = nativeWatchedOutputImport;
+
+/// A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
+///
+/// Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
+/// spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
+/// the return value of [`Filter::register_output`].
+///
+/// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
+/// may have been spent there. See [`Filter::register_output`] for details.
+///
+/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
+/// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
+#[must_use]
+#[repr(C)]
+pub struct WatchedOutput {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeWatchedOutput,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for WatchedOutput {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeWatchedOutput>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(self.inner) };
+ }
+ }
+}
+/// Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn WatchedOutput_free(this_obj: WatchedOutput) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn WatchedOutput_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWatchedOutput); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl WatchedOutput {
+ pub(crate) fn take_inner(mut self) -> *mut nativeWatchedOutput {
+ assert!(self.is_owned);
+ let ret = self.inner;
+ self.inner = std::ptr::null_mut();
+ ret
+ }
+}
+/// First block where the transaction output may have been spent.
+#[no_mangle]
+pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::ThirtyTwoBytes {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.block_hash;
+ 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() } } };
+ local_inner_val
+}
+/// First block where the transaction output may have been spent.
+#[no_mangle]
+pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::ThirtyTwoBytes) {
+ let mut local_val = if val.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap() }) };
+ unsafe { &mut *this_ptr.inner }.block_hash = local_val;
+}
+/// Outpoint identifying the transaction output.
+#[no_mangle]
+pub extern "C" fn WatchedOutput_get_outpoint(this_ptr: &WatchedOutput) -> crate::chain::transaction::OutPoint {
+ let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint;
+ crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Outpoint identifying the transaction output.
+#[no_mangle]
+pub extern "C" fn WatchedOutput_set_outpoint(this_ptr: &mut WatchedOutput, mut val: crate::chain::transaction::OutPoint) {
+ unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Spending condition of the transaction output.
+#[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)[..])
+}
+/// Spending condition of the transaction output.
+#[no_mangle]
+pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::CVec_u8Z) {
+ unsafe { &mut *this_ptr.inner }.script_pubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
+}
+/// Constructs a new WatchedOutput given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut outpoint_arg: crate::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput {
+ 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() }) };
+ WatchedOutput { inner: Box::into_raw(Box::new(nativeWatchedOutput {
+ block_hash: local_block_hash_arg,
+ outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
+ script_pubkey: ::bitcoin::blockdata::script::Script::from(script_pubkey_arg.into_rust()),
+ })), is_owned: true }
+}