[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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 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
61          */
62         public OutputSpender as_OutputSpender() {
63                 long ret = bindings.PhantomKeysManager_as_OutputSpender(this.ptr);
64                 GC.KeepAlive(this);
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); };
68                 return ret_hu_conv;
69         }
70
71         /**
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
74          */
75         public SignerProvider as_SignerProvider() {
76                 long ret = bindings.PhantomKeysManager_as_SignerProvider(this.ptr);
77                 GC.KeepAlive(this);
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); };
81                 return ret_hu_conv;
82         }
83
84         /**
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]
87          * together.
88          * 
89          * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and
90          * `starting_time_nanos`.
91          * 
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.
94          * 
95          * [phantom node payments]: PhantomKeysManager
96          */
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)));
99                 GC.KeepAlive(seed);
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); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * See [`KeysManager::derive_channel_keys`] for documentation on this method.
111          */
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)));
114                 GC.KeepAlive(this);
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); };
120                 return ret_hu_conv;
121         }
122
123         /**
124          * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc.
125          */
126         public byte[] get_node_secret_key() {
127                 long ret = bindings.PhantomKeysManager_get_node_secret_key(this.ptr);
128                 GC.KeepAlive(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
131                 return ret_conv;
132         }
133
134         /**
135          * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the
136          * last-hop onion data, etc.
137          */
138         public byte[] get_phantom_node_secret_key() {
139                 long ret = bindings.PhantomKeysManager_get_phantom_node_secret_key(this.ptr);
140                 GC.KeepAlive(this);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
143                 return ret_conv;
144         }
145
146 }
147 } } }