6 namespace org { namespace ldk { namespace structs {
10 * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node
13 * A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be
14 * paid to one of multiple nodes. This works because we encode the invoice route hints such that
15 * LDK will recognize an incoming payment as destined for a phantom node, and collect the payment
16 * itself without ever needing to forward to this fake node.
18 * Phantom node payments are useful for load balancing between multiple LDK nodes. They also
19 * provide some fault tolerance, because payers will automatically retry paying other provided
20 * nodes in the case that one node goes down.
22 * Note that multi-path payments are not supported in phantom invoices for security reasons.
23 * Switching between this struct and [`KeysManager`] will invalidate any previously issued
24 * invoices and attempts to pay previous invoices will fail.
26 public class PhantomKeysManager : CommonBase {
27 internal PhantomKeysManager(object _dummy, long ptr) : base(ptr) { }
28 ~PhantomKeysManager() {
29 if (ptr != 0) { bindings.PhantomKeysManager_free(ptr); }
33 * Constructs a new EntropySource which calls the relevant methods on this_arg.
34 * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
36 public EntropySource as_EntropySource() {
37 long ret = bindings.PhantomKeysManager_as_EntropySource(this.ptr);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 EntropySource ret_hu_conv = new EntropySource(null, ret);
41 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
46 * Constructs a new NodeSigner which calls the relevant methods on this_arg.
47 * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is
49 public NodeSigner as_NodeSigner() {
50 long ret = bindings.PhantomKeysManager_as_NodeSigner(this.ptr);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 NodeSigner ret_hu_conv = new NodeSigner(null, ret);
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59 * Constructs a new OutputSpender which calls the relevant methods on this_arg.
60 * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is
62 public OutputSpender as_OutputSpender() {
63 long ret = bindings.PhantomKeysManager_as_OutputSpender(this.ptr);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 OutputSpender ret_hu_conv = new OutputSpender(null, ret);
67 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
72 * Constructs a new SignerProvider which calls the relevant methods on this_arg.
73 * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is
75 public SignerProvider as_SignerProvider() {
76 long ret = bindings.PhantomKeysManager_as_SignerProvider(this.ptr);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 SignerProvider ret_hu_conv = new SignerProvider(null, ret);
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
85 * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed`
86 * that is shared across all nodes that intend to participate in [phantom node payments]
89 * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
90 * `starting_time_nanos`.
92 * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the
93 * same across restarts, or else inbound payments may fail.
95 * [phantom node payments]: PhantomKeysManager
97 public static PhantomKeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos, byte[] cross_node_seed) {
98 long ret = bindings.PhantomKeysManager_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(seed, 32)), starting_time_secs, starting_time_nanos, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(cross_node_seed, 32)));
100 GC.KeepAlive(starting_time_secs);
101 GC.KeepAlive(starting_time_nanos);
102 GC.KeepAlive(cross_node_seed);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 org.ldk.structs.PhantomKeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomKeysManager(null, ret); }
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110 * See [`KeysManager::derive_channel_keys`] for documentation on this method.
112 public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] _params) {
113 long ret = bindings.PhantomKeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(_params, 32)));
115 GC.KeepAlive(channel_value_satoshis);
116 GC.KeepAlive(_params);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
124 * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc.
126 public byte[] get_node_secret_key() {
127 long ret = bindings.PhantomKeysManager_get_node_secret_key(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
135 * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the
136 * last-hop onion data, etc.
138 public byte[] get_phantom_node_secret_key() {
139 long ret = bindings.PhantomKeysManager_get_phantom_node_secret_key(this.ptr);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);