6 namespace org { namespace ldk { namespace structs {
10 * Builds a [`Refund`] for the \"offer for money\" flow.
12 * See [module-level documentation] for usage.
14 * [module-level documentation]: self
16 public class RefundMaybeWithDerivedMetadataBuilder : CommonBase {
17 internal RefundMaybeWithDerivedMetadataBuilder(object _dummy, long ptr) : base(ptr) { }
18 ~RefundMaybeWithDerivedMetadataBuilder() {
19 if (ptr != 0) { bindings.RefundMaybeWithDerivedMetadataBuilder_free(ptr); }
22 internal long clone_ptr() {
23 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_clone_ptr(this.ptr);
29 * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder
31 public RefundMaybeWithDerivedMetadataBuilder clone() {
32 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_clone(this.ptr);
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); };
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.
44 * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`],
45 * and [`Refund::amount_msats`].
49 * If constructing a [`Refund`] for use with a [`ChannelManager`], use
50 * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`].
52 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
53 * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder
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);
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.
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`].
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.
77 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
78 * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
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); };
95 * Sets the [`Refund::description`].
97 * Successive calls to this method will override the previous setting.
99 public void description(string description) {
100 bindings.RefundMaybeWithDerivedMetadataBuilder_description(this.ptr, InternalUtils.encodeString(description));
102 GC.KeepAlive(description);
103 if (this != null) { this.ptrs_to.AddLast(this); };
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`].
110 * Successive calls to this method will override the previous setting.
112 public void absolute_expiry(long absolute_expiry) {
113 bindings.RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
115 GC.KeepAlive(absolute_expiry);
116 if (this != null) { this.ptrs_to.AddLast(this); };
120 * Sets the [`Refund::issuer`].
122 * Successive calls to this method will override the previous setting.
124 public void issuer(string issuer) {
125 bindings.RefundMaybeWithDerivedMetadataBuilder_issuer(this.ptr, InternalUtils.encodeString(issuer));
127 GC.KeepAlive(issuer);
128 if (this != null) { this.ptrs_to.AddLast(this); };
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.
135 * Successive calls to this method will add another blinded path. Caller is responsible for not
136 * adding duplicate paths.
138 public void path(org.ldk.structs.BlindedPath path) {
139 bindings.RefundMaybeWithDerivedMetadataBuilder_path(this.ptr, path.ptr);
142 if (this != null) { this.ptrs_to.AddLast(path); };
143 if (this != null) { this.ptrs_to.AddLast(this); };
147 * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not
148 * called, [`Network::Bitcoin`] is assumed.
150 * Successive calls to this method will override the previous setting.
152 public void chain(Network network) {
153 bindings.RefundMaybeWithDerivedMetadataBuilder_chain(this.ptr, network);
155 GC.KeepAlive(network);
156 if (this != null) { this.ptrs_to.AddLast(this); };
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`].
164 * Successive calls to this method will override the previous setting.
166 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
167 * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
168 * [`Offer`]: crate::offers::offer::Offer
170 public void quantity(long quantity) {
171 bindings.RefundMaybeWithDerivedMetadataBuilder_quantity(this.ptr, quantity);
173 GC.KeepAlive(quantity);
174 if (this != null) { this.ptrs_to.AddLast(this); };
178 * Sets the [`Refund::payer_note`].
180 * Successive calls to this method will override the previous setting.
182 public void payer_note(string payer_note) {
183 bindings.RefundMaybeWithDerivedMetadataBuilder_payer_note(this.ptr, InternalUtils.encodeString(payer_note));
185 GC.KeepAlive(payer_note);
186 if (this != null) { this.ptrs_to.AddLast(this); };
190 * Builds a [`Refund`] after checking for valid semantics.
192 public Result_RefundBolt12SemanticErrorZ build() {
193 long ret = bindings.RefundMaybeWithDerivedMetadataBuilder_build(this.ptr);
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); };