X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Fevents.rs;h=6baa8b27823a22106c480852d125c7b0ea66197b;hb=5271372bfe3ddc870c806f7b7ee13c4a7660e7e5;hp=55541a5cd7388e2988998c5b3e4a36362d8de2ee;hpb=4b4f99b5639701ccfd4722589316ce2c333ef517;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/util/events.rs index 55541a5..6baa8b2 100644 --- a/lightning-c-bindings/src/lightning/util/events.rs +++ b/lightning-c-bindings/src/lightning/util/events.rs @@ -365,25 +365,27 @@ pub enum Event { 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. + /// + /// [`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. 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. @@ -395,14 +397,44 @@ pub enum Event { /// 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 which 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 /// something. You may wish to retry with a different route. PaymentPathFailed { + /// 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 hash which was given to ChannelManager::send_payment. payment_hash: crate::c_types::ThirtyTwoBytes, /// Indicates the payment was rejected for some reason by the recipient. This implies that @@ -424,6 +456,20 @@ pub enum Event { 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. @@ -469,9 +515,23 @@ pub enum Event { /// 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`], or 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 + 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, + }, } use lightning::util::events::Event as nativeEvent; impl Event { @@ -500,13 +560,23 @@ 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(); @@ -514,12 +584,19 @@ impl Event { 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::PendingHTLCsForwardable {ref time_forwardable, } => { @@ -544,14 +621,24 @@ impl Event { 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(), + } + }, } } #[allow(unused)] @@ -572,20 +659,31 @@ impl Event { 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::PendingHTLCsForwardable {mut time_forwardable, } => { @@ -606,12 +704,19 @@ impl Event { 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(), + } + }, } } #[allow(unused)] @@ -639,13 +744,23 @@ impl Event { 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(); @@ -653,12 +768,19 @@ impl Event { 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() { std::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::PendingHTLCsForwardable {ref time_forwardable, } => { @@ -683,14 +805,24 @@ impl Event { 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), + } + }, } } #[allow(unused)] @@ -711,20 +843,31 @@ impl Event { 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() { std::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::PendingHTLCsForwardable {mut time_forwardable, } => { @@ -745,12 +888,19 @@ impl Event { 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), + } + }, } } } @@ -783,20 +933,26 @@ pub extern "C" fn Event_payment_received(payment_hash: crate::c_types::ThirtyTwo } #[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] @@ -823,13 +979,22 @@ pub extern "C" fn Event_payment_forwarded(fee_earned_msat: crate::c_types::deriv } #[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] /// 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 { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())