[Java] Update auto-generated Java bindings
[ldk-java] / src / main / java / org / ldk / structs / Filter.java
index bd754f79acc5887375792a0efcd81cc8f745086b..f26427c2c056a35ffdeb855df77effab055840cd 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;
 
 /**
@@ -22,9 +23,9 @@ import javax.annotation.Nullable;
  * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter`
  * should not block on I/O. Implementations should instead queue the newly monitored data to be
  * processed later. Then, in order to block until the data has been processed, any [`Watch`]
- * invocation that has called the `Filter` must return [`TemporaryFailure`].
+ * invocation that has called the `Filter` must return [`InProgress`].
  * 
- * [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure
+ * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress
  * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
  * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
  */
@@ -51,15 +52,12 @@ public class Filter extends CommonBase {
                /**
                 * Registers interest in spends of a transaction output.
                 * 
-                * Optionally, when `output.block_hash` is set, should return any transaction spending the
-                * output that is found in the corresponding block along with its index.
-                * 
-                * This return value is useful for Electrum clients in order to supply in-block descendant
-                * transactions which otherwise were not included. This is not necessary for other clients if
-                * such descendant transactions were already included (e.g., when a BIP 157 client provides the
-                * full block).
+                * Note that this method might be called during processing of a new block. You therefore need
+                * to ensure that also dependent output spents within an already connected block are correctly
+                * handled, e.g., by re-scanning the block in question whenever new outputs have been
+                * registered mid-processing.
                 */
-               Option_C2Tuple_usizeTransactionZZ register_output(WatchedOutput output);
+               void register_output(WatchedOutput output);
        }
        private static class LDKFilterHolder { Filter held; }
        public static Filter new_impl(FilterInterface arg) {
@@ -67,13 +65,13 @@ public class Filter extends CommonBase {
                impl_holder.held = new Filter(new bindings.LDKFilter() {
                        @Override public void register_tx(byte[] txid, byte[] script_pubkey) {
                                arg.register_tx(txid, script_pubkey);
+                               Reference.reachabilityFence(arg);
                        }
-                       @Override public long register_output(long output) {
-                               WatchedOutput output_hu_conv = new WatchedOutput(null, output);
-                               output_hu_conv.ptrs_to.add(this);
-                               Option_C2Tuple_usizeTransactionZZ ret = arg.register_output(output_hu_conv);
-                               long result = ret.ptr;
-                               return result;
+                       @Override public void register_output(long output) {
+                               org.ldk.structs.WatchedOutput output_hu_conv = null; if (output < 0 || output > 4096) { output_hu_conv = new org.ldk.structs.WatchedOutput(null, output); }
+                               if (output_hu_conv != null) { output_hu_conv.ptrs_to.add(this); };
+                               arg.register_output(output_hu_conv);
+                               Reference.reachabilityFence(arg);
                        }
                });
                return impl_holder.held;
@@ -83,26 +81,25 @@ public class Filter extends CommonBase {
         * a spending condition.
         */
        public void register_tx(byte[] txid, byte[] script_pubkey) {
-               bindings.Filter_register_tx(this.ptr, txid, script_pubkey);
+               bindings.Filter_register_tx(this.ptr, InternalUtils.check_arr_len(txid, 32), script_pubkey);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(txid);
+               Reference.reachabilityFence(script_pubkey);
        }
 
        /**
         * Registers interest in spends of a transaction output.
         * 
-        * Optionally, when `output.block_hash` is set, should return any transaction spending the
-        * output that is found in the corresponding block along with its index.
-        * 
-        * This return value is useful for Electrum clients in order to supply in-block descendant
-        * transactions which otherwise were not included. This is not necessary for other clients if
-        * such descendant transactions were already included (e.g., when a BIP 157 client provides the
-        * full block).
+        * Note that this method might be called during processing of a new block. You therefore need
+        * to ensure that also dependent output spents within an already connected block are correctly
+        * handled, e.g., by re-scanning the block in question whenever new outputs have been
+        * registered mid-processing.
         */
-       public Option_C2Tuple_usizeTransactionZZ register_output(WatchedOutput output) {
-               long ret = bindings.Filter_register_output(this.ptr, output == null ? 0 : output.ptr & ~1);
-               if (ret >= 0 && ret < 1024) { return null; }
-               Option_C2Tuple_usizeTransactionZZ ret_hu_conv = Option_C2Tuple_usizeTransactionZZ.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(this);
-               return ret_hu_conv;
+       public void register_output(WatchedOutput output) {
+               bindings.Filter_register_output(this.ptr, output == null ? 0 : output.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(output);
+               if (this != null) { this.ptrs_to.add(output); };
        }
 
 }