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 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;
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).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); }; };
53 * A fake scid used for representing the phantom node's fake channel in generating the invoice
56 public long get_phantom_scid() {
57 long ret = bindings.PhantomRouteHints_get_phantom_scid(this.ptr);
58 Reference.reachabilityFence(this);
63 * A fake scid used for representing the phantom node's fake channel in generating the invoice
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);
73 * The pubkey of the real backing node that would ultimately receive the payment.
75 public byte[] get_real_node_pubkey() {
76 byte[] ret = bindings.PhantomRouteHints_get_real_node_pubkey(this.ptr);
77 Reference.reachabilityFence(this);
82 * The pubkey of the real backing node that would ultimately receive the payment.
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);
91 * Constructs a new PhantomRouteHints given each field
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 == null ? 0 : 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); }; };
106 long ret = bindings.PhantomRouteHints_clone_ptr(this.ptr);
107 Reference.reachabilityFence(this);
112 * Creates a copy of the PhantomRouteHints
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); };
124 * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
126 public byte[] write() {
127 byte[] ret = bindings.PhantomRouteHints_write(this.ptr);
128 Reference.reachabilityFence(this);
133 * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
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);