Update java bindings with new generator and new upstream code
[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 /**
9  * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
10  * UTXOs.
11  */
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class Access extends CommonBase {
14         final bindings.LDKAccess bindings_instance;
15         Access(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
16         private Access(bindings.LDKAccess arg) {
17                 super(bindings.LDKAccess_new(arg));
18                 this.ptrs_to.add(arg);
19                 this.bindings_instance = arg;
20         }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 if (ptr != 0) { bindings.Access_free(ptr); } super.finalize();
24         }
25
26         public static interface AccessInterface {
27                 /**
28                  * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
29                  * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
30                  * is unknown.
31                  * 
32                  * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
33                  */
34                 Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id);
35         }
36         private static class LDKAccessHolder { Access held; }
37         public static Access new_impl(AccessInterface arg) {
38                 final LDKAccessHolder impl_holder = new LDKAccessHolder();
39                 impl_holder.held = new Access(new bindings.LDKAccess() {
40                         @Override public long get_utxo(byte[] genesis_hash, long short_channel_id) {
41                                 Result_TxOutAccessErrorZ ret = arg.get_utxo(genesis_hash, short_channel_id);
42                                 long result = ret != null ? ret.ptr : 0;
43                                 return result;
44                         }
45                 });
46                 return impl_holder.held;
47         }
48         /**
49          * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
50          * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
51          * is unknown.
52          * 
53          * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
54          */
55         public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
56                 long ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id);
57                 Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
58                 return ret_hu_conv;
59         }
60
61 }