+
+use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabilisticScoringParametersImport;
+pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport;
+
+/// Parameters for configuring [`ProbabilisticScorer`].
+#[must_use]
+#[repr(C)]
+pub struct ProbabilisticScoringParameters {
+ /// 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 nativeProbabilisticScoringParameters,
+ /// 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 ProbabilisticScoringParameters {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeProbabilisticScoringParameters>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_free(this_obj: ProbabilisticScoringParameters) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ProbabilisticScoringParameters_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeProbabilisticScoringParameters); }
+}
+#[allow(unused)]
+impl ProbabilisticScoringParameters {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringParameters {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringParameters {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringParameters {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// A multiplier used to determine the amount in msats willing to be paid to avoid routing
+/// through a channel, as per multiplying by the negative `log10` of the channel's success
+/// probability for a payment.
+///
+/// The success probability is determined by the effective channel capacity, the payment amount,
+/// and knowledge learned from prior successful and unsuccessful payments. The lower bound of
+/// the success probability is 0.01, effectively limiting the penalty to the range
+/// `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
+/// on [`liquidity_offset_half_life`].
+///
+/// Default value: 10,000 msat
+///
+/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_multiplier_msat;
+ *inner_val
+}
+/// A multiplier used to determine the amount in msats willing to be paid to avoid routing
+/// through a channel, as per multiplying by the negative `log10` of the channel's success
+/// probability for a payment.
+///
+/// The success probability is determined by the effective channel capacity, the payment amount,
+/// and knowledge learned from prior successful and unsuccessful payments. The lower bound of
+/// the success probability is 0.01, effectively limiting the penalty to the range
+/// `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based
+/// on [`liquidity_offset_half_life`].
+///
+/// Default value: 10,000 msat
+///
+/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_penalty_multiplier_msat = val;
+}
+/// The time required to elapse before any knowledge learned about channel liquidity balances is
+/// cut in half.
+///
+/// The bounds are defined in terms of offsets and are initially zero. Increasing the offsets
+/// gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases
+/// the certainty of the channel liquidity balance.
+///
+/// Default value: 1 hour
+///
+/// # Note
+///
+/// When built with the `no-std` feature, time will never elapse. Therefore, the channel
+/// liquidity knowledge will never decay except when the bounds cross.
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_offset_half_life(this_ptr: &ProbabilisticScoringParameters) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_offset_half_life;
+ inner_val.as_secs()
+}
+/// The time required to elapse before any knowledge learned about channel liquidity balances is
+/// cut in half.
+///
+/// The bounds are defined in terms of offsets and are initially zero. Increasing the offsets
+/// gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases
+/// the certainty of the channel liquidity balance.
+///
+/// Default value: 1 hour
+///
+/// # Note
+///
+/// When built with the `no-std` feature, time will never elapse. Therefore, the channel
+/// liquidity knowledge will never decay except when the bounds cross.
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_offset_half_life(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_offset_half_life = core::time::Duration::from_secs(val);
+}
+/// Constructs a new ProbabilisticScoringParameters given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_new(mut liquidity_penalty_multiplier_msat_arg: u64, mut liquidity_offset_half_life_arg: u64) -> ProbabilisticScoringParameters {
+ ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(nativeProbabilisticScoringParameters {
+ liquidity_penalty_multiplier_msat: liquidity_penalty_multiplier_msat_arg,
+ liquidity_offset_half_life: core::time::Duration::from_secs(liquidity_offset_half_life_arg),
+ }), is_owned: true }
+}
+impl Clone for ProbabilisticScoringParameters {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeProbabilisticScoringParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ProbabilisticScoringParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringParameters)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ProbabilisticScoringParameters
+pub extern "C" fn ProbabilisticScoringParameters_clone(orig: &ProbabilisticScoringParameters) -> ProbabilisticScoringParameters {
+ orig.clone()
+}
+#[no_mangle]
+/// Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read
+pub extern "C" fn ProbabilisticScoringParameters_write(obj: &ProbabilisticScoringParameters) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn ProbabilisticScoringParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeProbabilisticScoringParameters) })
+}
+#[no_mangle]
+/// Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write
+pub extern "C" fn ProbabilisticScoringParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ProbabilisticScoringParametersDecodeErrorZ {
+ let res: Result<lightning::routing::scoring::ProbabilisticScoringParameters, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).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
+}
+/// Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ProbabilisticScoringParameters_default() -> ProbabilisticScoringParameters {
+ ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
+}