protected void finalize() throws Throwable {
if (ptr != 0) { bindings.Filter_free(ptr); } super.finalize();
}
-
+ /**
+ * Destroys the object, freeing associated resources. After this call, any access
+ * to this object may result in a SEGFAULT or worse.
+ *
+ * You should generally NEVER call this method. You should let the garbage collector
+ * do this for you when it finalizes objects. However, it may be useful for types
+ * which represent locks and should be closed immediately to avoid holding locks
+ * until the GC runs.
+ */
+ public void destroy() {
+ if (ptr != 0) { bindings.Filter_free(ptr); }
+ ptr = 0;
+ }
public static interface FilterInterface {
/**
* Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
* a spending condition.
+ *
+ * This may be used, for example, to monitor for when a funding transaction confirms.
+ *
+ * The `script_pubkey` is provided for informational purposes and may be useful for block
+ * sources which only support filtering on scripts.
*/
void register_tx(byte[] txid, byte[] script_pubkey);
/**
* 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.
+ *
+ * This may be used, for example, to monitor for when a funding output is spent (by any
+ * transaction).
*/
void register_output(WatchedOutput output);
}
/**
* Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
* a spending condition.
+ *
+ * This may be used, for example, to monitor for when a funding transaction confirms.
+ *
+ * The `script_pubkey` is provided for informational purposes and may be useful for block
+ * sources which only support filtering on scripts.
*/
public void register_tx(byte[] txid, byte[] script_pubkey) {
bindings.Filter_register_tx(this.ptr, InternalUtils.check_arr_len(txid, 32), script_pubkey);
* 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.
+ *
+ * This may be used, for example, to monitor for when a funding output is spent (by any
+ * transaction).
*/
public void register_output(org.ldk.structs.WatchedOutput output) {
- bindings.Filter_register_output(this.ptr, output == null ? 0 : output.ptr);
+ bindings.Filter_register_output(this.ptr, output.ptr);
Reference.reachabilityFence(this);
Reference.reachabilityFence(output);
- if (this != null) { this.ptrs_to.add(output); };
}
}