//! future, as well as generate and broadcast funding transactions handle payment preimages and a
//! few other things.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Some information provided on receipt of payment depends on whether the payment received is a
/// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice.
/// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
payment_secret: crate::c_types::ThirtyTwoBytes,
- /// This is the `user_payment_id` which was provided to
- /// [`ChannelManager::create_inbound_payment_for_hash`] or
- /// [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is
- /// simply copied here. It may be used to correlate PaymentReceived events with invoice
- /// metadata stored elsewhere.
- ///
- /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
- /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
- user_payment_id: u64,
},
/// Because this is a spontaneous payment, the payer generated their own preimage rather than us
/// (the payee) providing a preimage.
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativePaymentPurpose {
match self {
- PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, ref user_payment_id, } => {
+ PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => {
let mut payment_preimage_nonref = (*payment_preimage).clone();
let mut local_payment_preimage_nonref = if payment_preimage_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data) }) };
let mut payment_secret_nonref = (*payment_secret).clone();
- let mut user_payment_id_nonref = (*user_payment_id).clone();
nativePaymentPurpose::InvoicePayment {
payment_preimage: local_payment_preimage_nonref,
payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data),
- user_payment_id: user_payment_id_nonref,
}
},
PaymentPurpose::SpontaneousPayment (ref a, ) => {
#[allow(unused)]
pub(crate) fn into_native(self) -> nativePaymentPurpose {
match self {
- PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, mut user_payment_id, } => {
+ PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => {
let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
nativePaymentPurpose::InvoicePayment {
payment_preimage: local_payment_preimage,
payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data),
- user_payment_id: user_payment_id,
}
},
PaymentPurpose::SpontaneousPayment (mut a, ) => {
#[allow(unused)]
pub(crate) fn from_native(native: &nativePaymentPurpose) -> Self {
match native {
- nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, ref user_payment_id, } => {
+ nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => {
let mut payment_preimage_nonref = (*payment_preimage).clone();
let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage_nonref.unwrap()).0 } } };
let mut payment_secret_nonref = (*payment_secret).clone();
- let mut user_payment_id_nonref = (*user_payment_id).clone();
PaymentPurpose::InvoicePayment {
payment_preimage: local_payment_preimage_nonref,
payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 },
- user_payment_id: user_payment_id_nonref,
}
},
nativePaymentPurpose::SpontaneousPayment (ref a, ) => {
#[allow(unused)]
pub(crate) fn native_into(native: nativePaymentPurpose) -> Self {
match native {
- nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, mut user_payment_id, } => {
+ nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => {
let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage.unwrap()).0 } } };
PaymentPurpose::InvoicePayment {
payment_preimage: local_payment_preimage,
payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 },
- user_payment_id: user_payment_id,
}
},
nativePaymentPurpose::SpontaneousPayment (mut a, ) => {
}
#[no_mangle]
/// Utility method to constructs a new InvoicePayment-variant PaymentPurpose
-pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes, user_payment_id: u64) -> PaymentPurpose {
+pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
PaymentPurpose::InvoicePayment {
payment_preimage,
payment_secret,
- user_payment_id,
}
}
#[no_mangle]
/// commitment transaction came from our counterparty, but it may also have come from
/// a copy of our own `ChannelMonitor`.
CommitmentTxConfirmed,
+ /// The funding transaction failed to confirm in a timely manner on an inbound channel.
+ FundingTimedOut,
/// Closure generated from processing an event, likely a HTLC forward/relay/reception.
ProcessingError {
/// A developer-readable error message which we generated.
ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
+ ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
ClosureReason::ProcessingError {ref err, } => {
let mut err_nonref = (*err).clone();
nativeClosureReason::ProcessingError {
ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
+ ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
ClosureReason::ProcessingError {mut err, } => {
nativeClosureReason::ProcessingError {
err: err.into_string(),
nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
+ nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
nativeClosureReason::ProcessingError {ref err, } => {
let mut err_nonref = (*err).clone();
ClosureReason::ProcessingError {
nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
+ nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
nativeClosureReason::ProcessingError {mut err, } => {
ClosureReason::ProcessingError {
err: err.into(),
pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
ClosureReason::CommitmentTxConfirmed}
#[no_mangle]
+/// Utility method to constructs a new FundingTimedOut-variant ClosureReason
+pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason {
+ ClosureReason::FundingTimedOut}
+#[no_mangle]
/// Utility method to constructs a new ProcessingError-variant ClosureReason
pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
ClosureReason::ProcessingError {
ClosureReason::OutdatedChannelManager}
#[no_mangle]
/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
-pub extern "C" fn ClosureReason_write(obj: &ClosureReason) -> crate::c_types::derived::CVec_u8Z {
+pub extern "C" fn ClosureReason_write(obj: &crate::lightning::util::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
}
+#[no_mangle]
+/// Read a ClosureReason from a byte array, created by ClosureReason_write
+pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ {
+ let res: Result<Option<lightning::util::events::ClosureReason>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::util::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
/// An Event which you should probably take some action in response to.
///
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
#[repr(C)]
pub enum Event {
/// Used to indicate that the client should generate a funding transaction with the given
- /// parameters and then call ChannelManager::funding_transaction_generated.
- /// Generated in ChannelManager message handling.
+ /// parameters and then call [`ChannelManager::funding_transaction_generated`].
+ /// Generated in [`ChannelManager`] message handling.
/// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
/// counterparty can steal your funds!
+ ///
+ /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+ /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
FundingGenerationReady {
/// The random channel_id we picked which you'll need to pass into
/// ChannelManager::funding_transaction_generated.
channel_value_satoshis: u64,
/// The script which should be used in the transaction output.
output_script: crate::c_types::derived::CVec_u8Z,
- /// The value passed in to ChannelManager::create_channel
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+ /// an inbound channel.
+ ///
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
user_channel_id: u64,
},
/// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
- /// ChannelManager::claim_funds to get it....
- /// Note that if the preimage is not known or the amount paid is incorrect, you should call
- /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
+ /// [`ChannelManager::claim_funds`] to get it....
+ /// Note that if the preimage is not known, you should call
+ /// [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
/// network congestion.
- /// The amount paid should be considered 'incorrect' when it is less than or more than twice
- /// the amount expected.
- /// If you fail to call either ChannelManager::claim_funds or
- /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
+ /// If you fail to call either [`ChannelManager::claim_funds`] or
+ /// [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
/// automatically failed.
+ ///
+ /// # Note
+ /// LDK will not stop an inbound payment from being paid multiple times, so multiple
+ /// `PaymentReceived` events may be generated for the same payment.
+ ///
+ /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
+ /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
PaymentReceived {
- /// The hash for which the preimage should be handed to the ChannelManager.
+ /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
+ /// not stop you from registering duplicate payment hashes for inbound payments.
payment_hash: crate::c_types::ThirtyTwoBytes,
- /// The value, in thousandths of a satoshi, that this payment is for. Note that you must
- /// compare this to the expected value before accepting the payment (as otherwise you are
- /// providing proof-of-payment for less than the value you expected!).
+ /// The value, in thousandths of a satoshi, that this payment is for.
amt: u64,
/// Information for claiming this received payment, based on whether the purpose of the
/// payment is to pay an invoice or to send a spontaneous payment.
/// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
/// event. In this situation, you SHOULD treat this payment as having succeeded.
PaymentSent {
+ /// The id returned by [`ChannelManager::send_payment`] and used with
+ /// [`ChannelManager::retry_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ payment_id: crate::c_types::ThirtyTwoBytes,
/// The preimage to the hash given to ChannelManager::send_payment.
/// Note that this serves as a payment receipt, if you wish to have such a thing, you must
/// store it somehow!
payment_preimage: crate::c_types::ThirtyTwoBytes,
+ /// The hash that was given to [`ChannelManager::send_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ /// The total fee which was spent at intermediate hops in this payment, across all paths.
+ ///
+ /// Note that, like [`Route::get_total_fees`] this does *not* include any potential
+ /// overpayment to the recipient node.
+ ///
+ /// If the recipient or an intermediate node misbehaves and gives us free money, this may
+ /// overstate the amount paid, though this is unlikely.
+ ///
+ /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
+ fee_paid_msat: crate::c_types::derived::COption_u64Z,
},
- /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
+ /// Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
/// something. You may wish to retry with a different route.
+ ///
+ /// Note that this does *not* indicate that all paths for an MPP payment have failed, see
+ /// [`Event::PaymentFailed`] and [`all_paths_failed`].
+ ///
+ /// [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
PaymentPathFailed {
- /// The hash which was given to ChannelManager::send_payment.
+ /// The id returned by [`ChannelManager::send_payment`] and used with
+ /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// The hash that was given to [`ChannelManager::send_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
payment_hash: crate::c_types::ThirtyTwoBytes,
/// Indicates the payment was rejected for some reason by the recipient. This implies that
/// the payment has failed, not just the route in question. If this is not set, you may
/// For both single-path and multi-path payments, this is set if all paths of the payment have
/// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
/// larger MPP payment were still in flight when this event was generated.
+ ///
+ /// Note that if you are retrying individual MPP parts, using this value to determine if a
+ /// payment has fully failed is race-y. Because multiple failures can happen prior to events
+ /// being processed, you may retry in response to a first failure, with a second failure
+ /// (with `all_paths_failed` set) still pending. Then, when the second failure is processed
+ /// you will see `all_paths_failed` set even though the retry of the first failure still
+ /// has an associated in-flight HTLC. See (1) for an example of such a failure.
+ ///
+ /// If you wish to retry individual MPP parts and learn when a payment has failed, you must
+ /// call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
+ ///
+ /// (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
+ ///
+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
all_paths_failed: bool,
/// The payment path that failed.
path: crate::c_types::derived::CVec_RouteHopZ,
+ /// The channel responsible for the failed payment path.
+ ///
+ /// If this is `Some`, then the corresponding channel should be avoided when the payment is
+ /// retried. May be `None` for older [`Event`] serializations.
+ short_channel_id: crate::c_types::derived::COption_u64Z,
+ /// Parameters needed to compute a new [`Route`] when retrying the failed payment path.
+ ///
+ /// See [`find_route`] for details.
+ ///
+ /// [`Route`]: crate::routing::router::Route
+ /// [`find_route`]: crate::routing::router::find_route
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ retry: crate::lightning::routing::router::RouteParameters,
},
- /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
- /// time in the future.
+ /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
+ /// provide failure information for each MPP part in the payment.
+ ///
+ /// This event is provided once there are no further pending HTLCs for the payment and the
+ /// payment is no longer retryable, either due to a several-block timeout or because
+ /// [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
+ ///
+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ PaymentFailed {
+ /// The id returned by [`ChannelManager::send_payment`] and used with
+ /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// The hash that was given to [`ChannelManager::send_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ },
+ /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
+ /// a time in the future.
+ ///
+ /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
PendingHTLCsForwardable {
/// The minimum amount of time that should be waited prior to calling
/// process_pending_htlc_forwards. To increase the effort required to correlate payments,
/// The channel_id of the channel which has been closed. Note that on-chain transactions
/// resolving the channel are likely still awaiting confirmation.
channel_id: crate::c_types::ThirtyTwoBytes,
+ /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+ /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
+ /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+ /// `user_channel_id` will be 0 for an inbound channel.
+ /// This will always be zero for objects serialized with LDK versions prior to 0.0.102.
+ ///
+ /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+ /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+ user_channel_id: u64,
/// The reason the channel was closed.
reason: crate::lightning::util::events::ClosureReason,
},
+ /// Used to indicate to the user that they can abandon the funding transaction and recycle the
+ /// inputs for another purpose.
+ DiscardFunding {
+ /// The channel_id of the channel which has been closed.
+ channel_id: crate::c_types::ThirtyTwoBytes,
+ /// The full transaction received from the user
+ transaction: crate::c_types::Transaction,
+ },
+ /// Indicates that a path for an outbound payment was successful.
+ ///
+ /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
+ /// [`Event::PaymentSent`] for obtaining the payment preimage.
+ PaymentPathSuccessful {
+ /// The id returned by [`ChannelManager::send_payment`] and used with
+ /// [`ChannelManager::retry_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// The hash that was given to [`ChannelManager::send_payment`].
+ ///
+ /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ /// The payment path that was successful.
+ ///
+ /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
+ path: crate::c_types::derived::CVec_RouteHopZ,
+ },
+ /// Indicates a request to open a new channel by a peer.
+ ///
+ /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
+ /// request, call [`ChannelManager::force_close_channel`].
+ ///
+ /// The event is only triggered when a new open channel request is received and the
+ /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
+ ///
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+ /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+ /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+ OpenChannelRequest {
+ /// The temporary channel ID of the channel requested to be opened.
+ ///
+ /// When responding to the request, the `temporary_channel_id` should be passed
+ /// back to the ChannelManager with [`ChannelManager::accept_inbound_channel`] to accept,
+ /// or to [`ChannelManager::force_close_channel`] to reject.
+ ///
+ /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+ /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+ temporary_channel_id: crate::c_types::ThirtyTwoBytes,
+ /// The node_id of the counterparty requesting to open the channel.
+ counterparty_node_id: crate::c_types::PublicKey,
+ /// The channel value of the requested channel.
+ funding_satoshis: u64,
+ /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
+ push_msat: u64,
+ /// The features that this channel will operate with. If you reject the channel, a
+ /// well-behaved counterparty may automatically re-attempt the channel with a new set of
+ /// feature flags.
+ ///
+ /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
+ /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
+ /// 0.0.106.
+ ///
+ /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+ channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
+ },
}
use lightning::util::events::Event as nativeEvent;
impl Event {
purpose: purpose_nonref.into_native(),
}
},
- Event::PaymentSent {ref payment_preimage, } => {
+ Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
let mut payment_preimage_nonref = (*payment_preimage).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut fee_paid_msat_nonref = (*fee_paid_msat).clone();
+ let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None };
nativeEvent::PaymentSent {
+ payment_id: local_payment_id_nonref,
payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
+ fee_paid_msat: local_fee_paid_msat_nonref,
}
},
- Event::PaymentPathFailed {ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, } => {
+ Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
let mut payment_hash_nonref = (*payment_hash).clone();
let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
let mut network_update_nonref = (*network_update).clone();
let mut all_paths_failed_nonref = (*all_paths_failed).clone();
let mut path_nonref = (*path).clone();
let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut short_channel_id_nonref = (*short_channel_id).clone();
+ let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
+ let mut retry_nonref = (*retry).clone();
+ let mut local_retry_nonref = if retry_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry_nonref.take_inner()) } }) };
nativeEvent::PaymentPathFailed {
+ payment_id: local_payment_id_nonref,
payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
rejected_by_dest: rejected_by_dest_nonref,
network_update: local_network_update_nonref,
all_paths_failed: all_paths_failed_nonref,
path: local_path_nonref,
+ short_channel_id: local_short_channel_id_nonref,
+ retry: local_retry_nonref,
+ }
+ },
+ Event::PaymentFailed {ref payment_id, ref payment_hash, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ nativeEvent::PaymentFailed {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
}
},
Event::PendingHTLCsForwardable {ref time_forwardable, } => {
let mut time_forwardable_nonref = (*time_forwardable).clone();
nativeEvent::PendingHTLCsForwardable {
- time_forwardable: std::time::Duration::from_secs(time_forwardable_nonref),
+ time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref),
}
},
Event::SpendableOutputs {ref outputs, } => {
claim_from_onchain_tx: claim_from_onchain_tx_nonref,
}
},
- Event::ChannelClosed {ref channel_id, ref reason, } => {
+ Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
let mut channel_id_nonref = (*channel_id).clone();
+ let mut user_channel_id_nonref = (*user_channel_id).clone();
let mut reason_nonref = (*reason).clone();
nativeEvent::ChannelClosed {
channel_id: channel_id_nonref.data,
+ user_channel_id: user_channel_id_nonref,
reason: reason_nonref.into_native(),
}
},
+ Event::DiscardFunding {ref channel_id, ref transaction, } => {
+ let mut channel_id_nonref = (*channel_id).clone();
+ let mut transaction_nonref = (*transaction).clone();
+ nativeEvent::DiscardFunding {
+ channel_id: channel_id_nonref.data,
+ transaction: transaction_nonref.into_bitcoin(),
+ }
+ },
+ Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) };
+ let mut path_nonref = (*path).clone();
+ let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ nativeEvent::PaymentPathSuccessful {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: local_payment_hash_nonref,
+ path: local_path_nonref,
+ }
+ },
+ Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
+ let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
+ let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
+ let mut funding_satoshis_nonref = (*funding_satoshis).clone();
+ let mut push_msat_nonref = (*push_msat).clone();
+ let mut channel_type_nonref = (*channel_type).clone();
+ nativeEvent::OpenChannelRequest {
+ temporary_channel_id: temporary_channel_id_nonref.data,
+ counterparty_node_id: counterparty_node_id_nonref.into_rust(),
+ funding_satoshis: funding_satoshis_nonref,
+ push_msat: push_msat_nonref,
+ channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
+ }
+ },
}
}
#[allow(unused)]
purpose: purpose.into_native(),
}
},
- Event::PaymentSent {mut payment_preimage, } => {
+ Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
+ let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
+ let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None };
nativeEvent::PaymentSent {
+ payment_id: local_payment_id,
payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
+ fee_paid_msat: local_fee_paid_msat,
}
},
- Event::PaymentPathFailed {mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, } => {
+ Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
+ let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
let mut local_network_update = { /* network_update*/ let network_update_opt = network_update; { } if network_update_opt.is_none() { None } else { Some({ network_update_opt.take().into_native() }) } };
let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
+ let mut local_retry = if retry.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry.take_inner()) } }) };
nativeEvent::PaymentPathFailed {
+ payment_id: local_payment_id,
payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
rejected_by_dest: rejected_by_dest,
network_update: local_network_update,
all_paths_failed: all_paths_failed,
path: local_path,
+ short_channel_id: local_short_channel_id,
+ retry: local_retry,
+ }
+ },
+ Event::PaymentFailed {mut payment_id, mut payment_hash, } => {
+ nativeEvent::PaymentFailed {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
}
},
Event::PendingHTLCsForwardable {mut time_forwardable, } => {
nativeEvent::PendingHTLCsForwardable {
- time_forwardable: std::time::Duration::from_secs(time_forwardable),
+ time_forwardable: core::time::Duration::from_secs(time_forwardable),
}
},
Event::SpendableOutputs {mut outputs, } => {
claim_from_onchain_tx: claim_from_onchain_tx,
}
},
- Event::ChannelClosed {mut channel_id, mut reason, } => {
+ Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
nativeEvent::ChannelClosed {
channel_id: channel_id.data,
+ user_channel_id: user_channel_id,
reason: reason.into_native(),
}
},
+ Event::DiscardFunding {mut channel_id, mut transaction, } => {
+ nativeEvent::DiscardFunding {
+ channel_id: channel_id.data,
+ transaction: transaction.into_bitcoin(),
+ }
+ },
+ Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
+ let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) };
+ let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ nativeEvent::PaymentPathSuccessful {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: local_payment_hash,
+ path: local_path,
+ }
+ },
+ Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
+ nativeEvent::OpenChannelRequest {
+ temporary_channel_id: temporary_channel_id.data,
+ counterparty_node_id: counterparty_node_id.into_rust(),
+ funding_satoshis: funding_satoshis,
+ push_msat: push_msat,
+ channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
+ }
+ },
}
}
#[allow(unused)]
purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref),
}
},
- nativeEvent::PaymentSent {ref payment_preimage, } => {
+ nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } };
let mut payment_preimage_nonref = (*payment_preimage).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut fee_paid_msat_nonref = (*fee_paid_msat).clone();
+ let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat_nonref.unwrap() }) };
Event::PaymentSent {
+ payment_id: local_payment_id_nonref,
payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ fee_paid_msat: local_fee_paid_msat_nonref,
}
},
- nativeEvent::PaymentPathFailed {ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, } => {
+ nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } };
let mut payment_hash_nonref = (*payment_hash).clone();
let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
let mut network_update_nonref = (*network_update).clone();
let mut all_paths_failed_nonref = (*all_paths_failed).clone();
let mut path_nonref = (*path).clone();
let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ let mut short_channel_id_nonref = (*short_channel_id).clone();
+ let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) };
+ let mut retry_nonref = (*retry).clone();
+ let mut local_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if retry_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry_nonref.unwrap())) } }, is_owned: true };
Event::PaymentPathFailed {
+ payment_id: local_payment_id_nonref,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
rejected_by_dest: rejected_by_dest_nonref,
network_update: local_network_update_nonref,
all_paths_failed: all_paths_failed_nonref,
path: local_path_nonref.into(),
+ short_channel_id: local_short_channel_id_nonref,
+ retry: local_retry_nonref,
+ }
+ },
+ nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ Event::PaymentFailed {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
}
},
nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
claim_from_onchain_tx: claim_from_onchain_tx_nonref,
}
},
- nativeEvent::ChannelClosed {ref channel_id, ref reason, } => {
+ nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
let mut channel_id_nonref = (*channel_id).clone();
+ let mut user_channel_id_nonref = (*user_channel_id).clone();
let mut reason_nonref = (*reason).clone();
Event::ChannelClosed {
channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
+ user_channel_id: user_channel_id_nonref,
reason: crate::lightning::util::events::ClosureReason::native_into(reason_nonref),
}
},
+ nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => {
+ let mut channel_id_nonref = (*channel_id).clone();
+ let mut transaction_nonref = (*transaction).clone();
+ Event::DiscardFunding {
+ channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
+ transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref),
+ }
+ },
+ nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } };
+ let mut path_nonref = (*path).clone();
+ let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ Event::PaymentPathSuccessful {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: local_payment_hash_nonref,
+ path: local_path_nonref.into(),
+ }
+ },
+ nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
+ let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
+ let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
+ let mut funding_satoshis_nonref = (*funding_satoshis).clone();
+ let mut push_msat_nonref = (*push_msat).clone();
+ let mut channel_type_nonref = (*channel_type).clone();
+ Event::OpenChannelRequest {
+ temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
+ counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
+ funding_satoshis: funding_satoshis_nonref,
+ push_msat: push_msat_nonref,
+ channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
+ }
+ },
}
}
#[allow(unused)]
purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose),
}
},
- nativeEvent::PaymentSent {mut payment_preimage, } => {
+ nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
+ let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } };
+ let mut local_fee_paid_msat = if fee_paid_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat.unwrap() }) };
Event::PaymentSent {
+ payment_id: local_payment_id,
payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ fee_paid_msat: local_fee_paid_msat,
}
},
- nativeEvent::PaymentPathFailed {mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, } => {
+ nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
+ let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } };
let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(network_update.unwrap()) }) };
let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) };
+ let mut local_retry = crate::lightning::routing::router::RouteParameters { inner: if retry.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry.unwrap())) } }, is_owned: true };
Event::PaymentPathFailed {
+ payment_id: local_payment_id,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
rejected_by_dest: rejected_by_dest,
network_update: local_network_update,
all_paths_failed: all_paths_failed,
path: local_path.into(),
+ short_channel_id: local_short_channel_id,
+ retry: local_retry,
+ }
+ },
+ nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, } => {
+ Event::PaymentFailed {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
}
},
nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
claim_from_onchain_tx: claim_from_onchain_tx,
}
},
- nativeEvent::ChannelClosed {mut channel_id, mut reason, } => {
+ nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
Event::ChannelClosed {
channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
+ user_channel_id: user_channel_id,
reason: crate::lightning::util::events::ClosureReason::native_into(reason),
}
},
+ nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => {
+ Event::DiscardFunding {
+ channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
+ transaction: crate::c_types::Transaction::from_bitcoin(&transaction),
+ }
+ },
+ nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
+ let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } };
+ let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ Event::PaymentPathSuccessful {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: local_payment_hash,
+ path: local_path.into(),
+ }
+ },
+ nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
+ Event::OpenChannelRequest {
+ temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
+ counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
+ funding_satoshis: funding_satoshis,
+ push_msat: push_msat,
+ channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
+ }
+ },
}
}
}
}
#[no_mangle]
/// Utility method to constructs a new PaymentSent-variant Event
-pub extern "C" fn Event_payment_sent(payment_preimage: crate::c_types::ThirtyTwoBytes) -> Event {
+pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::ThirtyTwoBytes, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, fee_paid_msat: crate::c_types::derived::COption_u64Z) -> Event {
Event::PaymentSent {
+ payment_id,
payment_preimage,
+ payment_hash,
+ fee_paid_msat,
}
}
#[no_mangle]
/// Utility method to constructs a new PaymentPathFailed-variant Event
-pub extern "C" fn Event_payment_path_failed(payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ) -> Event {
+pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event {
Event::PaymentPathFailed {
+ payment_id,
payment_hash,
rejected_by_dest,
network_update,
all_paths_failed,
path,
+ short_channel_id,
+ retry,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new PaymentFailed-variant Event
+pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes) -> Event {
+ Event::PaymentFailed {
+ payment_id,
+ payment_hash,
}
}
#[no_mangle]
}
#[no_mangle]
/// Utility method to constructs a new ChannelClosed-variant Event
-pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, reason: crate::lightning::util::events::ClosureReason) -> Event {
+pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: u64, reason: crate::lightning::util::events::ClosureReason) -> Event {
Event::ChannelClosed {
channel_id,
+ user_channel_id,
reason,
}
}
#[no_mangle]
+/// Utility method to constructs a new DiscardFunding-variant Event
+pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event {
+ Event::DiscardFunding {
+ channel_id,
+ transaction,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new PaymentPathSuccessful-variant Event
+pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ) -> Event {
+ Event::PaymentPathSuccessful {
+ payment_id,
+ payment_hash,
+ path,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new OpenChannelRequest-variant Event
+pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event {
+ Event::OpenChannelRequest {
+ temporary_channel_id,
+ counterparty_node_id,
+ funding_satoshis,
+ push_msat,
+ channel_type,
+ }
+}
+#[no_mangle]
/// Serialize the Event object into a byte array which can be read by Event_read
-pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z {
+pub extern "C" fn Event_write(obj: &crate::lightning::util::events::Event) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
}
+#[no_mangle]
+/// Read a Event from a byte array, created by Event_write
+pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ {
+ let res: Result<Option<lightning::util::events::Event>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::util::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
/// An event generated by ChannelManager which indicates a message should be sent to a peer (or
/// broadcast to most peers).
/// These events are handled by PeerManager::process_events if you are using a PeerManager.
/// The reply_channel_range which should be sent.
msg: crate::lightning::ln::msgs::ReplyChannelRange,
},
+ /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
+ /// enable receiving gossip messages from the peer.
+ SendGossipTimestampFilter {
+ /// The node_id of this message recipient
+ node_id: crate::c_types::PublicKey,
+ /// The gossip_timestamp_filter which should be sent.
+ msg: crate::lightning::ln::msgs::GossipTimestampFilter,
+ },
}
use lightning::util::events::MessageSendEvent as nativeMessageSendEvent;
impl MessageSendEvent {
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
}
},
+ MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ nativeMessageSendEvent::SendGossipTimestampFilter {
+ node_id: node_id_nonref.into_rust(),
+ msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ }
+ },
}
}
#[allow(unused)]
msg: *unsafe { Box::from_raw(msg.take_inner()) },
}
},
+ MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
+ nativeMessageSendEvent::SendGossipTimestampFilter {
+ node_id: node_id.into_rust(),
+ msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ }
+ },
}
}
#[allow(unused)]
msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
}
},
+ nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut msg_nonref = (*msg).clone();
+ MessageSendEvent::SendGossipTimestampFilter {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ }
+ },
}
}
#[allow(unused)]
msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
}
},
+ nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
+ MessageSendEvent::SendGossipTimestampFilter {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ }
+ },
}
}
}
msg,
}
}
+#[no_mangle]
+/// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
+pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent {
+ MessageSendEvent::SendGossipTimestampFilter {
+ node_id,
+ msg,
+ }
+}
/// A trait indicating an object may generate message send events
#[repr(C)]
pub struct MessageSendEventsProvider {
// 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 MessageSendEventsProvider {
+impl core::ops::Deref for MessageSendEventsProvider {
type Target = Self;
fn deref(&self) -> &Self {
self
// 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 EventHandler {
+impl core::ops::Deref for EventHandler {
type Target = Self;
fn deref(&self) -> &Self {
self