Merge pull request #117 from TheBlueMatt/2022-08-fix-npe
[ldk-java] / src / main / java / org / ldk / structs / ClosureReason.java
index 519ac61be4df5a9b675e65c316b62bdeb0ff52d0..800deb56e6b5b59bb7a9b15a8994064ee5c4b9a5 100644 (file)
@@ -119,11 +119,11 @@ public class ClosureReason extends CommonBase {
                }
        }
        /**
-        * The `PeerManager` informed us that we've disconnected from the peer. We close channels
-        * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
-        * peer again in the future or if the peer disconnected before we finished negotiating
-        * the channel open. The first case may be caused by incompatible features which our
-        * counterparty, or we, require.
+        * The peer disconnected prior to funding completing. In this case the spec mandates that we
+        * forget the channel entirely - we can attempt again if the peer reconnects.
+        * 
+        * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
+        * peer because of mutual incompatibility between us and our channel counterparty.
         */
        public final static class DisconnectedPeer extends ClosureReason {
                private DisconnectedPeer(long ptr, bindings.LDKClosureReason.DisconnectedPeer obj) {
@@ -153,7 +153,7 @@ public class ClosureReason extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -165,7 +165,7 @@ public class ClosureReason extends CommonBase {
                Reference.reachabilityFence(peer_msg);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -176,7 +176,7 @@ public class ClosureReason extends CommonBase {
                long ret = bindings.ClosureReason_holder_force_closed();
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -187,7 +187,7 @@ public class ClosureReason extends CommonBase {
                long ret = bindings.ClosureReason_cooperative_closure();
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -198,7 +198,7 @@ public class ClosureReason extends CommonBase {
                long ret = bindings.ClosureReason_commitment_tx_confirmed();
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -209,7 +209,7 @@ public class ClosureReason extends CommonBase {
                long ret = bindings.ClosureReason_funding_timed_out();
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -221,7 +221,7 @@ public class ClosureReason extends CommonBase {
                Reference.reachabilityFence(err);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -232,7 +232,7 @@ public class ClosureReason extends CommonBase {
                long ret = bindings.ClosureReason_disconnected_peer();
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
@@ -243,7 +243,7 @@ public class ClosureReason extends CommonBase {
                long ret = bindings.ClosureReason_outdated_channel_manager();
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }