[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ScoreLookUp.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
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`.
15          * 
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.
21          */
22         long channel_penalty_msat(CandidateRouteHop candidate, ChannelUsage usage, ProbabilisticScoringFeeParameters score_params);
23 }
24
25 /**
26  * An interface used to score payment channels for path finding.
27  * 
28  * `ScoreLookUp` is used to determine the penalty for a given channel.
29  * 
30  * Scoring is in terms of fees willing to be paid in order to avoid routing through a channel.
31  */
32 public class ScoreLookUp : CommonBase {
33         internal bindings.LDKScoreLookUp bindings_instance;
34         internal long instance_idx;
35
36         internal ScoreLookUp(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
37         ~ScoreLookUp() {
38                 if (ptr != 0) { bindings.ScoreLookUp_free(ptr); }
39         }
40
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);
52                                 GC.KeepAlive(arg);
53                         return ret;
54                 }
55         }
56
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);
62
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;
67         }
68
69         /**
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`.
72          * 
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.
78          */
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 == null ? 0 : candidate.ptr, usage == null ? 0 : usage.ptr, score_params == null ? 0 : score_params.ptr);
81                 GC.KeepAlive(this);
82                 GC.KeepAlive(candidate);
83                 GC.KeepAlive(usage);
84                 GC.KeepAlive(score_params);
85                 if (this != null) { this.ptrs_to.AddLast(usage); };
86                 if (this != null) { this.ptrs_to.AddLast(score_params); };
87                 return ret;
88         }
89
90 }
91 } } }