[Java] Update auto-generated bindings to 0.0.105.0
[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::chain::keysinterface::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                         ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16); }
36                         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 == null ? 0 : val_conv_16.ptr & ~1).toArray() : null);
47                 Reference.reachabilityFence(this);
48                 Reference.reachabilityFence(val);
49         }
50
51         /**
52          * A fake scid used for representing the phantom node's fake channel in generating the invoice
53          * route hints.
54          */
55         public long get_phantom_scid() {
56                 long ret = bindings.PhantomRouteHints_get_phantom_scid(this.ptr);
57                 Reference.reachabilityFence(this);
58                 return ret;
59         }
60
61         /**
62          * A fake scid used for representing the phantom node's fake channel in generating the invoice
63          * route hints.
64          */
65         public void set_phantom_scid(long val) {
66                 bindings.PhantomRouteHints_set_phantom_scid(this.ptr, val);
67                 Reference.reachabilityFence(this);
68                 Reference.reachabilityFence(val);
69         }
70
71         /**
72          * The pubkey of the real backing node that would ultimately receive the payment.
73          */
74         public byte[] get_real_node_pubkey() {
75                 byte[] ret = bindings.PhantomRouteHints_get_real_node_pubkey(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80         /**
81          * The pubkey of the real backing node that would ultimately receive the payment.
82          */
83         public void set_real_node_pubkey(byte[] val) {
84                 bindings.PhantomRouteHints_set_real_node_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(val);
87         }
88
89         /**
90          * Constructs a new PhantomRouteHints given each field
91          */
92         public static PhantomRouteHints of(ChannelDetails[] channels_arg, long phantom_scid_arg, byte[] real_node_pubkey_arg) {
93                 long ret = bindings.PhantomRouteHints_new(channels_arg != null ? Arrays.stream(channels_arg).mapToLong(channels_arg_conv_16 -> channels_arg_conv_16 == null ? 0 : channels_arg_conv_16.ptr & ~1).toArray() : null, phantom_scid_arg, InternalUtils.check_arr_len(real_node_pubkey_arg, 33));
94                 Reference.reachabilityFence(channels_arg);
95                 Reference.reachabilityFence(phantom_scid_arg);
96                 Reference.reachabilityFence(real_node_pubkey_arg);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PhantomRouteHints(null, ret); }
99                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
100                 return ret_hu_conv;
101         }
102
103         long clone_ptr() {
104                 long ret = bindings.PhantomRouteHints_clone_ptr(this.ptr);
105                 Reference.reachabilityFence(this);
106                 return ret;
107         }
108
109         /**
110          * Creates a copy of the PhantomRouteHints
111          */
112         public PhantomRouteHints clone() {
113                 long ret = bindings.PhantomRouteHints_clone(this.ptr);
114                 Reference.reachabilityFence(this);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PhantomRouteHints(null, ret); }
117                 ret_hu_conv.ptrs_to.add(this);
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
123          */
124         public byte[] write() {
125                 byte[] ret = bindings.PhantomRouteHints_write(this.ptr);
126                 Reference.reachabilityFence(this);
127                 return ret;
128         }
129
130         /**
131          * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
132          */
133         public static Result_PhantomRouteHintsDecodeErrorZ read(byte[] ser) {
134                 long ret = bindings.PhantomRouteHints_read(ser);
135                 Reference.reachabilityFence(ser);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 Result_PhantomRouteHintsDecodeErrorZ ret_hu_conv = Result_PhantomRouteHintsDecodeErrorZ.constr_from_ptr(ret);
138                 return ret_hu_conv;
139         }
140
141 }