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 KeysInterface which calls the relevant methods on this_arg.
34 * This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is
36 public KeysInterface as_KeysInterface() {
37 long ret = bindings.PhantomKeysManager_as_KeysInterface(this.ptr);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 KeysInterface ret_hu_conv = new KeysInterface(null, ret);
41 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
46 * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed`
47 * that is shared across all nodes that intend to participate in [phantom node payments]
50 * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
51 * `starting_time_nanos`.
53 * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the
54 * same across restarts, or else inbound payments may fail.
56 * [phantom node payments]: PhantomKeysManager
58 public static PhantomKeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos, byte[] cross_node_seed) {
59 long ret = bindings.PhantomKeysManager_new(InternalUtils.check_arr_len(seed, 32), starting_time_secs, starting_time_nanos, InternalUtils.check_arr_len(cross_node_seed, 32));
61 GC.KeepAlive(starting_time_secs);
62 GC.KeepAlive(starting_time_nanos);
63 GC.KeepAlive(cross_node_seed);
64 if (ret >= 0 && ret <= 4096) { return null; }
65 org.ldk.structs.PhantomKeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomKeysManager(null, ret); }
66 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
71 * See [`KeysManager::spend_spendable_outputs`] for documentation on this method.
73 public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight) {
74 long ret = bindings.PhantomKeysManager_spend_spendable_outputs(this.ptr, descriptors != null ? InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr) : null, outputs != null ? InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr) : null, change_destination_script, feerate_sat_per_1000_weight);
76 GC.KeepAlive(descriptors);
77 GC.KeepAlive(outputs);
78 GC.KeepAlive(change_destination_script);
79 GC.KeepAlive(feerate_sat_per_1000_weight);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
86 * See [`KeysManager::derive_channel_keys`] for documentation on this method.
88 public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] _params) {
89 long ret = bindings.PhantomKeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.check_arr_len(_params, 32));
91 GC.KeepAlive(channel_value_satoshis);
92 GC.KeepAlive(_params);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };