0ecc2feb6789cde12c5814a77c0ce738b2330018
[ldk-java] / src / main / java / org / ldk / structs / BroadcasterInterface.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * An interface to send a transaction to the Bitcoin network.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class BroadcasterInterface extends CommonBase {
15         final bindings.LDKBroadcasterInterface bindings_instance;
16         BroadcasterInterface(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
17         private BroadcasterInterface(bindings.LDKBroadcasterInterface arg) {
18                 super(bindings.LDKBroadcasterInterface_new(arg));
19                 this.ptrs_to.add(arg);
20                 this.bindings_instance = arg;
21         }
22         @Override @SuppressWarnings("deprecation")
23         protected void finalize() throws Throwable {
24                 if (ptr != 0) { bindings.BroadcasterInterface_free(ptr); } super.finalize();
25         }
26         /**
27          * Destroys the object, freeing associated resources. After this call, any access
28          * to this object may result in a SEGFAULT or worse.
29          *
30          * You should generally NEVER call this method. You should let the garbage collector
31          * do this for you when it finalizes objects. However, it may be useful for types
32          * which represent locks and should be closed immediately to avoid holding locks
33          * until the GC runs.
34          */
35         public void destroy() {
36                 if (ptr != 0) { bindings.BroadcasterInterface_free(ptr); }
37                 ptr = 0;
38         }
39         public static interface BroadcasterInterfaceInterface {
40                 /**
41                  * Sends a transaction out to (hopefully) be mined.
42                  */
43                 void broadcast_transaction(byte[] tx);
44         }
45         private static class LDKBroadcasterInterfaceHolder { BroadcasterInterface held; }
46         public static BroadcasterInterface new_impl(BroadcasterInterfaceInterface arg) {
47                 final LDKBroadcasterInterfaceHolder impl_holder = new LDKBroadcasterInterfaceHolder();
48                 impl_holder.held = new BroadcasterInterface(new bindings.LDKBroadcasterInterface() {
49                         @Override public void broadcast_transaction(byte[] tx) {
50                                 arg.broadcast_transaction(tx);
51                                 Reference.reachabilityFence(arg);
52                         }
53                 });
54                 return impl_holder.held;
55         }
56         /**
57          * Sends a transaction out to (hopefully) be mined.
58          */
59         public void broadcast_transaction(byte[] tx) {
60                 bindings.BroadcasterInterface_broadcast_transaction(this.ptr, tx);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(tx);
63         }
64
65 }