1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow.
14 * See [module-level documentation] for usage.
16 * [module-level documentation]: self
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class InvoiceRequestWithExplicitPayerIdBuilder extends CommonBase {
20 InvoiceRequestWithExplicitPayerIdBuilder(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.InvoiceRequestWithExplicitPayerIdBuilder_free(ptr); }
28 * Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed
29 * by [`UnsignedInvoiceRequest::sign`].
31 public Result_UnsignedInvoiceRequestBolt12SemanticErrorZ build() {
32 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_build(this.ptr);
33 Reference.reachabilityFence(this);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 Result_UnsignedInvoiceRequestBolt12SemanticErrorZ ret_hu_conv = Result_UnsignedInvoiceRequestBolt12SemanticErrorZ.constr_from_ptr(ret);
36 if (this != null) { this.ptrs_to.add(this); };
37 // Due to rust's strict-ownership memory model, in some cases we need to "move"
38 // an object to pass exclusive ownership to the function being called.
39 // In most cases, we avoid this being visible in GC'd languages by cloning the object
40 // at the FFI layer, creating a new object which Rust can claim ownership of
41 // However, in some cases (eg here), there is no way to clone an object, and thus
42 // we actually have to pass full ownership to Rust.
43 // Thus, after this call, this is reset to null and is now a dummy object.
49 * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not
50 * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported
53 * Successive calls to this method will override the previous setting.
55 public Result_NoneBolt12SemanticErrorZ chain(org.ldk.enums.Network network) {
56 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_chain(this.ptr, network);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(network);
59 if (ret >= 0 && ret <= 4096) { return null; }
60 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
61 if (this != null) { this.ptrs_to.add(this); };
62 // Due to rust's strict-ownership memory model, in some cases we need to "move"
63 // an object to pass exclusive ownership to the function being called.
64 // In most cases, we avoid this being visible in GC'd languages by cloning the object
65 // at the FFI layer, creating a new object which Rust can claim ownership of
66 // However, in some cases (eg here), there is no way to clone an object, and thus
67 // we actually have to pass full ownership to Rust.
68 // Thus, after this call, this is reset to null and is now a dummy object.
74 * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is
75 * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]).
77 * Successive calls to this method will override the previous setting.
79 * [`quantity`]: Self::quantity
81 public Result_NoneBolt12SemanticErrorZ amount_msats(long amount_msats) {
82 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(this.ptr, amount_msats);
83 Reference.reachabilityFence(this);
84 Reference.reachabilityFence(amount_msats);
85 if (ret >= 0 && ret <= 4096) { return null; }
86 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
87 if (this != null) { this.ptrs_to.add(this); };
88 // Due to rust's strict-ownership memory model, in some cases we need to "move"
89 // an object to pass exclusive ownership to the function being called.
90 // In most cases, we avoid this being visible in GC'd languages by cloning the object
91 // at the FFI layer, creating a new object which Rust can claim ownership of
92 // However, in some cases (eg here), there is no way to clone an object, and thus
93 // we actually have to pass full ownership to Rust.
94 // Thus, after this call, this is reset to null and is now a dummy object.
100 * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
101 * does not conform to [`Offer::is_valid_quantity`].
103 * Successive calls to this method will override the previous setting.
105 public Result_NoneBolt12SemanticErrorZ quantity(long quantity) {
106 long ret = bindings.InvoiceRequestWithExplicitPayerIdBuilder_quantity(this.ptr, quantity);
107 Reference.reachabilityFence(this);
108 Reference.reachabilityFence(quantity);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
111 if (this != null) { this.ptrs_to.add(this); };
112 // Due to rust's strict-ownership memory model, in some cases we need to "move"
113 // an object to pass exclusive ownership to the function being called.
114 // In most cases, we avoid this being visible in GC'd languages by cloning the object
115 // at the FFI layer, creating a new object which Rust can claim ownership of
116 // However, in some cases (eg here), there is no way to clone an object, and thus
117 // we actually have to pass full ownership to Rust.
118 // Thus, after this call, this is reset to null and is now a dummy object.
124 * Sets the [`InvoiceRequest::payer_note`].
126 * Successive calls to this method will override the previous setting.
128 public void payer_note(java.lang.String payer_note) {
129 bindings.InvoiceRequestWithExplicitPayerIdBuilder_payer_note(this.ptr, payer_note);
130 Reference.reachabilityFence(this);
131 Reference.reachabilityFence(payer_note);
132 if (this != null) { this.ptrs_to.add(this); };
133 // Due to rust's strict-ownership memory model, in some cases we need to "move"
134 // an object to pass exclusive ownership to the function being called.
135 // In most cases, we avoid this being visible in GC'd languages by cloning the object
136 // at the FFI layer, creating a new object which Rust can claim ownership of
137 // However, in some cases (eg here), there is no way to clone an object, and thus
138 // we actually have to pass full ownership to Rust.
139 // Thus, after this call, this is reset to null and is now a dummy object.