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