15b3d7423df26c1bb581c2a75b7393295ae382da
[ldk-java] / src / main / java / org / ldk / structs / Access.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
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class Access extends CommonBase {
10         final bindings.LDKAccess bindings_instance;
11         Access(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private Access(bindings.LDKAccess arg) {
13                 super(bindings.LDKAccess_new(arg));
14                 this.ptrs_to.add(arg);
15                 this.bindings_instance = arg;
16         }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 if (ptr != 0) { bindings.Access_free(ptr); } super.finalize();
20         }
21
22         public static interface AccessInterface {
23                 Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id);
24         }
25         public Access(AccessInterface arg) {
26                 this(new bindings.LDKAccess() {
27                         @Override public long get_utxo(byte[] genesis_hash, long short_channel_id) {
28                                 Result_TxOutAccessErrorZ ret = arg.get_utxo(genesis_hash, short_channel_id);
29                                 long result = ret != null ? ret.ptr : 0;
30                                 ret.ptr = 0;
31                                 return result;
32                         }
33                 });
34         }
35         public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
36                 long ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id);
37                 Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
38                 ret_hu_conv.ptrs_to.add(this);
39                 return ret_hu_conv;
40         }
41
42 }