[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / Score.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * An interface used to score payment channels for path finding.
10  * 
11  * \tScoring is in terms of fees willing to be paid in order to avoid routing through a channel.
12  */
13 public class Score : CommonBase {
14         internal readonly bindings.LDKScore bindings_instance;
15         internal Score(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
16         private Score(bindings.LDKScore arg) : base(bindings.LDKScore_new(arg)) {
17                 this.ptrs_to.AddLast(arg);
18                 this.bindings_instance = arg;
19         }
20         ~Score() {
21                 if (ptr != 0) { bindings.Score_free(ptr); }
22         }
23
24         public interface ScoreInterface {
25                 /**
26                  * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
27                  * given channel in the direction from `source` to `target`.
28                  * 
29                  * The channel's capacity (less any other MPP parts that are also being considered for use in
30                  * the same payment) is given by `capacity_msat`. It may be determined from various sources
31                  * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
32                  * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
33                  * Thus, implementations should be overflow-safe.
34                  */
35                 long channel_penalty_msat(long _short_channel_id, NodeId _source, NodeId _target, ChannelUsage _usage, ProbabilisticScoringFeeParameters _score_params);
36                 /**
37                  * Handles updating channel penalties after failing to route through a channel.
38                  */
39                 void payment_path_failed(Path _path, long _short_channel_id);
40                 /**
41                  * Handles updating channel penalties after successfully routing along a path.
42                  */
43                 void payment_path_successful(Path _path);
44                 /**
45                  * Handles updating channel penalties after a probe over the given path failed.
46                  */
47                 void probe_failed(Path _path, long _short_channel_id);
48                 /**
49                  * Handles updating channel penalties after a probe over the given path succeeded.
50                  */
51                 void probe_successful(Path _path);
52                 /**
53                  * Serialize the object into a byte array
54                  */
55                 byte[] write();
56         }
57         private class LDKScoreHolder { internal Score held; }
58         private class LDKScoreImpl : bindings.LDKScore {
59                 internal LDKScoreImpl(ScoreInterface arg, LDKScoreHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
60                 private ScoreInterface arg;
61                 private LDKScoreHolder impl_holder;
62                 public long channel_penalty_msat(long _short_channel_id, long _source, long _target, long _usage, long _score_params) {
63                         org.ldk.structs.NodeId _source_hu_conv = null; if (_source < 0 || _source > 4096) { _source_hu_conv = new org.ldk.structs.NodeId(null, _source); }
64                         org.ldk.structs.NodeId _target_hu_conv = null; if (_target < 0 || _target > 4096) { _target_hu_conv = new org.ldk.structs.NodeId(null, _target); }
65                         org.ldk.structs.ChannelUsage _usage_hu_conv = null; if (_usage < 0 || _usage > 4096) { _usage_hu_conv = new org.ldk.structs.ChannelUsage(null, _usage); }
66                         if (_usage_hu_conv != null) { _usage_hu_conv.ptrs_to.AddLast(this); };
67                         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); }
68                         long ret = arg.channel_penalty_msat(_short_channel_id, _source_hu_conv, _target_hu_conv, _usage_hu_conv, _score_params_hu_conv);
69                                 GC.KeepAlive(arg);
70                         return ret;
71                 }
72                 public void payment_path_failed(long _path, long _short_channel_id) {
73                         org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
74                         arg.payment_path_failed(_path_hu_conv, _short_channel_id);
75                                 GC.KeepAlive(arg);
76                 }
77                 public void payment_path_successful(long _path) {
78                         org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
79                         arg.payment_path_successful(_path_hu_conv);
80                                 GC.KeepAlive(arg);
81                 }
82                 public void probe_failed(long _path, long _short_channel_id) {
83                         org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
84                         arg.probe_failed(_path_hu_conv, _short_channel_id);
85                                 GC.KeepAlive(arg);
86                 }
87                 public void probe_successful(long _path) {
88                         org.ldk.structs.Path _path_hu_conv = null; if (_path < 0 || _path > 4096) { _path_hu_conv = new org.ldk.structs.Path(null, _path); }
89                         arg.probe_successful(_path_hu_conv);
90                                 GC.KeepAlive(arg);
91                 }
92                 public byte[] write() {
93                         byte[] ret = arg.write();
94                                 GC.KeepAlive(arg);
95                         return ret;
96                 }
97         }
98         public static Score new_impl(ScoreInterface arg) {
99                 LDKScoreHolder impl_holder = new LDKScoreHolder();
100                 impl_holder.held = new Score(new LDKScoreImpl(arg, impl_holder));
101                 return impl_holder.held;
102         }
103         /**
104          * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
105          * given channel in the direction from `source` to `target`.
106          * 
107          * The channel's capacity (less any other MPP parts that are also being considered for use in
108          * the same payment) is given by `capacity_msat`. It may be determined from various sources
109          * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
110          * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
111          * Thus, implementations should be overflow-safe.
112          */
113         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) {
114                 long ret = bindings.Score_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);
115                 GC.KeepAlive(this);
116                 GC.KeepAlive(short_channel_id);
117                 GC.KeepAlive(source);
118                 GC.KeepAlive(target);
119                 GC.KeepAlive(usage);
120                 GC.KeepAlive(score_params);
121                 if (this != null) { this.ptrs_to.AddLast(source); };
122                 if (this != null) { this.ptrs_to.AddLast(target); };
123                 if (this != null) { this.ptrs_to.AddLast(usage); };
124                 if (this != null) { this.ptrs_to.AddLast(score_params); };
125                 return ret;
126         }
127
128         /**
129          * Handles updating channel penalties after failing to route through a channel.
130          */
131         public void payment_path_failed(org.ldk.structs.Path path, long short_channel_id) {
132                 bindings.Score_payment_path_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id);
133                 GC.KeepAlive(this);
134                 GC.KeepAlive(path);
135                 GC.KeepAlive(short_channel_id);
136                 if (this != null) { this.ptrs_to.AddLast(path); };
137         }
138
139         /**
140          * Handles updating channel penalties after successfully routing along a path.
141          */
142         public void payment_path_successful(org.ldk.structs.Path path) {
143                 bindings.Score_payment_path_successful(this.ptr, path == null ? 0 : path.ptr);
144                 GC.KeepAlive(this);
145                 GC.KeepAlive(path);
146                 if (this != null) { this.ptrs_to.AddLast(path); };
147         }
148
149         /**
150          * Handles updating channel penalties after a probe over the given path failed.
151          */
152         public void probe_failed(org.ldk.structs.Path path, long short_channel_id) {
153                 bindings.Score_probe_failed(this.ptr, path == null ? 0 : path.ptr, short_channel_id);
154                 GC.KeepAlive(this);
155                 GC.KeepAlive(path);
156                 GC.KeepAlive(short_channel_id);
157                 if (this != null) { this.ptrs_to.AddLast(path); };
158         }
159
160         /**
161          * Handles updating channel penalties after a probe over the given path succeeded.
162          */
163         public void probe_successful(org.ldk.structs.Path path) {
164                 bindings.Score_probe_successful(this.ptr, path == null ? 0 : path.ptr);
165                 GC.KeepAlive(this);
166                 GC.KeepAlive(path);
167                 if (this != null) { this.ptrs_to.AddLast(path); };
168         }
169
170         /**
171          * Serialize the object into a byte array
172          */
173         public byte[] write() {
174                 byte[] ret = bindings.Score_write(this.ptr);
175                 GC.KeepAlive(this);
176                 return ret;
177         }
178
179 }
180 } } }