1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
12 * Although we require signers to be cloneable, it may be useful for developers to be able to use
13 * signers in an un-sized way, for example as `dyn BaseSign`. Therefore we separate the Clone trait,
14 * which implies Sized, into this derived trait.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Sign extends CommonBase {
18 final bindings.LDKSign bindings_instance;
19 Sign(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
20 private Sign(bindings.LDKSign arg, bindings.LDKBaseSign BaseSign, ChannelPublicKeys pubkeys) {
21 super(bindings.LDKSign_new(arg, BaseSign, pubkeys == null ? 0 : pubkeys.ptr & ~1));
22 this.ptrs_to.add(arg);
23 this.ptrs_to.add(BaseSign);
24 this.bindings_instance = arg;
26 @Override @SuppressWarnings("deprecation")
27 protected void finalize() throws Throwable {
28 if (ptr != 0) { bindings.Sign_free(ptr); } super.finalize();
31 public static interface SignInterface {
33 * Serialize the object into a byte array
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();
45 }, BaseSign.new_impl(BaseSign_impl, pubkeys).bindings_instance, pubkeys);
46 return impl_holder.held;
50 * Gets the underlying BaseSign.
52 public BaseSign get_base_sign() {
53 BaseSign res = new BaseSign(null, bindings.LDKSign_get_BaseSign(this.ptr));
54 this.ptrs_to.add(res);
59 * Serialize the object into a byte array
61 public byte[] write() {
62 byte[] ret = bindings.Sign_write(this.ptr);
67 * Creates a copy of a Sign
70 long ret = bindings.Sign_clone(this.ptr);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 Sign ret_hu_conv = new Sign(null, ret);
73 ret_hu_conv.ptrs_to.add(this);