1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Route hints used in constructing invoices for [phantom node payents].
14 * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
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 {
22 if (ptr != 0) { bindings.PhantomRouteHints_free(ptr); }
26 * The list of channels to be included in the invoice route hints.
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 ret_conv_16_hu_conv.ptrs_to.add(this);
37 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
39 return ret_conv_16_arr;
43 * The list of channels to be included in the invoice route hints.
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);
52 * A fake scid used for representing the phantom node's fake channel in generating the invoice
55 public long get_phantom_scid() {
56 long ret = bindings.PhantomRouteHints_get_phantom_scid(this.ptr);
57 Reference.reachabilityFence(this);
62 * A fake scid used for representing the phantom node's fake channel in generating the invoice
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);
72 * The pubkey of the real backing node that would ultimately receive the payment.
74 public byte[] get_real_node_pubkey() {
75 byte[] ret = bindings.PhantomRouteHints_get_real_node_pubkey(this.ptr);
76 Reference.reachabilityFence(this);
81 * The pubkey of the real backing node that would ultimately receive the payment.
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);
90 * Constructs a new PhantomRouteHints given each field
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 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
99 ret_hu_conv.ptrs_to.add(ret_hu_conv);
104 long ret = bindings.PhantomRouteHints_clone_ptr(this.ptr);
105 Reference.reachabilityFence(this);
110 * Creates a copy of the PhantomRouteHints
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 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
117 ret_hu_conv.ptrs_to.add(this);
122 * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
124 public byte[] write() {
125 byte[] ret = bindings.PhantomRouteHints_write(this.ptr);
126 Reference.reachabilityFence(this);
131 * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
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);