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`] as seconds since [`Bolt12Invoice::created_at`].
54 * Any expiry that has already passed is valid and can be checked for using
55 * [`Bolt12Invoice::is_expired`].
57 * Successive calls to this method will override the previous setting.
59 public void relative_expiry(int relative_expiry_secs) {
60 bindings.InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(this.ptr, relative_expiry_secs);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(relative_expiry_secs);
63 if (this != null) { this.ptrs_to.add(this); };
64 // Due to rust's strict-ownership memory model, in some cases we need to "move"
65 // an object to pass exclusive ownership to the function being called.
66 // In most cases, we avoid this being visible in GC'd languages by cloning the object
67 // at the FFI layer, creating a new object which Rust can claim ownership of
68 // However, in some cases (eg here), there is no way to clone an object, and thus
69 // we actually have to pass full ownership to Rust.
70 // Thus, after this call, this is reset to null and is now a dummy object.
75 * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
77 * Successive calls to this method will add another address. Caller is responsible for not
78 * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
80 public void fallback_v0_p2wsh(byte[] script_hash) {
81 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(this.ptr, InternalUtils.check_arr_len(script_hash, 32));
82 Reference.reachabilityFence(this);
83 Reference.reachabilityFence(script_hash);
84 if (this != null) { this.ptrs_to.add(this); };
85 // Due to rust's strict-ownership memory model, in some cases we need to "move"
86 // an object to pass exclusive ownership to the function being called.
87 // In most cases, we avoid this being visible in GC'd languages by cloning the object
88 // at the FFI layer, creating a new object which Rust can claim ownership of
89 // However, in some cases (eg here), there is no way to clone an object, and thus
90 // we actually have to pass full ownership to Rust.
91 // Thus, after this call, this is reset to null and is now a dummy object.
96 * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
98 * Successive calls to this method will add another address. Caller is responsible for not
99 * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
101 public void fallback_v0_p2wpkh(byte[] pubkey_hash) {
102 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(this.ptr, InternalUtils.check_arr_len(pubkey_hash, 20));
103 Reference.reachabilityFence(this);
104 Reference.reachabilityFence(pubkey_hash);
105 if (this != null) { this.ptrs_to.add(this); };
106 // Due to rust's strict-ownership memory model, in some cases we need to "move"
107 // an object to pass exclusive ownership to the function being called.
108 // In most cases, we avoid this being visible in GC'd languages by cloning the object
109 // at the FFI layer, creating a new object which Rust can claim ownership of
110 // However, in some cases (eg here), there is no way to clone an object, and thus
111 // we actually have to pass full ownership to Rust.
112 // Thus, after this call, this is reset to null and is now a dummy object.
117 * Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
119 * Successive calls to this method will add another address. Caller is responsible for not
120 * adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
122 public void fallback_v1_p2tr_tweaked(byte[] utput_key) {
123 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(this.ptr, InternalUtils.check_arr_len(utput_key, 32));
124 Reference.reachabilityFence(this);
125 Reference.reachabilityFence(utput_key);
126 if (this != null) { this.ptrs_to.add(this); };
127 // Due to rust's strict-ownership memory model, in some cases we need to "move"
128 // an object to pass exclusive ownership to the function being called.
129 // In most cases, we avoid this being visible in GC'd languages by cloning the object
130 // at the FFI layer, creating a new object which Rust can claim ownership of
131 // However, in some cases (eg here), there is no way to clone an object, and thus
132 // we actually have to pass full ownership to Rust.
133 // Thus, after this call, this is reset to null and is now a dummy object.
138 * Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
141 public void allow_mpp() {
142 bindings.InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(this.ptr);
143 Reference.reachabilityFence(this);
144 if (this != null) { this.ptrs_to.add(this); };
145 // Due to rust's strict-ownership memory model, in some cases we need to "move"
146 // an object to pass exclusive ownership to the function being called.
147 // In most cases, we avoid this being visible in GC'd languages by cloning the object
148 // at the FFI layer, creating a new object which Rust can claim ownership of
149 // However, in some cases (eg here), there is no way to clone an object, and thus
150 // we actually have to pass full ownership to Rust.
151 // Thus, after this call, this is reset to null and is now a dummy object.