7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of ScoreLookUp */
12 public interface ScoreLookUpInterface {
13 /**Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
14 * given channel in the direction from `source` to `target`.
16 * The channel's capacity (less any other MPP parts that are also being considered for use in
17 * the same payment) is given by `capacity_msat`. It may be determined from various sources
18 * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
19 * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
20 * Thus, implementations should be overflow-safe.
22 long channel_penalty_msat(CandidateRouteHop candidate, ChannelUsage usage, ProbabilisticScoringFeeParameters score_params);
26 * An interface used to score payment channels for path finding.
28 * `ScoreLookUp` is used to determine the penalty for a given channel.
30 * Scoring is in terms of fees willing to be paid in order to avoid routing through a channel.
32 public class ScoreLookUp : CommonBase {
33 internal bindings.LDKScoreLookUp bindings_instance;
34 internal long instance_idx;
36 internal ScoreLookUp(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
38 if (ptr != 0) { bindings.ScoreLookUp_free(ptr); }
41 private class LDKScoreLookUpHolder { internal ScoreLookUp held; }
42 private class LDKScoreLookUpImpl : bindings.LDKScoreLookUp {
43 internal LDKScoreLookUpImpl(ScoreLookUpInterface arg, LDKScoreLookUpHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
44 private ScoreLookUpInterface arg;
45 private LDKScoreLookUpHolder impl_holder;
46 public long channel_penalty_msat(long _candidate, long _usage, long _score_params) {
47 CandidateRouteHop _candidate_hu_conv = CandidateRouteHop.constr_from_ptr(_candidate);
48 org.ldk.structs.ChannelUsage _usage_hu_conv = null; if (_usage < 0 || _usage > 4096) { _usage_hu_conv = new org.ldk.structs.ChannelUsage(null, _usage); }
49 if (_usage_hu_conv != null) { _usage_hu_conv.ptrs_to.AddLast(this); };
50 org.ldk.structs.ProbabilisticScoringFeeParameters _score_params_hu_conv = null; if (_score_params < 0 || _score_params > 4096) { _score_params_hu_conv = new org.ldk.structs.ProbabilisticScoringFeeParameters(null, _score_params); }
51 long ret = arg.channel_penalty_msat(_candidate_hu_conv, _usage_hu_conv, _score_params_hu_conv);
57 /** Creates a new instance of ScoreLookUp from a given implementation */
58 public static ScoreLookUp new_impl(ScoreLookUpInterface arg) {
59 LDKScoreLookUpHolder impl_holder = new LDKScoreLookUpHolder();
60 LDKScoreLookUpImpl impl = new LDKScoreLookUpImpl(arg, impl_holder);
61 long[] ptr_idx = bindings.LDKScoreLookUp_new(impl);
63 impl_holder.held = new ScoreLookUp(null, ptr_idx[0]);
64 impl_holder.held.instance_idx = ptr_idx[1];
65 impl_holder.held.bindings_instance = impl;
66 return impl_holder.held;
70 * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
71 * given channel in the direction from `source` to `target`.
73 * The channel's capacity (less any other MPP parts that are also being considered for use in
74 * the same payment) is given by `capacity_msat`. It may be determined from various sources
75 * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
76 * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
77 * Thus, implementations should be overflow-safe.
79 public long channel_penalty_msat(org.ldk.structs.CandidateRouteHop candidate, org.ldk.structs.ChannelUsage usage, org.ldk.structs.ProbabilisticScoringFeeParameters score_params) {
80 long ret = bindings.ScoreLookUp_channel_penalty_msat(this.ptr, candidate.ptr, usage.ptr, score_params.ptr);
82 GC.KeepAlive(candidate);
84 GC.KeepAlive(score_params);
85 if (this != null) { this.ptrs_to.AddLast(usage); };
86 if (this != null) { this.ptrs_to.AddLast(score_params); };