6 namespace org { namespace ldk { namespace structs {
10 * Builds a [`Bolt12Invoice`] from either:
11 * - an [`InvoiceRequest`] for the \"offer to be paid\" flow or
12 * - a [`Refund`] for the \"offer for money\" flow.
14 * See [module-level documentation] for usage.
16 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
17 * [`Refund`]: crate::offers::refund::Refund
18 * [module-level documentation]: self
20 public class InvoiceWithExplicitSigningPubkeyBuilder : CommonBase {
21 internal InvoiceWithExplicitSigningPubkeyBuilder(object _dummy, long ptr) : base(ptr) { }
22 ~InvoiceWithExplicitSigningPubkeyBuilder() {
23 if (ptr != 0) { bindings.InvoiceWithExplicitSigningPubkeyBuilder_free(ptr); }
27 * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by
28 * [`UnsignedBolt12Invoice::sign`].
30 public Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ build() {
31 long ret = bindings.InvoiceWithExplicitSigningPubkeyBuilder_build(this.ptr);
33 if (ret >= 0 && ret <= 4096) { return null; }
34 Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ ret_hu_conv = Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
35 if (this != null) { this.ptrs_to.AddLast(this); };
36 // Due to rust's strict-ownership memory model, in some cases we need to "move"
37 // an object to pass exclusive ownership to the function being called.
38 // In most cases, we avoid this being visible in GC'd languages by cloning the object
39 // at the FFI layer, creating a new object which Rust can claim ownership of
40 // However, in some cases (eg here), there is no way to clone an object, and thus
41 // we actually have to pass full ownership to Rust.
42 // Thus, after this call, this is reset to null and is now a dummy object.
48 * Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
49 * Any expiry that has already passed is valid and can be checked for using
50 * [`Bolt12Invoice::is_expired`].
52 * Successive calls to this method will override the previous setting.
54 public void relative_expiry(int relative_expiry_secs) {
55 bindings.InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(this.ptr, relative_expiry_secs);
57 GC.KeepAlive(relative_expiry_secs);
58 if (this != null) { this.ptrs_to.AddLast(this); };
59 // Due to rust's strict-ownership memory model, in some cases we need to "move"
60 // an object to pass exclusive ownership to the function being called.
61 // In most cases, we avoid this being visible in GC'd languages by cloning the object
62 // at the FFI layer, creating a new object which Rust can claim ownership of
63 // However, in some cases (eg here), there is no way to clone an object, and thus
64 // we actually have to pass full ownership to Rust.
65 // Thus, after this call, this is reset to null and is now a dummy object.
70 * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
72 * Successive calls to this method will add another address. Caller is responsible for not
73 * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
75 public void fallback_v0_p2wsh(byte[] script_hash) {
76 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(script_hash, 32)));
78 GC.KeepAlive(script_hash);
79 if (this != null) { this.ptrs_to.AddLast(this); };
80 // Due to rust's strict-ownership memory model, in some cases we need to "move"
81 // an object to pass exclusive ownership to the function being called.
82 // In most cases, we avoid this being visible in GC'd languages by cloning the object
83 // at the FFI layer, creating a new object which Rust can claim ownership of
84 // However, in some cases (eg here), there is no way to clone an object, and thus
85 // we actually have to pass full ownership to Rust.
86 // Thus, after this call, this is reset to null and is now a dummy object.
91 * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
93 * Successive calls to this method will add another address. Caller is responsible for not
94 * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
96 public void fallback_v0_p2wpkh(byte[] pubkey_hash) {
97 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey_hash, 20)));
99 GC.KeepAlive(pubkey_hash);
100 if (this != null) { this.ptrs_to.AddLast(this); };
101 // Due to rust's strict-ownership memory model, in some cases we need to "move"
102 // an object to pass exclusive ownership to the function being called.
103 // In most cases, we avoid this being visible in GC'd languages by cloning the object
104 // at the FFI layer, creating a new object which Rust can claim ownership of
105 // However, in some cases (eg here), there is no way to clone an object, and thus
106 // we actually have to pass full ownership to Rust.
107 // Thus, after this call, this is reset to null and is now a dummy object.
112 * Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
114 * Successive calls to this method will add another address. Caller is responsible for not
115 * adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
117 public void fallback_v1_p2tr_tweaked(byte[] utput_key) {
118 bindings.InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(utput_key, 32)));
120 GC.KeepAlive(utput_key);
121 if (this != null) { this.ptrs_to.AddLast(this); };
122 // Due to rust's strict-ownership memory model, in some cases we need to "move"
123 // an object to pass exclusive ownership to the function being called.
124 // In most cases, we avoid this being visible in GC'd languages by cloning the object
125 // at the FFI layer, creating a new object which Rust can claim ownership of
126 // However, in some cases (eg here), there is no way to clone an object, and thus
127 // we actually have to pass full ownership to Rust.
128 // Thus, after this call, this is reset to null and is now a dummy object.
133 * Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
136 public void allow_mpp() {
137 bindings.InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(this.ptr);
139 if (this != null) { this.ptrs_to.AddLast(this); };
140 // Due to rust's strict-ownership memory model, in some cases we need to "move"
141 // an object to pass exclusive ownership to the function being called.
142 // In most cases, we avoid this being visible in GC'd languages by cloning the object
143 // at the FFI layer, creating a new object which Rust can claim ownership of
144 // However, in some cases (eg here), there is no way to clone an object, and thus
145 // we actually have to pass full ownership to Rust.
146 // Thus, after this call, this is reset to null and is now a dummy object.