1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
9 * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
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;
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.Access_free(ptr); } super.finalize();
26 public static interface AccessInterface {
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
32 * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
34 Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id);
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;
46 return impl_holder.held;
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
53 * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
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);