[Java] Update auto-generated Java bindings for 0.0.113
[ldk-java] / src / main / java / org / ldk / structs / PhantomKeysManager.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  * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node
13  * payments.
14  * 
15  * A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be
16  * paid to one of multiple nodes. This works because we encode the invoice route hints such that
17  * LDK will recognize an incoming payment as destined for a phantom node, and collect the payment
18  * itself without ever needing to forward to this fake node.
19  * 
20  * Phantom node payments are useful for load balancing between multiple LDK nodes. They also
21  * provide some fault tolerance, because payers will automatically retry paying other provided
22  * nodes in the case that one node goes down.
23  * 
24  * Note that multi-path payments are not supported in phantom invoices for security reasons.
25  * Switching between this struct and [`KeysManager`] will invalidate any previously issued
26  * invoices and attempts to pay previous invoices will fail.
27  */
28 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
29 public class PhantomKeysManager extends CommonBase {
30         PhantomKeysManager(Object _dummy, long ptr) { super(ptr); }
31         @Override @SuppressWarnings("deprecation")
32         protected void finalize() throws Throwable {
33                 super.finalize();
34                 if (ptr != 0) { bindings.PhantomKeysManager_free(ptr); }
35         }
36
37         /**
38          * Constructs a new KeysInterface which calls the relevant methods on this_arg.
39          * This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is
40          */
41         public KeysInterface as_KeysInterface() {
42                 long ret = bindings.PhantomKeysManager_as_KeysInterface(this.ptr);
43                 Reference.reachabilityFence(this);
44                 if (ret >= 0 && ret <= 4096) { return null; }
45                 KeysInterface ret_hu_conv = new KeysInterface(null, ret);
46                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
47                 return ret_hu_conv;
48         }
49
50         /**
51          * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed`
52          * that is shared across all nodes that intend to participate in [phantom node payments]
53          * together.
54          * 
55          * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
56          * `starting_time_nanos`.
57          * 
58          * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the
59          * same across restarts, or else inbound payments may fail.
60          * 
61          * [phantom node payments]: PhantomKeysManager
62          */
63         public static PhantomKeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos, byte[] cross_node_seed) {
64                 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));
65                 Reference.reachabilityFence(seed);
66                 Reference.reachabilityFence(starting_time_secs);
67                 Reference.reachabilityFence(starting_time_nanos);
68                 Reference.reachabilityFence(cross_node_seed);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.PhantomKeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomKeysManager(null, ret); }
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
72                 return ret_hu_conv;
73         }
74
75         /**
76          * See [`KeysManager::spend_spendable_outputs`] for documentation on this method.
77          */
78         public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight) {
79                 long ret = bindings.PhantomKeysManager_spend_spendable_outputs(this.ptr, descriptors != null ? Arrays.stream(descriptors).mapToLong(descriptors_conv_27 -> descriptors_conv_27.ptr).toArray() : null, outputs != null ? Arrays.stream(outputs).mapToLong(outputs_conv_7 -> outputs_conv_7.ptr).toArray() : null, change_destination_script, feerate_sat_per_1000_weight);
80                 Reference.reachabilityFence(this);
81                 Reference.reachabilityFence(descriptors);
82                 Reference.reachabilityFence(outputs);
83                 Reference.reachabilityFence(change_destination_script);
84                 Reference.reachabilityFence(feerate_sat_per_1000_weight);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
87                 return ret_hu_conv;
88         }
89
90         /**
91          * See [`KeysManager::derive_channel_keys`] for documentation on this method.
92          */
93         public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] params) {
94                 long ret = bindings.PhantomKeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.check_arr_len(params, 32));
95                 Reference.reachabilityFence(this);
96                 Reference.reachabilityFence(channel_value_satoshis);
97                 Reference.reachabilityFence(params);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
101                 return ret_hu_conv;
102         }
103
104 }