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 InvoiceWithExplicitSigningPubkeyBuilder extends CommonBase {
24 InvoiceWithExplicitSigningPubkeyBuilder(Object _dummy, long ptr) { super(ptr); }
25 @Override @SuppressWarnings("deprecation")
26 protected void finalize() throws Throwable {
28 if (ptr != 0) { bindings.InvoiceWithExplicitSigningPubkeyBuilder_free(ptr); }
32 * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by
33 * [`UnsignedBolt12Invoice::sign`].
35 public Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ build() {
36 long ret = bindings.InvoiceWithExplicitSigningPubkeyBuilder_build(this.ptr);
37 Reference.reachabilityFence(this);
38 if (ret >= 0 && ret <= 4096) { return null; }
39 Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ ret_hu_conv = Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
40 if (this != null) { this.ptrs_to.add(this); };
41 // Due to rust's strict-ownership memory model, in some cases we need to "move"
42 // an object to pass exclusive ownership to the function being called.
43 // In most cases, we avoid this being visible in GC'd languages by cloning the object
44 // at the FFI layer, creating a new object which Rust can claim ownership of
45 // However, in some cases (eg here), there is no way to clone an object, and thus
46 // we actually have to pass full ownership to Rust.
47 // Thus, after this call, this is reset to null and is now a dummy object.
53 * Sets the [`Bolt12Invoice::relative_expiry`]
54 * as seconds since [`Bolt12Invoice::created_at`].
55 * Any expiry that has already passed is valid and can be checked for using
56 * [`Bolt12Invoice::is_expired`].
58 * Successive calls to this method will override the previous setting.
60 public void relative_expiry(int relative_expiry_secs) {
61 bindings.InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(this.ptr, relative_expiry_secs);
62 Reference.reachabilityFence(this);
63 Reference.reachabilityFence(relative_expiry_secs);
64 if (this != null) { this.ptrs_to.add(this); };
65 // Due to rust's strict-ownership memory model, in some cases we need to "move"
66 // an object to pass exclusive ownership to the function being called.
67 // In most cases, we avoid this being visible in GC'd languages by cloning the object
68 // at the FFI layer, creating a new object which Rust can claim ownership of
69 // However, in some cases (eg here), there is no way to clone an object, and thus
70 // we actually have to pass full ownership to Rust.
71 // Thus, after this call, this is reset to null and is now a dummy object.
76 * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
78 * Successive calls to this method will add another address. Caller is responsible for not
79 * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
81 public void fallback_v0_p2wsh(byte[] script_hash) {
82 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(this.ptr, InternalUtils.check_arr_len(script_hash, 32));
83 Reference.reachabilityFence(this);
84 Reference.reachabilityFence(script_hash);
85 if (this != null) { this.ptrs_to.add(this); };
86 // Due to rust's strict-ownership memory model, in some cases we need to "move"
87 // an object to pass exclusive ownership to the function being called.
88 // In most cases, we avoid this being visible in GC'd languages by cloning the object
89 // at the FFI layer, creating a new object which Rust can claim ownership of
90 // However, in some cases (eg here), there is no way to clone an object, and thus
91 // we actually have to pass full ownership to Rust.
92 // Thus, after this call, this is reset to null and is now a dummy object.
97 * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
99 * Successive calls to this method will add another address. Caller is responsible for not
100 * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
102 public void fallback_v0_p2wpkh(byte[] pubkey_hash) {
103 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(this.ptr, InternalUtils.check_arr_len(pubkey_hash, 20));
104 Reference.reachabilityFence(this);
105 Reference.reachabilityFence(pubkey_hash);
106 if (this != null) { this.ptrs_to.add(this); };
107 // Due to rust's strict-ownership memory model, in some cases we need to "move"
108 // an object to pass exclusive ownership to the function being called.
109 // In most cases, we avoid this being visible in GC'd languages by cloning the object
110 // at the FFI layer, creating a new object which Rust can claim ownership of
111 // However, in some cases (eg here), there is no way to clone an object, and thus
112 // we actually have to pass full ownership to Rust.
113 // Thus, after this call, this is reset to null and is now a dummy object.
118 * Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
120 * Successive calls to this method will add another address. Caller is responsible for not
121 * adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
123 public void fallback_v1_p2tr_tweaked(byte[] utput_key) {
124 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(this.ptr, InternalUtils.check_arr_len(utput_key, 32));
125 Reference.reachabilityFence(this);
126 Reference.reachabilityFence(utput_key);
127 if (this != null) { this.ptrs_to.add(this); };
128 // Due to rust's strict-ownership memory model, in some cases we need to "move"
129 // an object to pass exclusive ownership to the function being called.
130 // In most cases, we avoid this being visible in GC'd languages by cloning the object
131 // at the FFI layer, creating a new object which Rust can claim ownership of
132 // However, in some cases (eg here), there is no way to clone an object, and thus
133 // we actually have to pass full ownership to Rust.
134 // Thus, after this call, this is reset to null and is now a dummy object.
139 * Sets [`Bolt12Invoice::invoice_features`]
140 * to indicate MPP may be used. Otherwise, MPP is disallowed.
142 public void allow_mpp() {
143 bindings.InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(this.ptr);
144 Reference.reachabilityFence(this);
145 if (this != null) { this.ptrs_to.add(this); };
146 // Due to rust's strict-ownership memory model, in some cases we need to "move"
147 // an object to pass exclusive ownership to the function being called.
148 // In most cases, we avoid this being visible in GC'd languages by cloning the object
149 // at the FFI layer, creating a new object which Rust can claim ownership of
150 // However, in some cases (eg here), there is no way to clone an object, and thus
151 // we actually have to pass full ownership to Rust.
152 // Thus, after this call, this is reset to null and is now a dummy object.