Merge pull request #50 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / Score.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 javax.annotation.Nullable;
8
9 /**
10  * An interface used to score payment channels for path finding.
11  * 
12  * \tScoring is in terms of fees willing to be paid in order to avoid routing through a channel.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Score extends CommonBase {
16         final bindings.LDKScore bindings_instance;
17         Score(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
18         private Score(bindings.LDKScore arg) {
19                 super(bindings.LDKScore_new(arg));
20                 this.ptrs_to.add(arg);
21                 this.bindings_instance = arg;
22         }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 if (ptr != 0) { bindings.Score_free(ptr); } super.finalize();
26         }
27
28         public static interface ScoreInterface {
29                 /**
30                  * Returns the fee in msats willing to be paid to avoid routing through the given channel.
31                  */
32                 long channel_penalty_msat(long short_channel_id);
33         }
34         private static class LDKScoreHolder { Score held; }
35         public static Score new_impl(ScoreInterface arg) {
36                 final LDKScoreHolder impl_holder = new LDKScoreHolder();
37                 impl_holder.held = new Score(new bindings.LDKScore() {
38                         @Override public long channel_penalty_msat(long short_channel_id) {
39                                 long ret = arg.channel_penalty_msat(short_channel_id);
40                                 return ret;
41                         }
42                 });
43                 return impl_holder.held;
44         }
45         /**
46          * Returns the fee in msats willing to be paid to avoid routing through the given channel.
47          */
48         public long channel_penalty_msat(long short_channel_id) {
49                 long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id);
50                 return ret;
51         }
52
53 }