+ if (ptr != 0) { bindings.Filter_free(ptr); } super.finalize();
+ }
+
+ public static interface FilterInterface {
+ /**
+ * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
+ * a spending condition.
+ */
+ void register_tx(byte[] txid, byte[] script_pubkey);
+ /**
+ * Registers interest in spends of a transaction output identified by `outpoint` having
+ * `script_pubkey` as the spending condition.
+ */
+ void register_output(OutPoint outpoint, byte[] script_pubkey);
+ }
+ private static class LDKFilterHolder { Filter held; }
+ public static Filter new_impl(FilterInterface arg) {
+ final LDKFilterHolder impl_holder = new LDKFilterHolder();
+ impl_holder.held = new Filter(new bindings.LDKFilter() {
+ @Override public void register_tx(byte[] txid, byte[] script_pubkey) {
+ arg.register_tx(txid, script_pubkey);
+ }
+ @Override public void register_output(long outpoint, byte[] script_pubkey) {
+ OutPoint outpoint_hu_conv = new OutPoint(null, outpoint);
+ arg.register_output(outpoint_hu_conv, script_pubkey);
+ }
+ });
+ return impl_holder.held;
+ }
+ /**
+ * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
+ * a spending condition.
+ */
+ public void register_tx(byte[] txid, byte[] script_pubkey) {
+ bindings.Filter_register_tx(this.ptr, txid, script_pubkey);
+ }
+
+ /**
+ * Registers interest in spends of a transaction output identified by `outpoint` having
+ * `script_pubkey` as the spending condition.
+ */
+ public void register_output(OutPoint outpoint, byte[] script_pubkey) {
+ bindings.Filter_register_output(this.ptr, outpoint == null ? 0 : outpoint.ptr & ~1, script_pubkey);
+ this.ptrs_to.add(outpoint);