[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PhantomKeysManager.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node
11  * payments.
12  * 
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.
17  * 
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.
21  * 
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.
25  */
26 public class PhantomKeysManager : CommonBase {
27         internal PhantomKeysManager(object _dummy, long ptr) : base(ptr) { }
28         ~PhantomKeysManager() {
29                 if (ptr != 0) { bindings.PhantomKeysManager_free(ptr); }
30         }
31
32         /**
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
35          */
36         public EntropySource as_EntropySource() {
37                 long ret = bindings.PhantomKeysManager_as_EntropySource(this.ptr);
38                 GC.KeepAlive(this);
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); };
42                 return ret_hu_conv;
43         }
44
45         /**
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
48          */
49         public NodeSigner as_NodeSigner() {
50                 long ret = bindings.PhantomKeysManager_as_NodeSigner(this.ptr);
51                 GC.KeepAlive(this);
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); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Constructs a new SignerProvider which calls the relevant methods on this_arg.
60          * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is
61          */
62         public SignerProvider as_SignerProvider() {
63                 long ret = bindings.PhantomKeysManager_as_SignerProvider(this.ptr);
64                 GC.KeepAlive(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 SignerProvider ret_hu_conv = new SignerProvider(null, ret);
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed`
73          * that is shared across all nodes that intend to participate in [phantom node payments]
74          * together.
75          * 
76          * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
77          * `starting_time_nanos`.
78          * 
79          * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the
80          * same across restarts, or else inbound payments may fail.
81          * 
82          * [phantom node payments]: PhantomKeysManager
83          */
84         public static PhantomKeysManager of(byte[] seed, long starting_time_secs, int starting_time_nanos, byte[] cross_node_seed) {
85                 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)));
86                 GC.KeepAlive(seed);
87                 GC.KeepAlive(starting_time_secs);
88                 GC.KeepAlive(starting_time_nanos);
89                 GC.KeepAlive(cross_node_seed);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.PhantomKeysManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomKeysManager(null, ret); }
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * See [`KeysManager::spend_spendable_outputs`] for documentation on this method.
98          */
99         public Result_TransactionNoneZ spend_spendable_outputs(SpendableOutputDescriptor[] descriptors, TxOut[] outputs, byte[] change_destination_script, int feerate_sat_per_1000_weight, org.ldk.structs.Option_u32Z locktime) {
100                 long ret = bindings.PhantomKeysManager_spend_spendable_outputs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(descriptors, descriptors_conv_27 => descriptors_conv_27.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(outputs, outputs_conv_7 => outputs_conv_7.ptr)), InternalUtils.encodeUint8Array(change_destination_script), feerate_sat_per_1000_weight, locktime.ptr);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(descriptors);
103                 GC.KeepAlive(outputs);
104                 GC.KeepAlive(change_destination_script);
105                 GC.KeepAlive(feerate_sat_per_1000_weight);
106                 GC.KeepAlive(locktime);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
109                 foreach (SpendableOutputDescriptor descriptors_conv_27 in descriptors) { if (this != null) { this.ptrs_to.AddLast(descriptors_conv_27); }; };
110                 if (this != null) { this.ptrs_to.AddLast(locktime); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * See [`KeysManager::derive_channel_keys`] for documentation on this method.
116          */
117         public InMemorySigner derive_channel_keys(long channel_value_satoshis, byte[] _params) {
118                 long ret = bindings.PhantomKeysManager_derive_channel_keys(this.ptr, channel_value_satoshis, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(_params, 32)));
119                 GC.KeepAlive(this);
120                 GC.KeepAlive(channel_value_satoshis);
121                 GC.KeepAlive(_params);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
125                 return ret_hu_conv;
126         }
127
128         /**
129          * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc.
130          */
131         public byte[] get_node_secret_key() {
132                 long ret = bindings.PhantomKeysManager_get_node_secret_key(this.ptr);
133                 GC.KeepAlive(this);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
136                 return ret_conv;
137         }
138
139         /**
140          * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the
141          * last-hop onion data, etc.
142          */
143         public byte[] get_phantom_node_secret_key() {
144                 long ret = bindings.PhantomKeysManager_get_phantom_node_secret_key(this.ptr);
145                 GC.KeepAlive(this);
146                 if (ret >= 0 && ret <= 4096) { return null; }
147                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
148                 return ret_conv;
149         }
150
151 }
152 } } }