[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / Balance.java
index 1a08f911cfdf35471aa6f9a464802e81ac759551..e6957ac2602e9d5900b0aceb0eb65852662c5852 100644 (file)
@@ -4,6 +4,7 @@ import org.ldk.impl.bindings;
 import org.ldk.enums.*;
 import org.ldk.util.*;
 import java.util.Arrays;
+import java.lang.ref.Reference;
 import javax.annotation.Nullable;
 
 
@@ -38,6 +39,11 @@ public class Balance extends CommonBase {
                assert false; return null; // Unreachable without extending the (internal) bindings interface
        }
 
+       /**
+        * The channel is not yet closed (or the commitment or closing transaction has not yet
+        * appeared in a block). The given balance is claimable (less on-chain fees) if the channel is
+        * force-closed now.
+        */
        public final static class ClaimableOnChannelClose extends Balance {
                /**
                 * The amount available to claim, in satoshis, excluding the on-chain fees which will be
@@ -49,6 +55,10 @@ public class Balance extends CommonBase {
                        this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
                }
        }
+       /**
+        * The channel has been closed, and the given balance is ours but awaiting confirmations until
+        * we consider it spendable.
+        */
        public final static class ClaimableAwaitingConfirmations extends Balance {
                /**
                 * The amount available to claim, in satoshis, possibly excluding the on-chain fees which
@@ -66,6 +76,15 @@ public class Balance extends CommonBase {
                        this.confirmation_height = obj.confirmation_height;
                }
        }
+       /**
+        * The channel has been closed, and the given balance should be ours but awaiting spending
+        * transaction confirmation. If the spending transaction does not confirm in time, it is
+        * possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain.
+        * 
+        * Once the spending transaction confirms, before it has reached enough confirmations to be
+        * considered safe from chain reorganizations, the balance will instead be provided via
+        * [`Balance::ClaimableAwaitingConfirmations`].
+        */
        public final static class ContentiousClaimable extends Balance {
                /**
                 * The amount available to claim, in satoshis, excluding the on-chain fees which will be
@@ -83,6 +102,11 @@ public class Balance extends CommonBase {
                        this.timeout_height = obj.timeout_height;
                }
        }
+       /**
+        * HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
+        * fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
+        * likely to be claimed by our counterparty before we do.
+        */
        public final static class MaybeClaimableHTLCAwaitingTimeout extends Balance {
                /**
                 * The amount available to claim, in satoshis, excluding the on-chain fees which will be
@@ -100,13 +124,20 @@ public class Balance extends CommonBase {
                        this.claimable_height = obj.claimable_height;
                }
        }
+       long clone_ptr() {
+               long ret = bindings.Balance_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
        /**
         * Creates a copy of the Balance
         */
        public Balance clone() {
                long ret = bindings.Balance_clone(this.ptr);
-               if (ret < 1024) { return null; }
-               Balance ret_hu_conv = Balance.constr_from_ptr(ret);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;
        }
@@ -116,8 +147,9 @@ public class Balance extends CommonBase {
         */
        public static Balance claimable_on_channel_close(long claimable_amount_satoshis) {
                long ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis);
-               if (ret < 1024) { return null; }
-               Balance ret_hu_conv = Balance.constr_from_ptr(ret);
+               Reference.reachabilityFence(claimable_amount_satoshis);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -127,8 +159,10 @@ public class Balance extends CommonBase {
         */
        public static Balance claimable_awaiting_confirmations(long claimable_amount_satoshis, int confirmation_height) {
                long ret = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
-               if (ret < 1024) { return null; }
-               Balance ret_hu_conv = Balance.constr_from_ptr(ret);
+               Reference.reachabilityFence(claimable_amount_satoshis);
+               Reference.reachabilityFence(confirmation_height);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -138,8 +172,10 @@ public class Balance extends CommonBase {
         */
        public static Balance contentious_claimable(long claimable_amount_satoshis, int timeout_height) {
                long ret = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
-               if (ret < 1024) { return null; }
-               Balance ret_hu_conv = Balance.constr_from_ptr(ret);
+               Reference.reachabilityFence(claimable_amount_satoshis);
+               Reference.reachabilityFence(timeout_height);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -149,8 +185,10 @@ public class Balance extends CommonBase {
         */
        public static Balance maybe_claimable_htlcawaiting_timeout(long claimable_amount_satoshis, int claimable_height) {
                long ret = bindings.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
-               if (ret < 1024) { return null; }
-               Balance ret_hu_conv = Balance.constr_from_ptr(ret);
+               Reference.reachabilityFence(claimable_amount_satoshis);
+               Reference.reachabilityFence(claimable_height);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
                ret_hu_conv.ptrs_to.add(ret_hu_conv);
                return ret_hu_conv;
        }
@@ -161,7 +199,13 @@ public class Balance extends CommonBase {
         */
        public boolean eq(Balance b) {
                boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(b);
                return ret;
        }
 
+       @Override public boolean equals(Object o) {
+               if (!(o instanceof Balance)) return false;
+               return this.eq((Balance)o);
+       }
 }