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