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;
11 * A function for signing an [`UnsignedBolt12Invoice`].
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class SignBolt12InvoiceFn extends CommonBase {
15 final bindings.LDKSignBolt12InvoiceFn bindings_instance;
16 SignBolt12InvoiceFn(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
17 private SignBolt12InvoiceFn(bindings.LDKSignBolt12InvoiceFn arg) {
18 super(bindings.LDKSignBolt12InvoiceFn_new(arg));
19 this.ptrs_to.add(arg);
20 this.bindings_instance = arg;
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.SignBolt12InvoiceFn_free(ptr); } super.finalize();
27 * Destroys the object, freeing associated resources. After this call, any access
28 * to this object may result in a SEGFAULT or worse.
30 * You should generally NEVER call this method. You should let the garbage collector
31 * do this for you when it finalizes objects. However, it may be useful for types
32 * which represent locks and should be closed immediately to avoid holding locks
35 public void destroy() {
36 if (ptr != 0) { bindings.SignBolt12InvoiceFn_free(ptr); }
39 public static interface SignBolt12InvoiceFnInterface {
41 * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
43 Result_SchnorrSignatureNoneZ sign_invoice(UnsignedBolt12Invoice message);
45 private static class LDKSignBolt12InvoiceFnHolder { SignBolt12InvoiceFn held; }
46 public static SignBolt12InvoiceFn new_impl(SignBolt12InvoiceFnInterface arg) {
47 final LDKSignBolt12InvoiceFnHolder impl_holder = new LDKSignBolt12InvoiceFnHolder();
48 impl_holder.held = new SignBolt12InvoiceFn(new bindings.LDKSignBolt12InvoiceFn() {
49 @Override public long sign_invoice(long message) {
50 org.ldk.structs.UnsignedBolt12Invoice message_hu_conv = null; if (message < 0 || message > 4096) { message_hu_conv = new org.ldk.structs.UnsignedBolt12Invoice(null, message); }
51 Result_SchnorrSignatureNoneZ ret = arg.sign_invoice(message_hu_conv);
52 Reference.reachabilityFence(arg);
53 long result = ret.clone_ptr();
57 return impl_holder.held;
60 * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
62 public Result_SchnorrSignatureNoneZ sign_invoice(org.ldk.structs.UnsignedBolt12Invoice message) {
63 long ret = bindings.SignBolt12InvoiceFn_sign_invoice(this.ptr, message.ptr);
64 Reference.reachabilityFence(this);
65 Reference.reachabilityFence(message);
66 if (ret >= 0 && ret <= 4096) { return null; }
67 Result_SchnorrSignatureNoneZ ret_hu_conv = Result_SchnorrSignatureNoneZ.constr_from_ptr(ret);
68 if (this != null) { this.ptrs_to.add(message); };