typedef struct nativeScorerOpaque LDKnativeScorer;
struct nativeScoringParametersOpaque;
typedef struct nativeScoringParametersOpaque LDKnativeScoringParameters;
+struct nativeProbabilisticScorerOpaque;
+typedef struct nativeProbabilisticScorerOpaque LDKnativeProbabilisticScorer;
struct nativeProbabilisticScoringParametersOpaque;
typedef struct nativeProbabilisticScoringParametersOpaque LDKnativeProbabilisticScoringParameters;
struct nativeInitFeaturesOpaque;
+/**
+ * Represents the network as nodes and channels between them
+ */
+typedef struct MUST_USE_STRUCT LDKNetworkGraph {
+ /**
+ * 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.
+ */
+ LDKnativeNetworkGraph *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;
+} LDKNetworkGraph;
+
+/**
+ * A tuple of 2 elements. See the individual fields for the types contained.
+ */
+typedef struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ {
+ /**
+ * The element at position 0
+ */
+ struct LDKProbabilisticScoringParameters a;
+ /**
+ * The element at position 1
+ */
+ const struct LDKNetworkGraph *NONNULL_PTR b;
+} LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ;
+
+
+
+/**
+ * [`Score`] implementation using channel success probability distributions.
+ *
+ * Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
+ * and Stefan Richter [[1]]. Given the uncertainty of channel liquidity balances, probability
+ * distributions are defined based on knowledge learned from successful and unsuccessful attempts.
+ * Then the negative `log10` of the success probability is used to determine the cost of routing a
+ * specific HTLC amount through a channel.
+ *
+ * Knowledge about channel liquidity balances takes the form of upper and lower bounds on the
+ * possible liquidity. Certainty of the bounds is decreased over time using a decay function. See
+ * [`ProbabilisticScoringParameters`] for details.
+ *
+ * Since the scorer aims to learn the current channel liquidity balances, it works best for nodes
+ * with high payment volume or that actively probe the [`NetworkGraph`]. Nodes with low payment
+ * volume are more likely to experience failed payment paths, which would need to be retried.
+ *
+ * # Note
+ *
+ * Mixing the `no-std` feature between serialization and deserialization results in undefined
+ * behavior.
+ *
+ * [1]: https://arxiv.org/abs/2107.05322
+ */
+typedef struct MUST_USE_STRUCT LDKProbabilisticScorer {
+ /**
+ * 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.
+ */
+ LDKnativeProbabilisticScorer *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;
+} LDKProbabilisticScorer;
+
+/**
+ * The contents of CResult_ProbabilisticScorerDecodeErrorZ
+ */
+typedef union LDKCResult_ProbabilisticScorerDecodeErrorZPtr {
+ /**
+ * A pointer to the contents in the success state.
+ * Reading from this pointer when `result_ok` is not set is undefined.
+ */
+ struct LDKProbabilisticScorer *result;
+ /**
+ * A pointer to the contents in the error state.
+ * Reading from this pointer when `result_ok` is set is undefined.
+ */
+ struct LDKDecodeError *err;
+} LDKCResult_ProbabilisticScorerDecodeErrorZPtr;
+
+/**
+ * A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation,
+ * containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_ProbabilisticScorerDecodeErrorZ {
+ /**
+ * The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either
+ * `err` or `result` depending on the state of `result_ok`.
+ */
+ union LDKCResult_ProbabilisticScorerDecodeErrorZPtr contents;
+ /**
+ * Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state.
+ */
+ bool result_ok;
+} LDKCResult_ProbabilisticScorerDecodeErrorZ;
+
+
+
/**
* Features used within an `init` message.
*/
bool result_ok;
} LDKCResult_NodeInfoDecodeErrorZ;
-
-
-/**
- * Represents the network as nodes and channels between them
- */
-typedef struct MUST_USE_STRUCT LDKNetworkGraph {
- /**
- * 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.
- */
- LDKnativeNetworkGraph *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;
-} LDKNetworkGraph;
-
/**
* The contents of CResult_NetworkGraphDecodeErrorZ
*/
*/
void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res);
+/**
+ * Creates a new CResult_SecretKeyErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_clone(const struct LDKCResult_SecretKeyErrorZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_PublicKeyErrorZ in the success state.
*/
*/
struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR orig);
+/**
+ * Creates a new C2Tuple_ProbabilisticScoringParametersNetworkGraphZ from the contained elements.
+ */
+struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(struct LDKProbabilisticScoringParameters a, const struct LDKNetworkGraph *NONNULL_PTR b);
+
+/**
+ * Frees any resources used by the C2Tuple_ProbabilisticScoringParametersNetworkGraphZ.
+ */
+void C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ _res);
+
+/**
+ * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state.
+ */
+struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o);
+
+/**
+ * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state.
+ */
+struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Checks if the given object is currently in the success state
+ */
+bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o);
+
+/**
+ * Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ.
+ */
+void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res);
+
/**
* Creates a new CResult_InitFeaturesDecodeErrorZ in the success state.
*/
*/
void CResult_SecretKeyNoneZ_free(struct LDKCResult_SecretKeyNoneZ _res);
+/**
+ * Creates a new CResult_SecretKeyNoneZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_clone(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR orig);
+
/**
* Creates a new CResult_SignDecodeErrorZ in the success state.
*/
*/
struct LDKCResult_ScorerDecodeErrorZ Scorer_read(struct LDKu8slice ser);
+/**
+ * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL.
+ */
+void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj);
+
/**
* Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL.
*/
*/
struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ ProbabilisticScoringParameters_read(struct LDKu8slice ser);
+/**
+ * Creates a new scorer using the given scoring parameters for sending payments from a node
+ * through a network graph.
+ */
+MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringParameters params, const struct LDKNetworkGraph *NONNULL_PTR network_graph);
+
/**
* Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used.
*/
MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_default(void);
+/**
+ * Constructs a new Score which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
+ */
+struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg);
+
+/**
+ * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read
+ */
+struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj);
+
+/**
+ * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write
+ */
+struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ arg);
+
/**
* Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL.
*/
class FixedPenaltyScorer;
class Scorer;
class ScoringParameters;
+class ProbabilisticScorer;
class ProbabilisticScoringParameters;
class InitFeatures;
class NodeFeatures;
class CResult_CommitmentSignedDecodeErrorZ;
class CVec_UpdateAddHTLCZ;
class CResult_UnsignedNodeAnnouncementDecodeErrorZ;
-class COption_u32Z;
class CResult_InitFeaturesDecodeErrorZ;
+class COption_u32Z;
class CResult_StaticPaymentOutputDescriptorDecodeErrorZ;
class CResult_PaymentIdPaymentSendFailureZ;
class CResult_ReplyChannelRangeDecodeErrorZ;
class CResult_OpenChannelDecodeErrorZ;
class CVec_CVec_u8ZZ;
class COption_FilterZ;
+class CResult_ProbabilisticScorerDecodeErrorZ;
class CResult_SecretKeyErrorZ;
class CResult_ShutdownScriptDecodeErrorZ;
class CResult_InvoiceNoneZ;
-class CResult_QueryChannelRangeDecodeErrorZ;
class CResult_TxCreationKeysDecodeErrorZ;
class C2Tuple_usizeTransactionZ;
class CResult_ChannelFeaturesDecodeErrorZ;
class CResult_UpdateFeeDecodeErrorZ;
class CResult_RouteHopDecodeErrorZ;
class CResult_NodeAnnouncementDecodeErrorZ;
+class CResult_QueryChannelRangeDecodeErrorZ;
class CVec_BalanceZ;
class CResult_HTLCOutputInCommitmentDecodeErrorZ;
class CResult_boolLightningErrorZ;
class CResult_COption_EventZDecodeErrorZ;
class CResult_CVec_SignatureZNoneZ;
class COption_CVec_NetAddressZZ;
+class C2Tuple_ProbabilisticScoringParametersNetworkGraphZ;
class CResult__u832APIErrorZ;
class CResult_PaymentIdPaymentErrorZ;
class CResult_DescriptionCreationErrorZ;
-class CResult_COption_MonitorEventZDecodeErrorZ;
class CResult_PayeePubKeyErrorZ;
+class CResult_COption_MonitorEventZDecodeErrorZ;
class CVec_C2Tuple_PublicKeyTypeZZ;
class CResult_RoutingFeesDecodeErrorZ;
-class CResult_QueryShortChannelIdsDecodeErrorZ;
class CResult_InvoiceSemanticErrorZ;
class CResult_UpdateAddHTLCDecodeErrorZ;
-class CVec_PhantomRouteHintsZ;
+class CResult_QueryShortChannelIdsDecodeErrorZ;
class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ;
class CResult_NoneAPIErrorZ;
class CVec_NetAddressZ;
class CResult_ChannelDetailsDecodeErrorZ;
class CVec_C2Tuple_usizeTransactionZZ;
class CVec_PublicKeyZ;
+class CVec_PhantomRouteHintsZ;
class COption_MonitorEventZ;
class COption_TypeZ;
class CResult_COption_TypeZDecodeErrorZ;
const LDKScoringParameters* operator &() const { return &self; }
const LDKScoringParameters* operator ->() const { return &self; }
};
+class ProbabilisticScorer {
+private:
+ LDKProbabilisticScorer self;
+public:
+ ProbabilisticScorer(const ProbabilisticScorer&) = delete;
+ ProbabilisticScorer(ProbabilisticScorer&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScorer)); }
+ ProbabilisticScorer(LDKProbabilisticScorer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScorer)); }
+ operator LDKProbabilisticScorer() && { LDKProbabilisticScorer res = self; memset(&self, 0, sizeof(LDKProbabilisticScorer)); return res; }
+ ~ProbabilisticScorer() { ProbabilisticScorer_free(self); }
+ ProbabilisticScorer& operator=(ProbabilisticScorer&& o) { ProbabilisticScorer_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScorer)); return *this; }
+ LDKProbabilisticScorer* operator &() { return &self; }
+ LDKProbabilisticScorer* operator ->() { return &self; }
+ const LDKProbabilisticScorer* operator &() const { return &self; }
+ const LDKProbabilisticScorer* operator ->() const { return &self; }
+};
class ProbabilisticScoringParameters {
private:
LDKProbabilisticScoringParameters self;
const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; }
};
-class COption_u32Z {
-private:
- LDKCOption_u32Z self;
-public:
- COption_u32Z(const COption_u32Z&) = delete;
- COption_u32Z(COption_u32Z&& o) : self(o.self) { memset(&o, 0, sizeof(COption_u32Z)); }
- COption_u32Z(LDKCOption_u32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_u32Z)); }
- operator LDKCOption_u32Z() && { LDKCOption_u32Z res = self; memset(&self, 0, sizeof(LDKCOption_u32Z)); return res; }
- ~COption_u32Z() { COption_u32Z_free(self); }
- COption_u32Z& operator=(COption_u32Z&& o) { COption_u32Z_free(self); self = o.self; memset(&o, 0, sizeof(COption_u32Z)); return *this; }
- LDKCOption_u32Z* operator &() { return &self; }
- LDKCOption_u32Z* operator ->() { return &self; }
- const LDKCOption_u32Z* operator &() const { return &self; }
- const LDKCOption_u32Z* operator ->() const { return &self; }
-};
class CResult_InitFeaturesDecodeErrorZ {
private:
LDKCResult_InitFeaturesDecodeErrorZ self;
const LDKCResult_InitFeaturesDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_InitFeaturesDecodeErrorZ* operator ->() const { return &self; }
};
+class COption_u32Z {
+private:
+ LDKCOption_u32Z self;
+public:
+ COption_u32Z(const COption_u32Z&) = delete;
+ COption_u32Z(COption_u32Z&& o) : self(o.self) { memset(&o, 0, sizeof(COption_u32Z)); }
+ COption_u32Z(LDKCOption_u32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_u32Z)); }
+ operator LDKCOption_u32Z() && { LDKCOption_u32Z res = self; memset(&self, 0, sizeof(LDKCOption_u32Z)); return res; }
+ ~COption_u32Z() { COption_u32Z_free(self); }
+ COption_u32Z& operator=(COption_u32Z&& o) { COption_u32Z_free(self); self = o.self; memset(&o, 0, sizeof(COption_u32Z)); return *this; }
+ LDKCOption_u32Z* operator &() { return &self; }
+ LDKCOption_u32Z* operator ->() { return &self; }
+ const LDKCOption_u32Z* operator &() const { return &self; }
+ const LDKCOption_u32Z* operator ->() const { return &self; }
+};
class CResult_StaticPaymentOutputDescriptorDecodeErrorZ {
private:
LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ self;
const LDKCOption_FilterZ* operator &() const { return &self; }
const LDKCOption_FilterZ* operator ->() const { return &self; }
};
+class CResult_ProbabilisticScorerDecodeErrorZ {
+private:
+ LDKCResult_ProbabilisticScorerDecodeErrorZ self;
+public:
+ CResult_ProbabilisticScorerDecodeErrorZ(const CResult_ProbabilisticScorerDecodeErrorZ&) = delete;
+ CResult_ProbabilisticScorerDecodeErrorZ(CResult_ProbabilisticScorerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ProbabilisticScorerDecodeErrorZ)); }
+ CResult_ProbabilisticScorerDecodeErrorZ(LDKCResult_ProbabilisticScorerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ)); }
+ operator LDKCResult_ProbabilisticScorerDecodeErrorZ() && { LDKCResult_ProbabilisticScorerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ)); return res; }
+ ~CResult_ProbabilisticScorerDecodeErrorZ() { CResult_ProbabilisticScorerDecodeErrorZ_free(self); }
+ CResult_ProbabilisticScorerDecodeErrorZ& operator=(CResult_ProbabilisticScorerDecodeErrorZ&& o) { CResult_ProbabilisticScorerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ProbabilisticScorerDecodeErrorZ)); return *this; }
+ LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() const { return &self; }
+};
class CResult_SecretKeyErrorZ {
private:
LDKCResult_SecretKeyErrorZ self;
const LDKCResult_InvoiceNoneZ* operator &() const { return &self; }
const LDKCResult_InvoiceNoneZ* operator ->() const { return &self; }
};
-class CResult_QueryChannelRangeDecodeErrorZ {
-private:
- LDKCResult_QueryChannelRangeDecodeErrorZ self;
-public:
- CResult_QueryChannelRangeDecodeErrorZ(const CResult_QueryChannelRangeDecodeErrorZ&) = delete;
- CResult_QueryChannelRangeDecodeErrorZ(CResult_QueryChannelRangeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_QueryChannelRangeDecodeErrorZ)); }
- CResult_QueryChannelRangeDecodeErrorZ(LDKCResult_QueryChannelRangeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ)); }
- operator LDKCResult_QueryChannelRangeDecodeErrorZ() && { LDKCResult_QueryChannelRangeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ)); return res; }
- ~CResult_QueryChannelRangeDecodeErrorZ() { CResult_QueryChannelRangeDecodeErrorZ_free(self); }
- CResult_QueryChannelRangeDecodeErrorZ& operator=(CResult_QueryChannelRangeDecodeErrorZ&& o) { CResult_QueryChannelRangeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_QueryChannelRangeDecodeErrorZ)); return *this; }
- LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() { return &self; }
- LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() const { return &self; }
-};
class CResult_TxCreationKeysDecodeErrorZ {
private:
LDKCResult_TxCreationKeysDecodeErrorZ self;
const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() const { return &self; }
};
+class CResult_QueryChannelRangeDecodeErrorZ {
+private:
+ LDKCResult_QueryChannelRangeDecodeErrorZ self;
+public:
+ CResult_QueryChannelRangeDecodeErrorZ(const CResult_QueryChannelRangeDecodeErrorZ&) = delete;
+ CResult_QueryChannelRangeDecodeErrorZ(CResult_QueryChannelRangeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_QueryChannelRangeDecodeErrorZ)); }
+ CResult_QueryChannelRangeDecodeErrorZ(LDKCResult_QueryChannelRangeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ)); }
+ operator LDKCResult_QueryChannelRangeDecodeErrorZ() && { LDKCResult_QueryChannelRangeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ)); return res; }
+ ~CResult_QueryChannelRangeDecodeErrorZ() { CResult_QueryChannelRangeDecodeErrorZ_free(self); }
+ CResult_QueryChannelRangeDecodeErrorZ& operator=(CResult_QueryChannelRangeDecodeErrorZ&& o) { CResult_QueryChannelRangeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_QueryChannelRangeDecodeErrorZ)); return *this; }
+ LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() const { return &self; }
+};
class CVec_BalanceZ {
private:
LDKCVec_BalanceZ self;
const LDKCOption_CVec_NetAddressZZ* operator &() const { return &self; }
const LDKCOption_CVec_NetAddressZZ* operator ->() const { return &self; }
};
+class C2Tuple_ProbabilisticScoringParametersNetworkGraphZ {
+private:
+ LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ self;
+public:
+ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ(const C2Tuple_ProbabilisticScoringParametersNetworkGraphZ&) = delete;
+ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ(C2Tuple_ProbabilisticScoringParametersNetworkGraphZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_ProbabilisticScoringParametersNetworkGraphZ)); }
+ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ)); }
+ operator LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ() && { LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ)); return res; }
+ ~C2Tuple_ProbabilisticScoringParametersNetworkGraphZ() { C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(self); }
+ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ& operator=(C2Tuple_ProbabilisticScoringParametersNetworkGraphZ&& o) { C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_ProbabilisticScoringParametersNetworkGraphZ)); return *this; }
+ LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* operator &() { return &self; }
+ LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* operator ->() { return &self; }
+ const LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* operator &() const { return &self; }
+ const LDKC2Tuple_ProbabilisticScoringParametersNetworkGraphZ* operator ->() const { return &self; }
+};
class CResult__u832APIErrorZ {
private:
LDKCResult__u832APIErrorZ self;
const LDKCResult_DescriptionCreationErrorZ* operator &() const { return &self; }
const LDKCResult_DescriptionCreationErrorZ* operator ->() const { return &self; }
};
-class CResult_COption_MonitorEventZDecodeErrorZ {
-private:
- LDKCResult_COption_MonitorEventZDecodeErrorZ self;
-public:
- CResult_COption_MonitorEventZDecodeErrorZ(const CResult_COption_MonitorEventZDecodeErrorZ&) = delete;
- CResult_COption_MonitorEventZDecodeErrorZ(CResult_COption_MonitorEventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_MonitorEventZDecodeErrorZ)); }
- CResult_COption_MonitorEventZDecodeErrorZ(LDKCResult_COption_MonitorEventZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ)); }
- operator LDKCResult_COption_MonitorEventZDecodeErrorZ() && { LDKCResult_COption_MonitorEventZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ)); return res; }
- ~CResult_COption_MonitorEventZDecodeErrorZ() { CResult_COption_MonitorEventZDecodeErrorZ_free(self); }
- CResult_COption_MonitorEventZDecodeErrorZ& operator=(CResult_COption_MonitorEventZDecodeErrorZ&& o) { CResult_COption_MonitorEventZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_MonitorEventZDecodeErrorZ)); return *this; }
- LDKCResult_COption_MonitorEventZDecodeErrorZ* operator &() { return &self; }
- LDKCResult_COption_MonitorEventZDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_COption_MonitorEventZDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_COption_MonitorEventZDecodeErrorZ* operator ->() const { return &self; }
-};
class CResult_PayeePubKeyErrorZ {
private:
LDKCResult_PayeePubKeyErrorZ self;
const LDKCResult_PayeePubKeyErrorZ* operator &() const { return &self; }
const LDKCResult_PayeePubKeyErrorZ* operator ->() const { return &self; }
};
+class CResult_COption_MonitorEventZDecodeErrorZ {
+private:
+ LDKCResult_COption_MonitorEventZDecodeErrorZ self;
+public:
+ CResult_COption_MonitorEventZDecodeErrorZ(const CResult_COption_MonitorEventZDecodeErrorZ&) = delete;
+ CResult_COption_MonitorEventZDecodeErrorZ(CResult_COption_MonitorEventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_MonitorEventZDecodeErrorZ)); }
+ CResult_COption_MonitorEventZDecodeErrorZ(LDKCResult_COption_MonitorEventZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ)); }
+ operator LDKCResult_COption_MonitorEventZDecodeErrorZ() && { LDKCResult_COption_MonitorEventZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ)); return res; }
+ ~CResult_COption_MonitorEventZDecodeErrorZ() { CResult_COption_MonitorEventZDecodeErrorZ_free(self); }
+ CResult_COption_MonitorEventZDecodeErrorZ& operator=(CResult_COption_MonitorEventZDecodeErrorZ&& o) { CResult_COption_MonitorEventZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_MonitorEventZDecodeErrorZ)); return *this; }
+ LDKCResult_COption_MonitorEventZDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_COption_MonitorEventZDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_COption_MonitorEventZDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_COption_MonitorEventZDecodeErrorZ* operator ->() const { return &self; }
+};
class CVec_C2Tuple_PublicKeyTypeZZ {
private:
LDKCVec_C2Tuple_PublicKeyTypeZZ self;
const LDKCResult_RoutingFeesDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_RoutingFeesDecodeErrorZ* operator ->() const { return &self; }
};
-class CResult_QueryShortChannelIdsDecodeErrorZ {
-private:
- LDKCResult_QueryShortChannelIdsDecodeErrorZ self;
-public:
- CResult_QueryShortChannelIdsDecodeErrorZ(const CResult_QueryShortChannelIdsDecodeErrorZ&) = delete;
- CResult_QueryShortChannelIdsDecodeErrorZ(CResult_QueryShortChannelIdsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_QueryShortChannelIdsDecodeErrorZ)); }
- CResult_QueryShortChannelIdsDecodeErrorZ(LDKCResult_QueryShortChannelIdsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ)); }
- operator LDKCResult_QueryShortChannelIdsDecodeErrorZ() && { LDKCResult_QueryShortChannelIdsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ)); return res; }
- ~CResult_QueryShortChannelIdsDecodeErrorZ() { CResult_QueryShortChannelIdsDecodeErrorZ_free(self); }
- CResult_QueryShortChannelIdsDecodeErrorZ& operator=(CResult_QueryShortChannelIdsDecodeErrorZ&& o) { CResult_QueryShortChannelIdsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_QueryShortChannelIdsDecodeErrorZ)); return *this; }
- LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() { return &self; }
- LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() { return &self; }
- const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() const { return &self; }
- const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() const { return &self; }
-};
class CResult_InvoiceSemanticErrorZ {
private:
LDKCResult_InvoiceSemanticErrorZ self;
const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator &() const { return &self; }
const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator ->() const { return &self; }
};
-class CVec_PhantomRouteHintsZ {
+class CResult_QueryShortChannelIdsDecodeErrorZ {
private:
- LDKCVec_PhantomRouteHintsZ self;
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ self;
public:
- CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete;
- CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); }
- CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); }
- operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; }
- ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); }
- CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; }
- LDKCVec_PhantomRouteHintsZ* operator &() { return &self; }
- LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; }
- const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; }
- const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; }
+ CResult_QueryShortChannelIdsDecodeErrorZ(const CResult_QueryShortChannelIdsDecodeErrorZ&) = delete;
+ CResult_QueryShortChannelIdsDecodeErrorZ(CResult_QueryShortChannelIdsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_QueryShortChannelIdsDecodeErrorZ)); }
+ CResult_QueryShortChannelIdsDecodeErrorZ(LDKCResult_QueryShortChannelIdsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ)); }
+ operator LDKCResult_QueryShortChannelIdsDecodeErrorZ() && { LDKCResult_QueryShortChannelIdsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ)); return res; }
+ ~CResult_QueryShortChannelIdsDecodeErrorZ() { CResult_QueryShortChannelIdsDecodeErrorZ_free(self); }
+ CResult_QueryShortChannelIdsDecodeErrorZ& operator=(CResult_QueryShortChannelIdsDecodeErrorZ&& o) { CResult_QueryShortChannelIdsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_QueryShortChannelIdsDecodeErrorZ)); return *this; }
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() { return &self; }
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() { return &self; }
+ const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() const { return &self; }
+ const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() const { return &self; }
};
class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ {
private:
const LDKCVec_PublicKeyZ* operator &() const { return &self; }
const LDKCVec_PublicKeyZ* operator ->() const { return &self; }
};
+class CVec_PhantomRouteHintsZ {
+private:
+ LDKCVec_PhantomRouteHintsZ self;
+public:
+ CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete;
+ CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); }
+ CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); }
+ operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; }
+ ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); }
+ CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; }
+ LDKCVec_PhantomRouteHintsZ* operator &() { return &self; }
+ LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; }
+ const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; }
+ const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; }
+};
class COption_MonitorEventZ {
private:
LDKCOption_MonitorEventZ self;
}
}
}
+impl Clone for CResult_SecretKeyErrorZ {
+ fn clone(&self) -> Self {
+ if self.result_ok {
+ Self { result_ok: true, contents: CResult_SecretKeyErrorZPtr {
+ result: Box::into_raw(Box::new(<crate::c_types::SecretKey>::clone(unsafe { &*self.contents.result })))
+ } }
+ } else {
+ Self { result_ok: false, contents: CResult_SecretKeyErrorZPtr {
+ err: Box::into_raw(Box::new(<crate::c_types::Secp256k1Error>::clone(unsafe { &*self.contents.err })))
+ } }
+ }
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_SecretKeyErrorZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_SecretKeyErrorZ_clone(orig: &CResult_SecretKeyErrorZ) -> CResult_SecretKeyErrorZ { Clone::clone(&orig) }
#[repr(C)]
/// The contents of CResult_PublicKeyErrorZ
pub union CResult_PublicKeyErrorZPtr {
/// but with all dynamically-allocated buffers duplicated in new buffers.
pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig: &CResult_ProbabilisticScoringParametersDecodeErrorZ) -> CResult_ProbabilisticScoringParametersDecodeErrorZ { Clone::clone(&orig) }
#[repr(C)]
+/// A tuple of 2 elements. See the individual fields for the types contained.
+pub struct C2Tuple_ProbabilisticScoringParametersNetworkGraphZ {
+ /// The element at position 0
+ pub a: crate::lightning::routing::scoring::ProbabilisticScoringParameters,
+ /// The element at position 1
+ pub b: &'static crate::lightning::routing::network_graph::NetworkGraph,
+}
+impl From<(crate::lightning::routing::scoring::ProbabilisticScoringParameters, &'static crate::lightning::routing::network_graph::NetworkGraph)> for C2Tuple_ProbabilisticScoringParametersNetworkGraphZ {
+ fn from (tup: (crate::lightning::routing::scoring::ProbabilisticScoringParameters, &'static crate::lightning::routing::network_graph::NetworkGraph)) -> Self {
+ Self {
+ a: tup.0,
+ b: tup.1,
+ }
+ }
+}
+impl C2Tuple_ProbabilisticScoringParametersNetworkGraphZ {
+ #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::routing::scoring::ProbabilisticScoringParameters, &'static crate::lightning::routing::network_graph::NetworkGraph) {
+ (self.a, self.b)
+ }
+}
+/// Creates a new C2Tuple_ProbabilisticScoringParametersNetworkGraphZ from the contained elements.
+#[no_mangle]
+pub extern "C" fn C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_new(a: crate::lightning::routing::scoring::ProbabilisticScoringParameters, b: &'static crate::lightning::routing::network_graph::NetworkGraph) -> C2Tuple_ProbabilisticScoringParametersNetworkGraphZ {
+ C2Tuple_ProbabilisticScoringParametersNetworkGraphZ { a, b, }
+}
+
+#[no_mangle]
+/// Frees any resources used by the C2Tuple_ProbabilisticScoringParametersNetworkGraphZ.
+pub extern "C" fn C2Tuple_ProbabilisticScoringParametersNetworkGraphZ_free(_res: C2Tuple_ProbabilisticScoringParametersNetworkGraphZ) { }
+#[repr(C)]
+/// The contents of CResult_ProbabilisticScorerDecodeErrorZ
+pub union CResult_ProbabilisticScorerDecodeErrorZPtr {
+ /// A pointer to the contents in the success state.
+ /// Reading from this pointer when `result_ok` is not set is undefined.
+ pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer,
+ /// A pointer to the contents in the error state.
+ /// Reading from this pointer when `result_ok` is set is undefined.
+ pub err: *mut crate::lightning::ln::msgs::DecodeError,
+}
+#[repr(C)]
+/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation,
+/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure.
+/// `result_ok` indicates the overall state, and the contents are provided via `contents`.
+pub struct CResult_ProbabilisticScorerDecodeErrorZ {
+ /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either
+ /// `err` or `result` depending on the state of `result_ok`.
+ pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr,
+ /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state.
+ pub result_ok: bool,
+}
+#[no_mangle]
+/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state.
+pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ {
+ CResult_ProbabilisticScorerDecodeErrorZ {
+ contents: CResult_ProbabilisticScorerDecodeErrorZPtr {
+ result: Box::into_raw(Box::new(o)),
+ },
+ result_ok: true,
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state.
+pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ {
+ CResult_ProbabilisticScorerDecodeErrorZ {
+ contents: CResult_ProbabilisticScorerDecodeErrorZPtr {
+ err: Box::into_raw(Box::new(e)),
+ },
+ result_ok: false,
+ }
+}
+/// Checks if the given object is currently in the success state
+#[no_mangle]
+pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool {
+ o.result_ok
+}
+#[no_mangle]
+/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ.
+pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { }
+impl Drop for CResult_ProbabilisticScorerDecodeErrorZ {
+ fn drop(&mut self) {
+ if self.result_ok {
+ if unsafe { !(self.contents.result as *mut ()).is_null() } {
+ let _ = unsafe { Box::from_raw(self.contents.result) };
+ }
+ } else {
+ if unsafe { !(self.contents.err as *mut ()).is_null() } {
+ let _ = unsafe { Box::from_raw(self.contents.err) };
+ }
+ }
+ }
+}
+impl From<crate::c_types::CResultTempl<crate::lightning::routing::scoring::ProbabilisticScorer, crate::lightning::ln::msgs::DecodeError>> for CResult_ProbabilisticScorerDecodeErrorZ {
+ fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::scoring::ProbabilisticScorer, crate::lightning::ln::msgs::DecodeError>) -> Self {
+ let contents = if o.result_ok {
+ let result = unsafe { o.contents.result };
+ unsafe { o.contents.result = core::ptr::null_mut() };
+ CResult_ProbabilisticScorerDecodeErrorZPtr { result }
+ } else {
+ let err = unsafe { o.contents.err };
+ unsafe { o.contents.err = core::ptr::null_mut(); }
+ CResult_ProbabilisticScorerDecodeErrorZPtr { err }
+ };
+ Self {
+ contents,
+ result_ok: o.result_ok,
+ }
+ }
+}
+#[repr(C)]
/// The contents of CResult_InitFeaturesDecodeErrorZ
pub union CResult_InitFeaturesDecodeErrorZPtr {
/// A pointer to the contents in the success state.
}
}
}
+impl Clone for CResult_SecretKeyNoneZ {
+ fn clone(&self) -> Self {
+ if self.result_ok {
+ Self { result_ok: true, contents: CResult_SecretKeyNoneZPtr {
+ result: Box::into_raw(Box::new(<crate::c_types::SecretKey>::clone(unsafe { &*self.contents.result })))
+ } }
+ } else {
+ Self { result_ok: false, contents: CResult_SecretKeyNoneZPtr {
+ err: core::ptr::null_mut()
+ } }
+ }
+ }
+}
+#[no_mangle]
+/// Creates a new CResult_SecretKeyNoneZ which has the same data as `orig`
+/// but with all dynamically-allocated buffers duplicated in new buffers.
+pub extern "C" fn CResult_SecretKeyNoneZ_clone(orig: &CResult_SecretKeyNoneZ) -> CResult_SecretKeyNoneZ { Clone::clone(&orig) }
#[repr(C)]
/// The contents of CResult_SignDecodeErrorZ
pub union CResult_SignDecodeErrorZPtr {
local_res
}
+use lightning::routing::scoring::ProbabilisticScorer as nativeProbabilisticScorerImport;
+pub(crate) type nativeProbabilisticScorer = nativeProbabilisticScorerImport<&'static lightning::routing::network_graph::NetworkGraph>;
+
+/// [`Score`] implementation using channel success probability distributions.
+///
+/// Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt
+/// and Stefan Richter [[1]]. Given the uncertainty of channel liquidity balances, probability
+/// distributions are defined based on knowledge learned from successful and unsuccessful attempts.
+/// Then the negative `log10` of the success probability is used to determine the cost of routing a
+/// specific HTLC amount through a channel.
+///
+/// Knowledge about channel liquidity balances takes the form of upper and lower bounds on the
+/// possible liquidity. Certainty of the bounds is decreased over time using a decay function. See
+/// [`ProbabilisticScoringParameters`] for details.
+///
+/// Since the scorer aims to learn the current channel liquidity balances, it works best for nodes
+/// with high payment volume or that actively probe the [`NetworkGraph`]. Nodes with low payment
+/// volume are more likely to experience failed payment paths, which would need to be retried.
+///
+/// # Note
+///
+/// Mixing the `no-std` feature between serialization and deserialization results in undefined
+/// behavior.
+///
+/// [1]: https://arxiv.org/abs/2107.05322
+#[must_use]
+#[repr(C)]
+pub struct ProbabilisticScorer {
+ /// 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 nativeProbabilisticScorer,
+ /// 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 ProbabilisticScorer {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeProbabilisticScorer>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ProbabilisticScorer_free(this_obj: ProbabilisticScorer) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ProbabilisticScorer_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeProbabilisticScorer); }
+}
+#[allow(unused)]
+impl ProbabilisticScorer {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScorer {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScorer {
+ 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 nativeProbabilisticScorer {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+
use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabilisticScoringParametersImport;
pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport;
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 new scorer using the given scoring parameters for sending payments from a node
+/// through a network graph.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ProbabilisticScorer_new(mut params: crate::lightning::routing::scoring::ProbabilisticScoringParameters, network_graph: &crate::lightning::routing::network_graph::NetworkGraph) -> ProbabilisticScorer {
+ let mut ret = lightning::routing::scoring::ProbabilisticScorer::new(*unsafe { Box::from_raw(params.take_inner()) }, network_graph.get_native_ref());
+ ProbabilisticScorer { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
/// 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 }
}
+impl From<nativeProbabilisticScorer> for crate::lightning::routing::scoring::Score {
+ fn from(obj: nativeProbabilisticScorer) -> Self {
+ let mut rust_obj = ProbabilisticScorer { inner: ObjOps::heap_alloc(obj), is_owned: true };
+ let mut ret = ProbabilisticScorer_as_Score(&rust_obj);
+ // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+ rust_obj.inner = core::ptr::null_mut();
+ ret.free = Some(ProbabilisticScorer_free_void);
+ ret
+ }
+}
+/// Constructs a new Score which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn ProbabilisticScorer_as_Score(this_arg: &ProbabilisticScorer) -> crate::lightning::routing::scoring::Score {
+ crate::lightning::routing::scoring::Score {
+ this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+ free: None,
+ channel_penalty_msat: ProbabilisticScorer_Score_channel_penalty_msat,
+ payment_path_failed: ProbabilisticScorer_Score_payment_path_failed,
+ payment_path_successful: ProbabilisticScorer_Score_payment_path_successful,
+ write: ProbabilisticScorer_write_void,
+ }
+}
+
+#[must_use]
+extern "C" fn ProbabilisticScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, mut amount_msat: u64, mut capacity_msat: u64, source: &crate::lightning::routing::network_graph::NodeId, target: &crate::lightning::routing::network_graph::NodeId) -> u64 {
+ let mut ret = <nativeProbabilisticScorer as lightning::routing::scoring::Score<>>::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, short_channel_id, amount_msat, capacity_msat, source.get_native_ref(), target.get_native_ref());
+ ret
+}
+extern "C" fn ProbabilisticScorer_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeProbabilisticScorer as lightning::routing::scoring::Score<>>::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..], short_channel_id)
+}
+extern "C" fn ProbabilisticScorer_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) {
+ let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); };
+ <nativeProbabilisticScorer as lightning::routing::scoring::Score<>>::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..])
+}
+
+#[no_mangle]
+/// Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read
+pub extern "C" fn ProbabilisticScorer_write(obj: &ProbabilisticScorer) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn ProbabilisticScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeProbabilisticScorer) })
+}
+#[no_mangle]
+/// Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write
+pub extern "C" fn ProbabilisticScorer_read(ser: crate::c_types::u8slice, arg: crate::c_types::derived::C2Tuple_ProbabilisticScoringParametersNetworkGraphZ) -> crate::c_types::derived::CResult_ProbabilisticScorerDecodeErrorZ {
+ let (mut orig_arg_0, mut orig_arg_1) = arg.to_rust(); let mut local_arg = (*unsafe { Box::from_raw(orig_arg_0.take_inner()) }, orig_arg_1.get_native_ref());
+ let arg_conv = local_arg;
+ let res: Result<lightning::routing::scoring::ProbabilisticScorer<&lightning::routing::network_graph::NetworkGraph>, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::ProbabilisticScorer { 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
+}
mod time {
use alloc::str::FromStr;