[Java] Update auto-generated bindings to 0.0.105.0
[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                 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] together.
53          * 
54          * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
55          * `starting_time_nanos`.
56          * 
57          * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the
58          * same across restarts, or else inbound payments may fail.
59          * 
60          * [phantom node payments]: PhantomKeysManager
61          */
62         public static PhantomKeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos, byte[] cross_node_seed) {
63                 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));
64                 Reference.reachabilityFence(seed);
65                 Reference.reachabilityFence(starting_time_secs);
66                 Reference.reachabilityFence(starting_time_nanos);
67                 Reference.reachabilityFence(cross_node_seed);
68                 if (ret >= 0 && ret <= 4096) { return null; }
69                 PhantomKeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PhantomKeysManager(null, ret); }
70                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
71                 return ret_hu_conv;
72         }
73
74         /**
75          * See [`KeysManager::spend_spendable_outputs`] for documentation on this method.
76          */
77         public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight) {
78                 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);
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(descriptors);
81                 Reference.reachabilityFence(outputs);
82                 Reference.reachabilityFence(change_destination_script);
83                 Reference.reachabilityFence(feerate_sat_per_1000_weight);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * See [`KeysManager::derive_channel_keys`] for documentation on this method.
91          */
92         public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] params) {
93                 long ret = bindings.PhantomKeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.check_arr_len(params, 32));
94                 Reference.reachabilityFence(this);
95                 Reference.reachabilityFence(channel_value_satoshis);
96                 Reference.reachabilityFence(params);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
99                 ret_hu_conv.ptrs_to.add(this);
100                 return ret_hu_conv;
101         }
102
103 }