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 WriteableEcdsaChannelSigner extends CommonBase {
21 final bindings.LDKWriteableEcdsaChannelSigner bindings_instance;
22 WriteableEcdsaChannelSigner(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
23 private WriteableEcdsaChannelSigner(bindings.LDKWriteableEcdsaChannelSigner arg, bindings.LDKEcdsaChannelSigner EcdsaChannelSigner, bindings.LDKChannelSigner ChannelSigner, ChannelPublicKeys pubkeys) {
24 super(bindings.LDKWriteableEcdsaChannelSigner_new(arg, EcdsaChannelSigner, ChannelSigner, pubkeys == null ? 0 : pubkeys.clone_ptr()));
25 this.ptrs_to.add(arg);
26 this.ptrs_to.add(EcdsaChannelSigner);
27 this.ptrs_to.add(ChannelSigner);
28 this.bindings_instance = arg;
30 @Override @SuppressWarnings("deprecation")
31 protected void finalize() throws Throwable {
32 if (ptr != 0) { bindings.WriteableEcdsaChannelSigner_free(ptr); } super.finalize();
35 * Destroys the object, freeing associated resources. After this call, any access
36 * to this object may result in a SEGFAULT or worse.
38 * You should generally NEVER call this method. You should let the garbage collector
39 * do this for you when it finalizes objects. However, it may be useful for types
40 * which represent locks and should be closed immediately to avoid holding locks
43 public void destroy() {
44 if (ptr != 0) { bindings.WriteableEcdsaChannelSigner_free(ptr); }
47 public static interface WriteableEcdsaChannelSignerInterface {
49 * Serialize the object into a byte array
53 private static class LDKWriteableEcdsaChannelSignerHolder { WriteableEcdsaChannelSigner held; }
54 public static WriteableEcdsaChannelSigner new_impl(WriteableEcdsaChannelSignerInterface arg, EcdsaChannelSigner.EcdsaChannelSignerInterface EcdsaChannelSigner_impl, ChannelSigner.ChannelSignerInterface ChannelSigner_impl, ChannelPublicKeys pubkeys) {
55 final LDKWriteableEcdsaChannelSignerHolder impl_holder = new LDKWriteableEcdsaChannelSignerHolder();
56 impl_holder.held = new WriteableEcdsaChannelSigner(new bindings.LDKWriteableEcdsaChannelSigner() {
57 @Override public byte[] write() {
58 byte[] ret = arg.write();
59 Reference.reachabilityFence(arg);
62 }, EcdsaChannelSigner.new_impl(EcdsaChannelSigner_impl, ChannelSigner_impl, pubkeys).bindings_instance, ChannelSigner.new_impl(ChannelSigner_impl, pubkeys).bindings_instance, pubkeys);
63 return impl_holder.held;
67 * Gets the underlying EcdsaChannelSigner.
69 public EcdsaChannelSigner get_ecdsa_channel_signer() {
70 EcdsaChannelSigner res = new EcdsaChannelSigner(null, bindings.LDKWriteableEcdsaChannelSigner_get_EcdsaChannelSigner(this.ptr));
71 res.ptrs_to.add(this);
77 * Gets the underlying ChannelSigner.
79 public ChannelSigner get_channel_signer() {
80 ChannelSigner res = new ChannelSigner(null, bindings.LDKWriteableEcdsaChannelSigner_get_ChannelSigner(this.ptr));
81 res.ptrs_to.add(this);
86 * Serialize the object into a byte array
88 public byte[] write() {
89 byte[] ret = bindings.WriteableEcdsaChannelSigner_write(this.ptr);
90 Reference.reachabilityFence(this);
95 long ret = bindings.WriteableEcdsaChannelSigner_clone_ptr(this.ptr);
96 Reference.reachabilityFence(this);
101 * Creates a copy of a WriteableEcdsaChannelSigner
103 public WriteableEcdsaChannelSigner clone() {
104 long ret = bindings.WriteableEcdsaChannelSigner_clone(this.ptr);
105 Reference.reachabilityFence(this);
106 if (ret >= 0 && ret <= 4096) { return null; }
107 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
108 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };