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(long short_channel_id, NodeId source, NodeId target, 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 _short_channel_id, long _source, long _target, long _usage, long _score_params) {
47 org.ldk.structs.NodeId _source_hu_conv = null; if (_source < 0 || _source > 4096) { _source_hu_conv = new org.ldk.structs.NodeId(null, _source); }
48 org.ldk.structs.NodeId _target_hu_conv = null; if (_target < 0 || _target > 4096) { _target_hu_conv = new org.ldk.structs.NodeId(null, _target); }
49 org.ldk.structs.ChannelUsage _usage_hu_conv = null; if (_usage < 0 || _usage > 4096) { _usage_hu_conv = new org.ldk.structs.ChannelUsage(null, _usage); }
50 if (_usage_hu_conv != null) { _usage_hu_conv.ptrs_to.AddLast(this); };
51 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); }
52 long ret = arg.channel_penalty_msat(_short_channel_id, _source_hu_conv, _target_hu_conv, _usage_hu_conv, _score_params_hu_conv);
58 /** Creates a new instance of ScoreLookUp from a given implementation */
59 public static ScoreLookUp new_impl(ScoreLookUpInterface arg) {
60 LDKScoreLookUpHolder impl_holder = new LDKScoreLookUpHolder();
61 LDKScoreLookUpImpl impl = new LDKScoreLookUpImpl(arg, impl_holder);
62 long[] ptr_idx = bindings.LDKScoreLookUp_new(impl);
64 impl_holder.held = new ScoreLookUp(null, ptr_idx[0]);
65 impl_holder.held.instance_idx = ptr_idx[1];
66 impl_holder.held.bindings_instance = impl;
67 return impl_holder.held;
71 * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
72 * given channel in the direction from `source` to `target`.
74 * The channel's capacity (less any other MPP parts that are also being considered for use in
75 * the same payment) is given by `capacity_msat`. It may be determined from various sources
76 * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
77 * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
78 * Thus, implementations should be overflow-safe.
80 public long channel_penalty_msat(long short_channel_id, org.ldk.structs.NodeId source, org.ldk.structs.NodeId target, org.ldk.structs.ChannelUsage usage, org.ldk.structs.ProbabilisticScoringFeeParameters score_params) {
81 long ret = bindings.ScoreLookUp_channel_penalty_msat(this.ptr, short_channel_id, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, usage == null ? 0 : usage.ptr, score_params == null ? 0 : score_params.ptr);
83 GC.KeepAlive(short_channel_id);
87 GC.KeepAlive(score_params);
88 if (this != null) { this.ptrs_to.AddLast(source); };
89 if (this != null) { this.ptrs_to.AddLast(target); };
90 if (this != null) { this.ptrs_to.AddLast(usage); };
91 if (this != null) { this.ptrs_to.AddLast(score_params); };