X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FWriteableEcdsaChannelSigner.cs;h=d7b0988e41ac76ba6939b08eee0980409eb2c8ed;hb=8de7213fbf663ff60322896282dad51e8ab2f001;hp=71f6f1255652ffb97e58458732e04dfcc21acee4;hpb=afc50e5d491a11364849383b75a8f939df703bac;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/WriteableEcdsaChannelSigner.cs b/c_sharp/src/org/ldk/structs/WriteableEcdsaChannelSigner.cs index 71f6f125..d7b0988e 100644 --- a/c_sharp/src/org/ldk/structs/WriteableEcdsaChannelSigner.cs +++ b/c_sharp/src/org/ldk/structs/WriteableEcdsaChannelSigner.cs @@ -1,3 +1,4 @@ + using org.ldk.impl; using org.ldk.enums; using org.ldk.util; @@ -5,6 +6,15 @@ using System; namespace org { namespace ldk { namespace structs { + + +/** An implementation of WriteableEcdsaChannelSigner */ +public interface WriteableEcdsaChannelSignerInterface { + /**Serialize the object into a byte array + */ + byte[] write(); +} + /** * A writeable signer. * @@ -15,67 +25,52 @@ namespace org { namespace ldk { namespace structs { * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ public class WriteableEcdsaChannelSigner : CommonBase { - internal readonly bindings.LDKWriteableEcdsaChannelSigner bindings_instance; + internal bindings.LDKWriteableEcdsaChannelSigner bindings_instance; + internal long instance_idx; + internal WriteableEcdsaChannelSigner(object _dummy, long ptr) : base(ptr) { bindings_instance = null; } - private WriteableEcdsaChannelSigner(bindings.LDKWriteableEcdsaChannelSigner arg, bindings.LDKEcdsaChannelSigner EcdsaChannelSigner, bindings.LDKChannelSigner ChannelSigner, ChannelPublicKeys pubkeys) : base(bindings.LDKWriteableEcdsaChannelSigner_new(arg, EcdsaChannelSigner, ChannelSigner, pubkeys == null ? 0 : pubkeys.clone_ptr())) { - this.ptrs_to.AddLast(arg); - this.ptrs_to.AddLast(EcdsaChannelSigner); - this.ptrs_to.AddLast(ChannelSigner); - this.bindings_instance = arg; - } ~WriteableEcdsaChannelSigner() { if (ptr != 0) { bindings.WriteableEcdsaChannelSigner_free(ptr); } } - public interface WriteableEcdsaChannelSignerInterface { - /** - * Serialize the object into a byte array - */ - byte[] write(); - } private class LDKWriteableEcdsaChannelSignerHolder { internal WriteableEcdsaChannelSigner held; } private class LDKWriteableEcdsaChannelSignerImpl : bindings.LDKWriteableEcdsaChannelSigner { internal LDKWriteableEcdsaChannelSignerImpl(WriteableEcdsaChannelSignerInterface arg, LDKWriteableEcdsaChannelSignerHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; } private WriteableEcdsaChannelSignerInterface arg; private LDKWriteableEcdsaChannelSignerHolder impl_holder; - public byte[] write() { + public long write() { byte[] ret = arg.write(); GC.KeepAlive(arg); - return ret; + long result = InternalUtils.encodeUint8Array(ret); + return result; } } - public static WriteableEcdsaChannelSigner new_impl(WriteableEcdsaChannelSignerInterface arg, EcdsaChannelSigner.EcdsaChannelSignerInterface EcdsaChannelSigner_impl, ChannelSigner.ChannelSignerInterface ChannelSigner_impl, ChannelPublicKeys pubkeys) { - LDKWriteableEcdsaChannelSignerHolder impl_holder = new LDKWriteableEcdsaChannelSignerHolder(); - impl_holder.held = new WriteableEcdsaChannelSigner(new LDKWriteableEcdsaChannelSignerImpl(arg, impl_holder), EcdsaChannelSigner.new_impl(EcdsaChannelSigner_impl, ChannelSigner_impl, pubkeys).bindings_instance, ChannelSigner.new_impl(ChannelSigner_impl, pubkeys).bindings_instance, pubkeys); - return impl_holder.held; - } - - /** - * Gets the underlying EcdsaChannelSigner. - */ - public EcdsaChannelSigner get_ecdsa_channel_signer() { - EcdsaChannelSigner res = new EcdsaChannelSigner(null, bindings.LDKWriteableEcdsaChannelSigner_get_EcdsaChannelSigner(this.ptr)); - this.ptrs_to.AddLast(res); - return res; - } + /** Creates a new instance of WriteableEcdsaChannelSigner from a given implementation */ + public static WriteableEcdsaChannelSigner new_impl(WriteableEcdsaChannelSignerInterface arg, EcdsaChannelSignerInterface ecdsaChannelSigner_impl, ChannelSignerInterface channelSigner_impl, ChannelPublicKeys pubkeys) { + LDKWriteableEcdsaChannelSignerHolder impl_holder = new LDKWriteableEcdsaChannelSignerHolder(); + LDKWriteableEcdsaChannelSignerImpl impl = new LDKWriteableEcdsaChannelSignerImpl(arg, impl_holder); + EcdsaChannelSigner ecdsaChannelSigner = EcdsaChannelSigner.new_impl(ecdsaChannelSigner_impl, channelSigner_impl, pubkeys); + ChannelSigner channelSigner = ChannelSigner.new_impl(channelSigner_impl, pubkeys); + long[] ptr_idx = bindings.LDKWriteableEcdsaChannelSigner_new(impl, ecdsaChannelSigner.instance_idx, channelSigner.instance_idx, pubkeys == null ? 0 : pubkeys.clone_ptr()); - /** - * Gets the underlying ChannelSigner. - */ - public ChannelSigner get_channel_signer() { - ChannelSigner res = new ChannelSigner(null, bindings.LDKWriteableEcdsaChannelSigner_get_ChannelSigner(this.ptr)); - this.ptrs_to.AddLast(res); - return res; + impl_holder.held = new WriteableEcdsaChannelSigner(null, ptr_idx[0]); + impl_holder.held.instance_idx = ptr_idx[1]; + impl_holder.held.bindings_instance = impl; + impl_holder.held.ptrs_to.AddLast(ecdsaChannelSigner); + impl_holder.held.ptrs_to.AddLast(channelSigner); + return impl_holder.held; } /** * Serialize the object into a byte array */ public byte[] write() { - byte[] ret = bindings.WriteableEcdsaChannelSigner_write(this.ptr); + long ret = bindings.WriteableEcdsaChannelSigner_write(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } internal long clone_ptr() {