[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / UtxoLookup.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * The `UtxoLookup` trait defines behavior for accessing on-chain UTXOs.
10  */
11 public class UtxoLookup : CommonBase {
12         internal readonly bindings.LDKUtxoLookup bindings_instance;
13         internal UtxoLookup(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
14         private UtxoLookup(bindings.LDKUtxoLookup arg) : base(bindings.LDKUtxoLookup_new(arg)) {
15                 this.ptrs_to.AddLast(arg);
16                 this.bindings_instance = arg;
17         }
18         ~UtxoLookup() {
19                 if (ptr != 0) { bindings.UtxoLookup_free(ptr); }
20         }
21
22         public interface UtxoLookupInterface {
23                 /**
24                  * Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
25                  * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
26                  * is unknown.
27                  * 
28                  * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id
29                  */
30                 UtxoResult get_utxo(byte[] _genesis_hash, long _short_channel_id);
31         }
32         private class LDKUtxoLookupHolder { internal UtxoLookup held; }
33         private class LDKUtxoLookupImpl : bindings.LDKUtxoLookup {
34                 internal LDKUtxoLookupImpl(UtxoLookupInterface arg, LDKUtxoLookupHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
35                 private UtxoLookupInterface arg;
36                 private LDKUtxoLookupHolder impl_holder;
37                 public long get_utxo(byte[] _genesis_hash, long _short_channel_id) {
38                         UtxoResult ret = arg.get_utxo(_genesis_hash, _short_channel_id);
39                                 GC.KeepAlive(arg);
40                         long result = ret == null ? 0 : ret.clone_ptr();
41                         if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
42                         return result;
43                 }
44         }
45         public static UtxoLookup new_impl(UtxoLookupInterface arg) {
46                 LDKUtxoLookupHolder impl_holder = new LDKUtxoLookupHolder();
47                 impl_holder.held = new UtxoLookup(new LDKUtxoLookupImpl(arg, impl_holder));
48                 return impl_holder.held;
49         }
50         /**
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
53          * is unknown.
54          * 
55          * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id
56          */
57         public UtxoResult get_utxo(byte[] genesis_hash, long short_channel_id) {
58                 long ret = bindings.UtxoLookup_get_utxo(this.ptr, InternalUtils.check_arr_len(genesis_hash, 32), short_channel_id);
59                 GC.KeepAlive(this);
60                 GC.KeepAlive(genesis_hash);
61                 GC.KeepAlive(short_channel_id);
62                 if (ret >= 0 && ret <= 4096) { return null; }
63                 org.ldk.structs.UtxoResult ret_hu_conv = org.ldk.structs.UtxoResult.constr_from_ptr(ret);
64                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
65                 return ret_hu_conv;
66         }
67
68 }
69 } } }