[C#] Run tests against release library in determinism CI run
[ldk-java] / src / main / java / org / ldk / structs / PhantomRouteHints.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 /**
12  * Route hints used in constructing invoices for [phantom node payents].
13  * 
14  * [phantom node payments]: crate::sign::PhantomKeysManager
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class PhantomRouteHints extends CommonBase {
18         PhantomRouteHints(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.PhantomRouteHints_free(ptr); }
23         }
24
25         /**
26          * The list of channels to be included in the invoice route hints.
27          */
28         public ChannelDetails[] get_channels() {
29                 long[] ret = bindings.PhantomRouteHints_get_channels(this.ptr);
30                 Reference.reachabilityFence(this);
31                 int ret_conv_16_len = ret.length;
32                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
33                 for (int q = 0; q < ret_conv_16_len; q++) {
34                         long ret_conv_16 = ret[q];
35                         org.ldk.structs.ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.ChannelDetails(null, ret_conv_16); }
36                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
37                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
38                 }
39                 return ret_conv_16_arr;
40         }
41
42         /**
43          * The list of channels to be included in the invoice route hints.
44          */
45         public void set_channels(ChannelDetails[] val) {
46                 bindings.PhantomRouteHints_set_channels(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_16 -> val_conv_16.ptr).toArray() : null);
47                 Reference.reachabilityFence(this);
48                 Reference.reachabilityFence(val);
49                 for (ChannelDetails val_conv_16: val) { if (this != null) { this.ptrs_to.add(val_conv_16); }; };
50         }
51
52         /**
53          * A fake scid used for representing the phantom node's fake channel in generating the invoice
54          * route hints.
55          */
56         public long get_phantom_scid() {
57                 long ret = bindings.PhantomRouteHints_get_phantom_scid(this.ptr);
58                 Reference.reachabilityFence(this);
59                 return ret;
60         }
61
62         /**
63          * A fake scid used for representing the phantom node's fake channel in generating the invoice
64          * route hints.
65          */
66         public void set_phantom_scid(long val) {
67                 bindings.PhantomRouteHints_set_phantom_scid(this.ptr, val);
68                 Reference.reachabilityFence(this);
69                 Reference.reachabilityFence(val);
70         }
71
72         /**
73          * The pubkey of the real backing node that would ultimately receive the payment.
74          */
75         public byte[] get_real_node_pubkey() {
76                 byte[] ret = bindings.PhantomRouteHints_get_real_node_pubkey(this.ptr);
77                 Reference.reachabilityFence(this);
78                 return ret;
79         }
80
81         /**
82          * The pubkey of the real backing node that would ultimately receive the payment.
83          */
84         public void set_real_node_pubkey(byte[] val) {
85                 bindings.PhantomRouteHints_set_real_node_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
86                 Reference.reachabilityFence(this);
87                 Reference.reachabilityFence(val);
88         }
89
90         /**
91          * Constructs a new PhantomRouteHints given each field
92          */
93         public static PhantomRouteHints of(ChannelDetails[] channels_arg, long phantom_scid_arg, byte[] real_node_pubkey_arg) {
94                 long ret = bindings.PhantomRouteHints_new(channels_arg != null ? Arrays.stream(channels_arg).mapToLong(channels_arg_conv_16 -> channels_arg_conv_16.ptr).toArray() : null, phantom_scid_arg, InternalUtils.check_arr_len(real_node_pubkey_arg, 33));
95                 Reference.reachabilityFence(channels_arg);
96                 Reference.reachabilityFence(phantom_scid_arg);
97                 Reference.reachabilityFence(real_node_pubkey_arg);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
101                 for (ChannelDetails channels_arg_conv_16: channels_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channels_arg_conv_16); }; };
102                 return ret_hu_conv;
103         }
104
105         long clone_ptr() {
106                 long ret = bindings.PhantomRouteHints_clone_ptr(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * Creates a copy of the PhantomRouteHints
113          */
114         public PhantomRouteHints clone() {
115                 long ret = bindings.PhantomRouteHints_clone(this.ptr);
116                 Reference.reachabilityFence(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
120                 return ret_hu_conv;
121         }
122
123         /**
124          * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
125          */
126         public byte[] write() {
127                 byte[] ret = bindings.PhantomRouteHints_write(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
134          */
135         public static Result_PhantomRouteHintsDecodeErrorZ read(byte[] ser) {
136                 long ret = bindings.PhantomRouteHints_read(ser);
137                 Reference.reachabilityFence(ser);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 Result_PhantomRouteHintsDecodeErrorZ ret_hu_conv = Result_PhantomRouteHintsDecodeErrorZ.constr_from_ptr(ret);
140                 return ret_hu_conv;
141         }
142
143 }