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 a [`Bolt12Invoice`] from either:
13 * - an [`InvoiceRequest`] for the \"offer to be paid\" flow or
14 * - a [`Refund`] for the \"offer for money\" flow.
16 * See [module-level documentation] for usage.
18 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
19 * [`Refund`]: crate::offers::refund::Refund
20 * [module-level documentation]: self
22 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
23 public class InvoiceWithDerivedSigningPubkeyBuilder extends CommonBase {
24 InvoiceWithDerivedSigningPubkeyBuilder(Object _dummy, long ptr) { super(ptr); }
25 @Override @SuppressWarnings("deprecation")
26 protected void finalize() throws Throwable {
28 if (ptr != 0) { bindings.InvoiceWithDerivedSigningPubkeyBuilder_free(ptr); }
32 * Builds a signed [`Bolt12Invoice`] after checking for valid semantics.
34 public Result_Bolt12InvoiceBolt12SemanticErrorZ build_and_sign() {
35 long ret = bindings.InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(this.ptr);
36 Reference.reachabilityFence(this);
37 if (ret >= 0 && ret <= 4096) { return null; }
38 Result_Bolt12InvoiceBolt12SemanticErrorZ ret_hu_conv = Result_Bolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
39 if (this != null) { this.ptrs_to.add(this); };
40 // Due to rust's strict-ownership memory model, in some cases we need to "move"
41 // an object to pass exclusive ownership to the function being called.
42 // In most cases, we avoid this being visible in GC'd languages by cloning the object
43 // at the FFI layer, creating a new object which Rust can claim ownership of
44 // However, in some cases (eg here), there is no way to clone an object, and thus
45 // we actually have to pass full ownership to Rust.
46 // Thus, after this call, this is reset to null and is now a dummy object.
52 * Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
53 * Any expiry that has already passed is valid and can be checked for using
54 * [`Bolt12Invoice::is_expired`].
56 * Successive calls to this method will override the previous setting.
58 public void relative_expiry(int relative_expiry_secs) {
59 bindings.InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(this.ptr, relative_expiry_secs);
60 Reference.reachabilityFence(this);
61 Reference.reachabilityFence(relative_expiry_secs);
62 if (this != null) { this.ptrs_to.add(this); };
63 // Due to rust's strict-ownership memory model, in some cases we need to "move"
64 // an object to pass exclusive ownership to the function being called.
65 // In most cases, we avoid this being visible in GC'd languages by cloning the object
66 // at the FFI layer, creating a new object which Rust can claim ownership of
67 // However, in some cases (eg here), there is no way to clone an object, and thus
68 // we actually have to pass full ownership to Rust.
69 // Thus, after this call, this is reset to null and is now a dummy object.
74 * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
76 * Successive calls to this method will add another address. Caller is responsible for not
77 * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
79 public void fallback_v0_p2wsh(byte[] script_hash) {
80 bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(this.ptr, InternalUtils.check_arr_len(script_hash, 32));
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(script_hash);
83 if (this != null) { this.ptrs_to.add(this); };
84 // Due to rust's strict-ownership memory model, in some cases we need to "move"
85 // an object to pass exclusive ownership to the function being called.
86 // In most cases, we avoid this being visible in GC'd languages by cloning the object
87 // at the FFI layer, creating a new object which Rust can claim ownership of
88 // However, in some cases (eg here), there is no way to clone an object, and thus
89 // we actually have to pass full ownership to Rust.
90 // Thus, after this call, this is reset to null and is now a dummy object.
95 * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
97 * Successive calls to this method will add another address. Caller is responsible for not
98 * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
100 public void fallback_v0_p2wpkh(byte[] pubkey_hash) {
101 bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(this.ptr, InternalUtils.check_arr_len(pubkey_hash, 20));
102 Reference.reachabilityFence(this);
103 Reference.reachabilityFence(pubkey_hash);
104 if (this != null) { this.ptrs_to.add(this); };
105 // Due to rust's strict-ownership memory model, in some cases we need to "move"
106 // an object to pass exclusive ownership to the function being called.
107 // In most cases, we avoid this being visible in GC'd languages by cloning the object
108 // at the FFI layer, creating a new object which Rust can claim ownership of
109 // However, in some cases (eg here), there is no way to clone an object, and thus
110 // we actually have to pass full ownership to Rust.
111 // Thus, after this call, this is reset to null and is now a dummy object.
116 * Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
118 * Successive calls to this method will add another address. Caller is responsible for not
119 * adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
121 public void fallback_v1_p2tr_tweaked(byte[] utput_key) {
122 bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(this.ptr, InternalUtils.check_arr_len(utput_key, 32));
123 Reference.reachabilityFence(this);
124 Reference.reachabilityFence(utput_key);
125 if (this != null) { this.ptrs_to.add(this); };
126 // Due to rust's strict-ownership memory model, in some cases we need to "move"
127 // an object to pass exclusive ownership to the function being called.
128 // In most cases, we avoid this being visible in GC'd languages by cloning the object
129 // at the FFI layer, creating a new object which Rust can claim ownership of
130 // However, in some cases (eg here), there is no way to clone an object, and thus
131 // we actually have to pass full ownership to Rust.
132 // Thus, after this call, this is reset to null and is now a dummy object.
137 * Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
140 public void allow_mpp() {
141 bindings.InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(this.ptr);
142 Reference.reachabilityFence(this);
143 if (this != null) { this.ptrs_to.add(this); };
144 // Due to rust's strict-ownership memory model, in some cases we need to "move"
145 // an object to pass exclusive ownership to the function being called.
146 // In most cases, we avoid this being visible in GC'd languages by cloning the object
147 // at the FFI layer, creating a new object which Rust can claim ownership of
148 // However, in some cases (eg here), there is no way to clone an object, and thus
149 // we actually have to pass full ownership to Rust.
150 // Thus, after this call, this is reset to null and is now a dummy object.