[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / OfferWithExplicitMetadataBuilder.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 an [`Offer`] for the \"offer to be paid\" flow.
11  * 
12  * See [module-level documentation] for usage.
13  * 
14  * [module-level documentation]: self
15  */
16 public class OfferWithExplicitMetadataBuilder : CommonBase {
17         internal OfferWithExplicitMetadataBuilder(object _dummy, long ptr) : base(ptr) { }
18         ~OfferWithExplicitMetadataBuilder() {
19                 if (ptr != 0) { bindings.OfferWithExplicitMetadataBuilder_free(ptr); }
20         }
21
22         internal long clone_ptr() {
23                 long ret = bindings.OfferWithExplicitMetadataBuilder_clone_ptr(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * Creates a copy of the OfferWithExplicitMetadataBuilder
30          */
31         public OfferWithExplicitMetadataBuilder clone() {
32                 long ret = bindings.OfferWithExplicitMetadataBuilder_clone(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.OfferWithExplicitMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithExplicitMetadataBuilder(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 an offer using the [`Offer::signing_pubkey`] for signing invoices.
42          * The associated secret key must be remembered while the offer is valid.
43          * 
44          * Use a different pubkey per offer to avoid correlating offers.
45          * 
46          * # Note
47          * 
48          * If constructing an [`Offer`] for use with a [`ChannelManager`], use
49          * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`].
50          * 
51          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
52          * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder
53          */
54         public static OfferWithExplicitMetadataBuilder of(byte[] signing_pubkey) {
55                 long ret = bindings.OfferWithExplicitMetadataBuilder_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signing_pubkey, 33)));
56                 GC.KeepAlive(signing_pubkey);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 org.ldk.structs.OfferWithExplicitMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithExplicitMetadataBuilder(null, ret); }
59                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Sets the [`Offer::metadata`] to the given bytes.
65          * 
66          * Successive calls to this method will override the previous setting.
67          */
68         public Result_NoneBolt12SemanticErrorZ metadata(byte[] metadata) {
69                 long ret = bindings.OfferWithExplicitMetadataBuilder_metadata(this.ptr, InternalUtils.encodeUint8Array(metadata));
70                 GC.KeepAlive(this);
71                 GC.KeepAlive(metadata);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
74                 if (this != null) { this.ptrs_to.AddLast(this); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called,
80          * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported.
81          * 
82          * See [`Offer::chains`] on how this relates to the payment currency.
83          * 
84          * Successive calls to this method will add another chain hash.
85          */
86         public void chain(Network network) {
87                 bindings.OfferWithExplicitMetadataBuilder_chain(this.ptr, network);
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(network);
90                 if (this != null) { this.ptrs_to.AddLast(this); };
91         }
92
93         /**
94          * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
95          * 
96          * Successive calls to this method will override the previous setting.
97          */
98         public void amount_msats(long amount_msats) {
99                 bindings.OfferWithExplicitMetadataBuilder_amount_msats(this.ptr, amount_msats);
100                 GC.KeepAlive(this);
101                 GC.KeepAlive(amount_msats);
102                 if (this != null) { this.ptrs_to.AddLast(this); };
103         }
104
105         /**
106          * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
107          * already passed is valid and can be checked for using [`Offer::is_expired`].
108          * 
109          * Successive calls to this method will override the previous setting.
110          */
111         public void absolute_expiry(long absolute_expiry) {
112                 bindings.OfferWithExplicitMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
113                 GC.KeepAlive(this);
114                 GC.KeepAlive(absolute_expiry);
115                 if (this != null) { this.ptrs_to.AddLast(this); };
116         }
117
118         /**
119          * Sets the [`Offer::description`].
120          * 
121          * Successive calls to this method will override the previous setting.
122          */
123         public void description(string description) {
124                 bindings.OfferWithExplicitMetadataBuilder_description(this.ptr, InternalUtils.encodeString(description));
125                 GC.KeepAlive(this);
126                 GC.KeepAlive(description);
127                 if (this != null) { this.ptrs_to.AddLast(this); };
128         }
129
130         /**
131          * Sets the [`Offer::issuer`].
132          * 
133          * Successive calls to this method will override the previous setting.
134          */
135         public void issuer(string issuer) {
136                 bindings.OfferWithExplicitMetadataBuilder_issuer(this.ptr, InternalUtils.encodeString(issuer));
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(issuer);
139                 if (this != null) { this.ptrs_to.AddLast(this); };
140         }
141
142         /**
143          * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by
144          * private channels or if [`Offer::signing_pubkey`] is not a public node id.
145          * 
146          * Successive calls to this method will add another blinded path. Caller is responsible for not
147          * adding duplicate paths.
148          */
149         public void path(org.ldk.structs.BlindedPath path) {
150                 bindings.OfferWithExplicitMetadataBuilder_path(this.ptr, path.ptr);
151                 GC.KeepAlive(this);
152                 GC.KeepAlive(path);
153                 if (this != null) { this.ptrs_to.AddLast(path); };
154                 if (this != null) { this.ptrs_to.AddLast(this); };
155         }
156
157         /**
158          * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
159          * [`Quantity::One`].
160          * 
161          * Successive calls to this method will override the previous setting.
162          */
163         public void supported_quantity(org.ldk.structs.Quantity quantity) {
164                 bindings.OfferWithExplicitMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
165                 GC.KeepAlive(this);
166                 GC.KeepAlive(quantity);
167                 if (this != null) { this.ptrs_to.AddLast(quantity); };
168                 if (this != null) { this.ptrs_to.AddLast(this); };
169         }
170
171         /**
172          * Builds an [`Offer`] from the builder's settings.
173          */
174         public Result_OfferBolt12SemanticErrorZ build() {
175                 long ret = bindings.OfferWithExplicitMetadataBuilder_build(this.ptr);
176                 GC.KeepAlive(this);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 Result_OfferBolt12SemanticErrorZ ret_hu_conv = Result_OfferBolt12SemanticErrorZ.constr_from_ptr(ret);
179                 if (this != null) { this.ptrs_to.AddLast(this); };
180                 return ret_hu_conv;
181         }
182
183 }
184 } } }