6 namespace org { namespace ldk { namespace structs {
10 * Builds an [`Offer`] for the \"offer to be paid\" flow.
12 * See [module-level documentation] for usage.
14 * [module-level documentation]: self
16 public class OfferWithExplicitMetadataBuilder : CommonBase {
17 internal OfferWithExplicitMetadataBuilder(object _dummy, long ptr) : base(ptr) { }
18 ~OfferWithExplicitMetadataBuilder() {
19 if (ptr != 0) { bindings.OfferWithExplicitMetadataBuilder_free(ptr); }
22 internal long clone_ptr() {
23 long ret = bindings.OfferWithExplicitMetadataBuilder_clone_ptr(this.ptr);
29 * Creates a copy of the OfferWithExplicitMetadataBuilder
31 public OfferWithExplicitMetadataBuilder clone() {
32 long ret = bindings.OfferWithExplicitMetadataBuilder_clone(this.ptr);
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); };
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.
44 * Use a different pubkey per offer to avoid correlating offers.
48 * If constructing an [`Offer`] for use with a [`ChannelManager`], use
49 * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`].
51 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
52 * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder
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); };
64 * Sets the [`Offer::metadata`] to the given bytes.
66 * Successive calls to this method will override the previous setting.
68 public Result_NoneBolt12SemanticErrorZ metadata(byte[] metadata) {
69 long ret = bindings.OfferWithExplicitMetadataBuilder_metadata(this.ptr, InternalUtils.encodeUint8Array(metadata));
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); };
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.
82 * See [`Offer::chains`] on how this relates to the payment currency.
84 * Successive calls to this method will add another chain hash.
86 public void chain(Network network) {
87 bindings.OfferWithExplicitMetadataBuilder_chain(this.ptr, network);
89 GC.KeepAlive(network);
90 if (this != null) { this.ptrs_to.AddLast(this); };
94 * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
96 * Successive calls to this method will override the previous setting.
98 public void amount_msats(long amount_msats) {
99 bindings.OfferWithExplicitMetadataBuilder_amount_msats(this.ptr, amount_msats);
101 GC.KeepAlive(amount_msats);
102 if (this != null) { this.ptrs_to.AddLast(this); };
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`].
109 * Successive calls to this method will override the previous setting.
111 public void absolute_expiry(long absolute_expiry) {
112 bindings.OfferWithExplicitMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
114 GC.KeepAlive(absolute_expiry);
115 if (this != null) { this.ptrs_to.AddLast(this); };
119 * Sets the [`Offer::description`].
121 * Successive calls to this method will override the previous setting.
123 public void description(string description) {
124 bindings.OfferWithExplicitMetadataBuilder_description(this.ptr, InternalUtils.encodeString(description));
126 GC.KeepAlive(description);
127 if (this != null) { this.ptrs_to.AddLast(this); };
131 * Sets the [`Offer::issuer`].
133 * Successive calls to this method will override the previous setting.
135 public void issuer(string issuer) {
136 bindings.OfferWithExplicitMetadataBuilder_issuer(this.ptr, InternalUtils.encodeString(issuer));
138 GC.KeepAlive(issuer);
139 if (this != null) { this.ptrs_to.AddLast(this); };
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.
146 * Successive calls to this method will add another blinded path. Caller is responsible for not
147 * adding duplicate paths.
149 public void path(org.ldk.structs.BlindedPath path) {
150 bindings.OfferWithExplicitMetadataBuilder_path(this.ptr, path.ptr);
153 if (this != null) { this.ptrs_to.AddLast(path); };
154 if (this != null) { this.ptrs_to.AddLast(this); };
158 * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
161 * Successive calls to this method will override the previous setting.
163 public void supported_quantity(org.ldk.structs.Quantity quantity) {
164 bindings.OfferWithExplicitMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
166 GC.KeepAlive(quantity);
167 if (this != null) { this.ptrs_to.AddLast(quantity); };
168 if (this != null) { this.ptrs_to.AddLast(this); };
172 * Builds an [`Offer`] from the builder's settings.
174 public Result_OfferBolt12SemanticErrorZ build() {
175 long ret = bindings.OfferWithExplicitMetadataBuilder_build(this.ptr);
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); };