[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ScoreLookUp.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * An interface used to score payment channels for path finding.
12  * 
13  * `ScoreLookUp` is used to determine the penalty for a given channel.
14  * 
15  * Scoring is in terms of fees willing to be paid in order to avoid routing through a channel.
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class ScoreLookUp extends CommonBase {
19         final bindings.LDKScoreLookUp bindings_instance;
20         ScoreLookUp(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
21         private ScoreLookUp(bindings.LDKScoreLookUp arg) {
22                 super(bindings.LDKScoreLookUp_new(arg));
23                 this.ptrs_to.add(arg);
24                 this.bindings_instance = arg;
25         }
26         @Override @SuppressWarnings("deprecation")
27         protected void finalize() throws Throwable {
28                 if (ptr != 0) { bindings.ScoreLookUp_free(ptr); } super.finalize();
29         }
30         /**
31          * Destroys the object, freeing associated resources. After this call, any access
32          * to this object may result in a SEGFAULT or worse.
33          *
34          * You should generally NEVER call this method. You should let the garbage collector
35          * do this for you when it finalizes objects. However, it may be useful for types
36          * which represent locks and should be closed immediately to avoid holding locks
37          * until the GC runs.
38          */
39         public void destroy() {
40                 if (ptr != 0) { bindings.ScoreLookUp_free(ptr); }
41                 ptr = 0;
42         }
43         public static interface ScoreLookUpInterface {
44                 /**
45                  * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
46                  * given channel in the direction from `source` to `target`.
47                  * 
48                  * The channel's capacity (less any other MPP parts that are also being considered for use in
49                  * the same payment) is given by `capacity_msat`. It may be determined from various sources
50                  * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
51                  * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
52                  * Thus, implementations should be overflow-safe.
53                  */
54                 long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage, ProbabilisticScoringFeeParameters score_params);
55         }
56         private static class LDKScoreLookUpHolder { ScoreLookUp held; }
57         public static ScoreLookUp new_impl(ScoreLookUpInterface arg) {
58                 final LDKScoreLookUpHolder impl_holder = new LDKScoreLookUpHolder();
59                 impl_holder.held = new ScoreLookUp(new bindings.LDKScoreLookUp() {
60                         @Override public long channel_penalty_msat(long short_channel_id, long source, long target, long usage, long score_params) {
61                                 org.ldk.structs.NodeId source_hu_conv = null; if (source < 0 || source > 4096) { source_hu_conv = new org.ldk.structs.NodeId(null, source); }
62                                 org.ldk.structs.NodeId target_hu_conv = null; if (target < 0 || target > 4096) { target_hu_conv = new org.ldk.structs.NodeId(null, target); }
63                                 org.ldk.structs.ChannelUsage usage_hu_conv = null; if (usage < 0 || usage > 4096) { usage_hu_conv = new org.ldk.structs.ChannelUsage(null, usage); }
64                                 if (usage_hu_conv != null) { usage_hu_conv.ptrs_to.add(this); };
65                                 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); }
66                                 long ret = arg.channel_penalty_msat(short_channel_id, source_hu_conv, target_hu_conv, usage_hu_conv, score_params_hu_conv);
67                                 Reference.reachabilityFence(arg);
68                                 return ret;
69                         }
70                 });
71                 return impl_holder.held;
72         }
73         /**
74          * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the
75          * given channel in the direction from `source` to `target`.
76          * 
77          * The channel's capacity (less any other MPP parts that are also being considered for use in
78          * the same payment) is given by `capacity_msat`. It may be determined from various sources
79          * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near
80          * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount.
81          * Thus, implementations should be overflow-safe.
82          */
83         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) {
84                 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);
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(short_channel_id);
87                 Reference.reachabilityFence(source);
88                 Reference.reachabilityFence(target);
89                 Reference.reachabilityFence(usage);
90                 Reference.reachabilityFence(score_params);
91                 if (this != null) { this.ptrs_to.add(source); };
92                 if (this != null) { this.ptrs_to.add(target); };
93                 if (this != null) { this.ptrs_to.add(usage); };
94                 if (this != null) { this.ptrs_to.add(score_params); };
95                 return ret;
96         }
97
98 }