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 InvoiceWithDerivedSigningPubkeyBuilder : CommonBase {
21 internal InvoiceWithDerivedSigningPubkeyBuilder(object _dummy, long ptr) : base(ptr) { }
22 ~InvoiceWithDerivedSigningPubkeyBuilder() {
23 if (ptr != 0) { bindings.InvoiceWithDerivedSigningPubkeyBuilder_free(ptr); }
27 * Builds a signed [`Bolt12Invoice`] after checking for valid semantics.
29 public Result_Bolt12InvoiceBolt12SemanticErrorZ build_and_sign() {
30 long ret = bindings.InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(this.ptr);
32 if (ret >= 0 && ret <= 4096) { return null; }
33 Result_Bolt12InvoiceBolt12SemanticErrorZ ret_hu_conv = Result_Bolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
34 if (this != null) { this.ptrs_to.AddLast(this); };
35 // Due to rust's strict-ownership memory model, in some cases we need to "move"
36 // an object to pass exclusive ownership to the function being called.
37 // In most cases, we avoid this being visible in GC'd languages by cloning the object
38 // at the FFI layer, creating a new object which Rust can claim ownership of
39 // However, in some cases (eg here), there is no way to clone an object, and thus
40 // we actually have to pass full ownership to Rust.
41 // Thus, after this call, this is reset to null and is now a dummy object.
47 * Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
48 * Any expiry that has already passed is valid and can be checked for using
49 * [`Bolt12Invoice::is_expired`].
51 * Successive calls to this method will override the previous setting.
53 public void relative_expiry(int relative_expiry_secs) {
54 bindings.InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(this.ptr, relative_expiry_secs);
56 GC.KeepAlive(relative_expiry_secs);
57 if (this != null) { this.ptrs_to.AddLast(this); };
58 // Due to rust's strict-ownership memory model, in some cases we need to "move"
59 // an object to pass exclusive ownership to the function being called.
60 // In most cases, we avoid this being visible in GC'd languages by cloning the object
61 // at the FFI layer, creating a new object which Rust can claim ownership of
62 // However, in some cases (eg here), there is no way to clone an object, and thus
63 // we actually have to pass full ownership to Rust.
64 // Thus, after this call, this is reset to null and is now a dummy object.
69 * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
71 * Successive calls to this method will add another address. Caller is responsible for not
72 * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
74 public void fallback_v0_p2wsh(byte[] script_hash) {
75 bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(script_hash, 32)));
77 GC.KeepAlive(script_hash);
78 if (this != null) { this.ptrs_to.AddLast(this); };
79 // Due to rust's strict-ownership memory model, in some cases we need to "move"
80 // an object to pass exclusive ownership to the function being called.
81 // In most cases, we avoid this being visible in GC'd languages by cloning the object
82 // at the FFI layer, creating a new object which Rust can claim ownership of
83 // However, in some cases (eg here), there is no way to clone an object, and thus
84 // we actually have to pass full ownership to Rust.
85 // Thus, after this call, this is reset to null and is now a dummy object.
90 * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
92 * Successive calls to this method will add another address. Caller is responsible for not
93 * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
95 public void fallback_v0_p2wpkh(byte[] pubkey_hash) {
96 bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey_hash, 20)));
98 GC.KeepAlive(pubkey_hash);
99 if (this != null) { this.ptrs_to.AddLast(this); };
100 // Due to rust's strict-ownership memory model, in some cases we need to "move"
101 // an object to pass exclusive ownership to the function being called.
102 // In most cases, we avoid this being visible in GC'd languages by cloning the object
103 // at the FFI layer, creating a new object which Rust can claim ownership of
104 // However, in some cases (eg here), there is no way to clone an object, and thus
105 // we actually have to pass full ownership to Rust.
106 // Thus, after this call, this is reset to null and is now a dummy object.
111 * Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
113 * Successive calls to this method will add another address. Caller is responsible for not
114 * adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
116 public void fallback_v1_p2tr_tweaked(byte[] utput_key) {
117 bindings.InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(utput_key, 32)));
119 GC.KeepAlive(utput_key);
120 if (this != null) { this.ptrs_to.AddLast(this); };
121 // Due to rust's strict-ownership memory model, in some cases we need to "move"
122 // an object to pass exclusive ownership to the function being called.
123 // In most cases, we avoid this being visible in GC'd languages by cloning the object
124 // at the FFI layer, creating a new object which Rust can claim ownership of
125 // However, in some cases (eg here), there is no way to clone an object, and thus
126 // we actually have to pass full ownership to Rust.
127 // Thus, after this call, this is reset to null and is now a dummy object.
132 * Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
135 public void allow_mpp() {
136 bindings.InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(this.ptr);
138 if (this != null) { this.ptrs_to.AddLast(this); };
139 // Due to rust's strict-ownership memory model, in some cases we need to "move"
140 // an object to pass exclusive ownership to the function being called.
141 // In most cases, we avoid this being visible in GC'd languages by cloning the object
142 // at the FFI layer, creating a new object which Rust can claim ownership of
143 // However, in some cases (eg here), there is no way to clone an object, and thus
144 // we actually have to pass full ownership to Rust.
145 // Thus, after this call, this is reset to null and is now a dummy object.