[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / java / org / ldk / structs / Sign.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * A cloneable signer.
12  * 
13  * Although we require signers to be cloneable, it may be useful for developers to be able to use
14  * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait,
15  * which implies Sized, into this derived trait.
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class Sign extends CommonBase {
19         final bindings.LDKSign bindings_instance;
20         Sign(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
21         private Sign(bindings.LDKSign arg, bindings.LDKBaseSign BaseSign, ChannelPublicKeys pubkeys) {
22                 super(bindings.LDKSign_new(arg, BaseSign, pubkeys == null ? 0 : pubkeys.clone_ptr()));
23                 this.ptrs_to.add(arg);
24                 this.ptrs_to.add(BaseSign);
25                 this.bindings_instance = arg;
26         }
27         @Override @SuppressWarnings("deprecation")
28         protected void finalize() throws Throwable {
29                 if (ptr != 0) { bindings.Sign_free(ptr); } super.finalize();
30         }
31
32         public static interface SignInterface {
33                 /**
34                  * Serialize the object into a byte array
35                  */
36                 byte[] write();
37         }
38         private static class LDKSignHolder { Sign held; }
39         public static Sign new_impl(SignInterface arg, BaseSign.BaseSignInterface BaseSign_impl, ChannelPublicKeys pubkeys) {
40                 final LDKSignHolder impl_holder = new LDKSignHolder();
41                 impl_holder.held = new Sign(new bindings.LDKSign() {
42                         @Override public byte[] write() {
43                                 byte[] ret = arg.write();
44                                 Reference.reachabilityFence(arg);
45                                 return ret;
46                         }
47                 }, BaseSign.new_impl(BaseSign_impl, pubkeys).bindings_instance, pubkeys);
48                 return impl_holder.held;
49         }
50
51         /**
52          * Gets the underlying BaseSign.
53          */
54         public BaseSign get_base_sign() {
55                 BaseSign res = new BaseSign(null, bindings.LDKSign_get_BaseSign(this.ptr));
56                 this.ptrs_to.add(res);
57                 return res;
58         }
59
60         /**
61          * Serialize the object into a byte array
62          */
63         public byte[] write() {
64                 byte[] ret = bindings.Sign_write(this.ptr);
65                 Reference.reachabilityFence(this);
66                 return ret;
67         }
68
69         long clone_ptr() {
70                 long ret = bindings.Sign_clone_ptr(this.ptr);
71                 Reference.reachabilityFence(this);
72                 return ret;
73         }
74
75         /**
76          * Creates a copy of a Sign
77          */
78         public Sign clone() {
79                 long ret = bindings.Sign_clone(this.ptr);
80                 Reference.reachabilityFence(this);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 Sign ret_hu_conv = new Sign(null, ret);
83                 ret_hu_conv.ptrs_to.add(this);
84                 return ret_hu_conv;
85         }
86
87 }