[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / RefundMaybeWithDerivedMetadataBuilder.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  * Builds a [`Refund`] for the \"offer for money\" flow.
11  * 
12  * See [module-level documentation] for usage.
13  * 
14  * [module-level documentation]: self
15  */
16 public class RefundMaybeWithDerivedMetadataBuilder : CommonBase {
17         internal RefundMaybeWithDerivedMetadataBuilder(object _dummy, long ptr) : base(ptr) { }
18         ~RefundMaybeWithDerivedMetadataBuilder() {
19                 if (ptr != 0) { bindings.RefundMaybeWithDerivedMetadataBuilder_free(ptr); }
20         }
21
22         internal long clone_ptr() {
23                 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_clone_ptr(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder
30          */
31         public RefundMaybeWithDerivedMetadataBuilder clone() {
32                 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_clone(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.RefundMaybeWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RefundMaybeWithDerivedMetadataBuilder(null, ret); }
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to
42          * send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey.
43          * 
44          * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`],
45          * and [`Refund::amount_msats`].
46          * 
47          * # Note
48          * 
49          * If constructing a [`Refund`] for use with a [`ChannelManager`], use
50          * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`].
51          * 
52          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
53          * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder
54          */
55         public static Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ of(byte[] metadata, byte[] payer_id, long amount_msats) {
56                 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_new(InternalUtils.encodeUint8Array(metadata), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payer_id, 33)), amount_msats);
57                 GC.KeepAlive(metadata);
58                 GC.KeepAlive(payer_id);
59                 GC.KeepAlive(amount_msats);
60                 if (ret >= 0 && ret <= 4096) { return null; }
61                 Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ ret_hu_conv = Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
62                 return ret_hu_conv;
63         }
64
65         /**
66          * Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id
67          * is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a
68          * different payer id for each refund, assuming a different nonce is used.  Otherwise, the
69          * provided `node_id` is used for the payer id.
70          * 
71          * Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used to
72          * verify that an [`InvoiceRequest`] was produced for the refund given an [`ExpandedKey`].
73          * 
74          * The `payment_id` is encrypted in the metadata and should be unique. This ensures that only
75          * one invoice will be paid for the refund and that payments can be uniquely identified.
76          * 
77          * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
78          * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
79          */
80         public static Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ deriving_payer_id(byte[] node_id, org.ldk.structs.ExpandedKey expanded_key, org.ldk.structs.EntropySource entropy_source, long amount_msats, byte[] payment_id) {
81                 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id, 33)), expanded_key.ptr, entropy_source.ptr, amount_msats, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)));
82                 GC.KeepAlive(node_id);
83                 GC.KeepAlive(expanded_key);
84                 GC.KeepAlive(entropy_source);
85                 GC.KeepAlive(amount_msats);
86                 GC.KeepAlive(payment_id);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ ret_hu_conv = Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(expanded_key); };
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Sets the [`Refund::description`].
96          * 
97          * Successive calls to this method will override the previous setting.
98          */
99         public void description(string description) {
100                 bindings.RefundMaybeWithDerivedMetadataBuilder_description(this.ptr, InternalUtils.encodeString(description));
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(description);
103                 if (this != null) { this.ptrs_to.AddLast(this); };
104         }
105
106         /**
107          * Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
108          * already passed is valid and can be checked for using [`Refund::is_expired`].
109          * 
110          * Successive calls to this method will override the previous setting.
111          */
112         public void absolute_expiry(long absolute_expiry) {
113                 bindings.RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
114                 GC.KeepAlive(this);
115                 GC.KeepAlive(absolute_expiry);
116                 if (this != null) { this.ptrs_to.AddLast(this); };
117         }
118
119         /**
120          * Sets the [`Refund::issuer`].
121          * 
122          * Successive calls to this method will override the previous setting.
123          */
124         public void issuer(string issuer) {
125                 bindings.RefundMaybeWithDerivedMetadataBuilder_issuer(this.ptr, InternalUtils.encodeString(issuer));
126                 GC.KeepAlive(this);
127                 GC.KeepAlive(issuer);
128                 if (this != null) { this.ptrs_to.AddLast(this); };
129         }
130
131         /**
132          * Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected
133          * by private channels or if [`Refund::payer_id`] is not a public node id.
134          * 
135          * Successive calls to this method will add another blinded path. Caller is responsible for not
136          * adding duplicate paths.
137          */
138         public void path(org.ldk.structs.BlindedPath path) {
139                 bindings.RefundMaybeWithDerivedMetadataBuilder_path(this.ptr, path.ptr);
140                 GC.KeepAlive(this);
141                 GC.KeepAlive(path);
142                 if (this != null) { this.ptrs_to.AddLast(path); };
143                 if (this != null) { this.ptrs_to.AddLast(this); };
144         }
145
146         /**
147          * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not
148          * called, [`Network::Bitcoin`] is assumed.
149          * 
150          * Successive calls to this method will override the previous setting.
151          */
152         public void chain(Network network) {
153                 bindings.RefundMaybeWithDerivedMetadataBuilder_chain(this.ptr, network);
154                 GC.KeepAlive(this);
155                 GC.KeepAlive(network);
156                 if (this != null) { this.ptrs_to.AddLast(this); };
157         }
158
159         /**
160          * Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful
161          * when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an
162          * [`Offer`] as specified by [`InvoiceRequest::quantity`].
163          * 
164          * Successive calls to this method will override the previous setting.
165          * 
166          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
167          * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
168          * [`Offer`]: crate::offers::offer::Offer
169          */
170         public void quantity(long quantity) {
171                 bindings.RefundMaybeWithDerivedMetadataBuilder_quantity(this.ptr, quantity);
172                 GC.KeepAlive(this);
173                 GC.KeepAlive(quantity);
174                 if (this != null) { this.ptrs_to.AddLast(this); };
175         }
176
177         /**
178          * Sets the [`Refund::payer_note`].
179          * 
180          * Successive calls to this method will override the previous setting.
181          */
182         public void payer_note(string payer_note) {
183                 bindings.RefundMaybeWithDerivedMetadataBuilder_payer_note(this.ptr, InternalUtils.encodeString(payer_note));
184                 GC.KeepAlive(this);
185                 GC.KeepAlive(payer_note);
186                 if (this != null) { this.ptrs_to.AddLast(this); };
187         }
188
189         /**
190          * Builds a [`Refund`] after checking for valid semantics.
191          */
192         public Result_RefundBolt12SemanticErrorZ build() {
193                 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_build(this.ptr);
194                 GC.KeepAlive(this);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 Result_RefundBolt12SemanticErrorZ ret_hu_conv = Result_RefundBolt12SemanticErrorZ.constr_from_ptr(ret);
197                 if (this != null) { this.ptrs_to.AddLast(this); };
198                 return ret_hu_conv;
199         }
200
201 }
202 } } }