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;
13 * There will always be two instances of a signer per channel, one occupied by the
14 * [`ChannelManager`] and another by the channel's [`ChannelMonitor`].
16 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
17 * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class Sign extends CommonBase {
21 final bindings.LDKSign bindings_instance;
22 Sign(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
23 private Sign(bindings.LDKSign arg, bindings.LDKBaseSign BaseSign, ChannelPublicKeys pubkeys) {
24 super(bindings.LDKSign_new(arg, BaseSign, pubkeys == null ? 0 : pubkeys.clone_ptr()));
25 this.ptrs_to.add(arg);
26 this.ptrs_to.add(BaseSign);
27 this.bindings_instance = arg;
29 @Override @SuppressWarnings("deprecation")
30 protected void finalize() throws Throwable {
31 if (ptr != 0) { bindings.Sign_free(ptr); } super.finalize();
34 public static interface SignInterface {
36 * Serialize the object into a byte array
40 private static class LDKSignHolder { Sign held; }
41 public static Sign new_impl(SignInterface arg, BaseSign.BaseSignInterface BaseSign_impl, ChannelPublicKeys pubkeys) {
42 final LDKSignHolder impl_holder = new LDKSignHolder();
43 impl_holder.held = new Sign(new bindings.LDKSign() {
44 @Override public byte[] write() {
45 byte[] ret = arg.write();
46 Reference.reachabilityFence(arg);
49 }, BaseSign.new_impl(BaseSign_impl, pubkeys).bindings_instance, pubkeys);
50 return impl_holder.held;
54 * Gets the underlying BaseSign.
56 public BaseSign get_base_sign() {
57 BaseSign res = new BaseSign(null, bindings.LDKSign_get_BaseSign(this.ptr));
58 this.ptrs_to.add(res);
63 * Serialize the object into a byte array
65 public byte[] write() {
66 byte[] ret = bindings.Sign_write(this.ptr);
67 Reference.reachabilityFence(this);
72 long ret = bindings.Sign_clone_ptr(this.ptr);
73 Reference.reachabilityFence(this);
78 * Creates a copy of a Sign
81 long ret = bindings.Sign_clone(this.ptr);
82 Reference.reachabilityFence(this);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 Sign ret_hu_conv = new Sign(null, ret);
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };