Rewrite the world, with several interdependant changes (but several still WIP)
[ldk-java] / src / main / java / org / ldk / structs / InMemoryChannelKeys.java
index 5176b137a3aed5cb90e90c792625ef0c68d9792b..00825ab32738701ba8132c24aa0b6b7f6a08a6da 100644 (file)
@@ -2,7 +2,10 @@ package org.ldk.structs;
 
 import org.ldk.impl.bindings;
 import org.ldk.enums.*;
+import org.ldk.util.*;
+import java.util.Arrays;
 
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class InMemoryChannelKeys extends CommonBase {
        InMemoryChannelKeys(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
@@ -11,81 +14,72 @@ public class InMemoryChannelKeys extends CommonBase {
                bindings.InMemoryChannelKeys_free(ptr);
        }
 
-       public InMemoryChannelKeys(InMemoryChannelKeys orig) {
-               super(bindings.InMemoryChannelKeys_clone(orig == null ? 0 : orig.ptr & ~1));
-               this.ptrs_to.add(orig);
+       public static InMemoryChannelKeys constructor_clone(InMemoryChannelKeys orig) {
+               long ret = bindings.InMemoryChannelKeys_clone(orig == null ? 0 : orig.ptr & ~1);
+               InMemoryChannelKeys ret_hu_conv = new InMemoryChannelKeys(null, ret);
+               ret_hu_conv.ptrs_to.add(orig);
+               return ret_hu_conv;
        }
 
-       public byte[] get_funding_key(InMemoryChannelKeys this_ptr) {
-               byte[] ret = bindings.InMemoryChannelKeys_get_funding_key(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       public byte[] get_funding_key() {
+               byte[] ret = bindings.InMemoryChannelKeys_get_funding_key(this.ptr);
                return ret;
        }
 
-       public void set_funding_key(InMemoryChannelKeys this_ptr, byte[] val) {
-               bindings.InMemoryChannelKeys_set_funding_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       public void set_funding_key(byte[] val) {
+               bindings.InMemoryChannelKeys_set_funding_key(this.ptr, val);
        }
 
-       public byte[] get_revocation_base_key(InMemoryChannelKeys this_ptr) {
-               byte[] ret = bindings.InMemoryChannelKeys_get_revocation_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       public byte[] get_revocation_base_key() {
+               byte[] ret = bindings.InMemoryChannelKeys_get_revocation_base_key(this.ptr);
                return ret;
        }
 
-       public void set_revocation_base_key(InMemoryChannelKeys this_ptr, byte[] val) {
-               bindings.InMemoryChannelKeys_set_revocation_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       public void set_revocation_base_key(byte[] val) {
+               bindings.InMemoryChannelKeys_set_revocation_base_key(this.ptr, val);
        }
 
-       public byte[] get_payment_key(InMemoryChannelKeys this_ptr) {
-               byte[] ret = bindings.InMemoryChannelKeys_get_payment_key(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       public byte[] get_payment_key() {
+               byte[] ret = bindings.InMemoryChannelKeys_get_payment_key(this.ptr);
                return ret;
        }
 
-       public void set_payment_key(InMemoryChannelKeys this_ptr, byte[] val) {
-               bindings.InMemoryChannelKeys_set_payment_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       public void set_payment_key(byte[] val) {
+               bindings.InMemoryChannelKeys_set_payment_key(this.ptr, val);
        }
 
-       public byte[] get_delayed_payment_base_key(InMemoryChannelKeys this_ptr) {
-               byte[] ret = bindings.InMemoryChannelKeys_get_delayed_payment_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       public byte[] get_delayed_payment_base_key() {
+               byte[] ret = bindings.InMemoryChannelKeys_get_delayed_payment_base_key(this.ptr);
                return ret;
        }
 
-       public void set_delayed_payment_base_key(InMemoryChannelKeys this_ptr, byte[] val) {
-               bindings.InMemoryChannelKeys_set_delayed_payment_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       public void set_delayed_payment_base_key(byte[] val) {
+               bindings.InMemoryChannelKeys_set_delayed_payment_base_key(this.ptr, val);
        }
 
-       public byte[] get_htlc_base_key(InMemoryChannelKeys this_ptr) {
-               byte[] ret = bindings.InMemoryChannelKeys_get_htlc_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       public byte[] get_htlc_base_key() {
+               byte[] ret = bindings.InMemoryChannelKeys_get_htlc_base_key(this.ptr);
                return ret;
        }
 
-       public void set_htlc_base_key(InMemoryChannelKeys this_ptr, byte[] val) {
-               bindings.InMemoryChannelKeys_set_htlc_base_key(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       public void set_htlc_base_key(byte[] val) {
+               bindings.InMemoryChannelKeys_set_htlc_base_key(this.ptr, val);
        }
 
-       public byte[] get_commitment_seed(InMemoryChannelKeys this_ptr) {
-               byte[] ret = bindings.InMemoryChannelKeys_get_commitment_seed(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       public byte[] get_commitment_seed() {
+               byte[] ret = bindings.InMemoryChannelKeys_get_commitment_seed(this.ptr);
                return ret;
        }
 
-       public void set_commitment_seed(InMemoryChannelKeys this_ptr, byte[] val) {
-               bindings.InMemoryChannelKeys_set_commitment_seed(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       public void set_commitment_seed(byte[] val) {
+               bindings.InMemoryChannelKeys_set_commitment_seed(this.ptr, val);
        }
 
        // Skipped InMemoryChannelKeys_new
        public ChannelPublicKeys counterparty_pubkeys() {
-               ChannelPublicKeys ret = new ChannelPublicKeys(null, bindings.InMemoryChannelKeys_counterparty_pubkeys(this.ptr));
-               return ret;
+               long ret = bindings.InMemoryChannelKeys_counterparty_pubkeys(this.ptr);
+               ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+               return ret_hu_conv;
        }
 
        public short counterparty_selected_contest_delay() {
@@ -99,9 +93,10 @@ public class InMemoryChannelKeys extends CommonBase {
        }
 
        public ChannelKeys as_ChannelKeys() {
-               ChannelKeys ret = new ChannelKeys(null, bindings.InMemoryChannelKeys_as_ChannelKeys(this.ptr));
-               ret.ptrs_to.add(this);
-               return ret;
+               long ret = bindings.InMemoryChannelKeys_as_ChannelKeys(this.ptr);
+               ChannelKeys ret_hu_conv = new ChannelKeys(null, ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
        }
 
        public byte[] write(InMemoryChannelKeys obj) {
@@ -110,8 +105,10 @@ public class InMemoryChannelKeys extends CommonBase {
                return ret;
        }
 
-       public InMemoryChannelKeys(byte[] ser) {
-               super(bindings.InMemoryChannelKeys_read(ser));
+       public static InMemoryChannelKeys constructor_read(byte[] ser) {
+               long ret = bindings.InMemoryChannelKeys_read(ser);
+               InMemoryChannelKeys ret_hu_conv = new InMemoryChannelKeys(null, ret);
+               return ret_hu_conv;
        }
 
 }