Update auto-generated bindings
[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
8 /**
9  * A cloneable signer.
10  * 
11  * Although we require signers to be cloneable, it may be useful for developers to be able to use
12  * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait,
13  * which implies Sized, into this derived trait.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class Sign extends CommonBase {
17         final bindings.LDKSign bindings_instance;
18         Sign(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
19         private Sign(bindings.LDKSign arg, bindings.LDKBaseSign BaseSign, ChannelPublicKeys pubkeys) {
20                 super(bindings.LDKSign_new(arg, BaseSign, pubkeys == null ? 0 : pubkeys.ptr & ~1));
21                 this.ptrs_to.add(arg);
22                 this.ptrs_to.add(BaseSign);
23                 this.ptrs_to.add(pubkeys);
24                 this.bindings_instance = arg;
25         }
26         @Override @SuppressWarnings("deprecation")
27         protected void finalize() throws Throwable {
28                 if (ptr != 0) { bindings.Sign_free(ptr); } super.finalize();
29         }
30
31         public static interface SignInterface {
32                 /**
33                  * Serialize the object into a byte array
34                  */
35                 byte[] write();
36         }
37         private static class LDKSignHolder { Sign held; }
38         public static Sign new_impl(SignInterface arg, BaseSign.BaseSignInterface BaseSign_impl, ChannelPublicKeys pubkeys) {
39                 final LDKSignHolder impl_holder = new LDKSignHolder();
40                 impl_holder.held = new Sign(new bindings.LDKSign() {
41                         @Override public byte[] write() {
42                                 byte[] ret = arg.write();
43                                 return ret;
44                         }
45                 }, BaseSign.new_impl(BaseSign_impl, pubkeys).bindings_instance, pubkeys);
46                 return impl_holder.held;
47         }
48         /**
49          * Serialize the object into a byte array
50          */
51         public byte[] write() {
52                 byte[] ret = bindings.Sign_write(this.ptr);
53                 return ret;
54         }
55
56         /**
57          * Creates a copy of a Sign
58          */
59         public Sign clone() {
60                 long ret = bindings.Sign_clone(this.ptr);
61                 Sign ret_hu_conv = new Sign(null, ret);
62                 ret_hu_conv.ptrs_to.add(this);
63                 return ret_hu_conv;
64         }
65
66 }