897b4b59e57d80b31f3735e33c8ce7b58258324e
[ldk-java] / ts / structs / Access.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 public class Access extends CommonBase {
6         final bindings.LDKAccess bindings_instance;
7         Access(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
8         private Access(bindings.LDKAccess arg) {
9                 super(bindings.LDKAccess_new(arg));
10                 this.ptrs_to.add(arg);
11                 this.bindings_instance = arg;
12         }
13         @Override @SuppressWarnings("deprecation")
14         protected void finalize() throws Throwable {
15                 if (ptr != 0) { bindings.Access_free(ptr); } super.finalize();
16         }
17
18         public static interface AccessInterface {
19                 Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id);
20         }
21         private static class LDKAccessHolder { Access held; }
22         public static Access new_impl(AccessInterface arg) {
23                 final LDKAccessHolder impl_holder = new LDKAccessHolder();
24                 impl_holder.held = new Access(new bindings.LDKAccess() {
25                         @Override public uint32_t get_utxo(byte[] genesis_hash, long short_channel_id) {
26                                 Result_TxOutAccessErrorZ ret = arg.get_utxo(genesis_hash, short_channel_id);
27                                 uint32_t result = ret != null ? ret.ptr : 0;
28                                 ret.ptr = 0;
29                                 return result;
30                         }
31                 });
32                 return impl_holder.held;
33         }
34         public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
35                 uint32_t ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id);
36                 Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
37                 return ret_hu_conv;
38         }
39
40 }