]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/OfferWithDerivedMetadataBuilder.cs
[C#] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / OfferWithDerivedMetadataBuilder.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 OfferWithDerivedMetadataBuilder : CommonBase {
17         internal OfferWithDerivedMetadataBuilder(object _dummy, long ptr) : base(ptr) { }
18         ~OfferWithDerivedMetadataBuilder() {
19                 if (ptr != 0) { bindings.OfferWithDerivedMetadataBuilder_free(ptr); }
20         }
21
22         internal long clone_ptr() {
23                 long ret = bindings.OfferWithDerivedMetadataBuilder_clone_ptr(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * Creates a copy of the OfferWithDerivedMetadataBuilder
30          */
31         public OfferWithDerivedMetadataBuilder clone() {
32                 long ret = bindings.OfferWithDerivedMetadataBuilder_clone(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.OfferWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithDerivedMetadataBuilder(null, ret); }
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing
42          * pubkey is derived from the given [`ExpandedKey`] and [`EntropySource`]. This provides
43          * recipient privacy by using a different signing pubkey for each offer. Otherwise, the
44          * provided `node_id` is used for the signing pubkey.
45          * 
46          * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by
47          * [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an
48          * [`ExpandedKey`].
49          * 
50          * [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify
51          * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
52          */
53         public static OfferWithDerivedMetadataBuilder deriving_signing_pubkey(byte[] node_id, org.ldk.structs.ExpandedKey expanded_key, org.ldk.structs.EntropySource entropy_source) {
54                 long ret = bindings.OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id, 33)), expanded_key.ptr, entropy_source.ptr);
55                 GC.KeepAlive(node_id);
56                 GC.KeepAlive(expanded_key);
57                 GC.KeepAlive(entropy_source);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.OfferWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithDerivedMetadataBuilder(null, ret); }
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(expanded_key); };
62                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
63                 return ret_hu_conv;
64         }
65
66         /**
67          * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called,
68          * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported.
69          * 
70          * See [`Offer::chains`] on how this relates to the payment currency.
71          * 
72          * Successive calls to this method will add another chain hash.
73          */
74         public void chain(Network network) {
75                 bindings.OfferWithDerivedMetadataBuilder_chain(this.ptr, network);
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(network);
78                 if (this != null) { this.ptrs_to.AddLast(this); };
79         }
80
81         /**
82          * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
83          * 
84          * Successive calls to this method will override the previous setting.
85          */
86         public void amount_msats(long amount_msats) {
87                 bindings.OfferWithDerivedMetadataBuilder_amount_msats(this.ptr, amount_msats);
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(amount_msats);
90                 if (this != null) { this.ptrs_to.AddLast(this); };
91         }
92
93         /**
94          * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
95          * already passed is valid and can be checked for using [`Offer::is_expired`].
96          * 
97          * Successive calls to this method will override the previous setting.
98          */
99         public void absolute_expiry(long absolute_expiry) {
100                 bindings.OfferWithDerivedMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(absolute_expiry);
103                 if (this != null) { this.ptrs_to.AddLast(this); };
104         }
105
106         /**
107          * Sets the [`Offer::description`].
108          * 
109          * Successive calls to this method will override the previous setting.
110          */
111         public void description(string description) {
112                 bindings.OfferWithDerivedMetadataBuilder_description(this.ptr, InternalUtils.encodeString(description));
113                 GC.KeepAlive(this);
114                 GC.KeepAlive(description);
115                 if (this != null) { this.ptrs_to.AddLast(this); };
116         }
117
118         /**
119          * Sets the [`Offer::issuer`].
120          * 
121          * Successive calls to this method will override the previous setting.
122          */
123         public void issuer(string issuer) {
124                 bindings.OfferWithDerivedMetadataBuilder_issuer(this.ptr, InternalUtils.encodeString(issuer));
125                 GC.KeepAlive(this);
126                 GC.KeepAlive(issuer);
127                 if (this != null) { this.ptrs_to.AddLast(this); };
128         }
129
130         /**
131          * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by
132          * private channels or if [`Offer::signing_pubkey`] is not a public node id.
133          * 
134          * Successive calls to this method will add another blinded path. Caller is responsible for not
135          * adding duplicate paths.
136          */
137         public void path(org.ldk.structs.BlindedPath path) {
138                 bindings.OfferWithDerivedMetadataBuilder_path(this.ptr, path.ptr);
139                 GC.KeepAlive(this);
140                 GC.KeepAlive(path);
141                 if (this != null) { this.ptrs_to.AddLast(path); };
142                 if (this != null) { this.ptrs_to.AddLast(this); };
143         }
144
145         /**
146          * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
147          * [`Quantity::One`].
148          * 
149          * Successive calls to this method will override the previous setting.
150          */
151         public void supported_quantity(org.ldk.structs.Quantity quantity) {
152                 bindings.OfferWithDerivedMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
153                 GC.KeepAlive(this);
154                 GC.KeepAlive(quantity);
155                 if (this != null) { this.ptrs_to.AddLast(quantity); };
156                 if (this != null) { this.ptrs_to.AddLast(this); };
157         }
158
159         /**
160          * Builds an [`Offer`] from the builder's settings.
161          */
162         public Result_OfferBolt12SemanticErrorZ build() {
163                 long ret = bindings.OfferWithDerivedMetadataBuilder_build(this.ptr);
164                 GC.KeepAlive(this);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 Result_OfferBolt12SemanticErrorZ ret_hu_conv = Result_OfferBolt12SemanticErrorZ.constr_from_ptr(ret);
167                 if (this != null) { this.ptrs_to.AddLast(this); };
168                 return ret_hu_conv;
169         }
170
171 }
172 } } }