6 namespace org { namespace ldk { namespace structs {
9 * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
12 public class Access : CommonBase {
13 internal readonly bindings.LDKAccess bindings_instance;
14 internal Access(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
15 private Access(bindings.LDKAccess arg) : base(bindings.LDKAccess_new(arg)) {
16 this.ptrs_to.AddLast(arg);
17 this.bindings_instance = arg;
20 if (ptr != 0) { bindings.Access_free(ptr); }
23 public interface AccessInterface {
25 * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
26 * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
29 * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id
31 Result_TxOutAccessErrorZ get_utxo(byte[] _genesis_hash, long _short_channel_id);
33 private class LDKAccessHolder { internal Access held; }
34 private class LDKAccessImpl : bindings.LDKAccess {
35 internal LDKAccessImpl(AccessInterface arg, LDKAccessHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
36 private AccessInterface arg;
37 private LDKAccessHolder impl_holder;
38 public long get_utxo(byte[] _genesis_hash, long _short_channel_id) {
39 Result_TxOutAccessErrorZ ret = arg.get_utxo(_genesis_hash, _short_channel_id);
41 long result = ret == null ? 0 : ret.clone_ptr();
45 public static Access new_impl(AccessInterface arg) {
46 LDKAccessHolder impl_holder = new LDKAccessHolder();
47 impl_holder.held = new Access(new LDKAccessImpl(arg, impl_holder));
48 return impl_holder.held;
51 * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
52 * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
55 * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id
57 public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
58 long ret = bindings.Access_get_utxo(this.ptr, InternalUtils.check_arr_len(genesis_hash, 32), short_channel_id);
60 GC.KeepAlive(genesis_hash);
61 GC.KeepAlive(short_channel_id);
62 if (ret >= 0 && ret <= 4096) { return null; }
63 Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);