Merge pull request #33 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / Watch.java
index 85602ac83a4135f09079c490791dcf1242224bc9..015f7e4f46b3caadd036f34ef19cb73958ad5719 100644 (file)
@@ -4,6 +4,7 @@ import org.ldk.impl.bindings;
 import org.ldk.enums.*;
 import org.ldk.util.*;
 import java.util.Arrays;
+import javax.annotation.Nullable;
 
 /**
  * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
@@ -24,9 +25,9 @@ import java.util.Arrays;
  * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
  * multiple instances.
  * 
- * [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html
- * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
- * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure
+ * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
+ * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
+ * [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class Watch extends CommonBase {
@@ -50,9 +51,9 @@ public class Watch extends CommonBase {
                 * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
                 * calling [`block_connected`] and [`block_disconnected`] on the monitor.
                 * 
-                * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
-                * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
-                * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
+                * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
+                * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
+                * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
                 */
                Result_NoneChannelMonitorUpdateErrZ watch_channel(OutPoint funding_txo, ChannelMonitor monitor);
                /**
@@ -61,8 +62,8 @@ public class Watch extends CommonBase {
                 * Implementations must call [`update_monitor`] with the given update. See
                 * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
                 * 
-                * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
-                * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+                * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor
+                * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
                 */
                Result_NoneChannelMonitorUpdateErrZ update_channel(OutPoint funding_txo, ChannelMonitorUpdate update);
                /**
@@ -95,7 +96,7 @@ public class Watch extends CommonBase {
                        }
                        @Override public long[] release_pending_monitor_events() {
                                MonitorEvent[] ret = arg.release_pending_monitor_events();
-                               long[] result = Arrays.stream(ret).mapToLong(ret_conv_14 -> ret_conv_14.ptr).toArray();
+                               long[] result = ret != null ? Arrays.stream(ret).mapToLong(ret_conv_14 -> ret_conv_14.ptr).toArray() : null;
                                /* TODO 2 MonitorEvent  */;
                                return result;
                        }
@@ -109,12 +110,13 @@ public class Watch extends CommonBase {
         * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
         * calling [`block_connected`] and [`block_disconnected`] on the monitor.
         * 
-        * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
-        * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
-        * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
+        * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
+        * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
+        * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
         */
        public Result_NoneChannelMonitorUpdateErrZ watch_channel(OutPoint funding_txo, ChannelMonitor monitor) {
                long ret = bindings.Watch_watch_channel(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, monitor == null ? 0 : monitor.ptr & ~1);
+               if (ret < 1024) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                this.ptrs_to.add(funding_txo);
                this.ptrs_to.add(monitor);
@@ -127,11 +129,12 @@ public class Watch extends CommonBase {
         * Implementations must call [`update_monitor`] with the given update. See
         * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
         * 
-        * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
-        * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+        * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor
+        * [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
         */
        public Result_NoneChannelMonitorUpdateErrZ update_channel(OutPoint funding_txo, ChannelMonitorUpdate update) {
                long ret = bindings.Watch_update_channel(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, update == null ? 0 : update.ptr & ~1);
+               if (ret < 1024) { return null; }
                Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
                this.ptrs_to.add(funding_txo);
                this.ptrs_to.add(update);