[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / CoinSelection.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 /**
10  * The result of a successful coin selection attempt for a transaction requiring additional UTXOs
11  * to cover its fees.
12  */
13 public class CoinSelection : CommonBase {
14         internal CoinSelection(object _dummy, long ptr) : base(ptr) { }
15         ~CoinSelection() {
16                 if (ptr != 0) { bindings.CoinSelection_free(ptr); }
17         }
18
19         /**
20          * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
21          * requiring additional fees.
22          */
23         public Utxo[] get_confirmed_utxos() {
24                 long ret = bindings.CoinSelection_get_confirmed_utxos(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 int ret_conv_6_len = InternalUtils.getArrayLength(ret);
28                 Utxo[] ret_conv_6_arr = new Utxo[ret_conv_6_len];
29                 for (int g = 0; g < ret_conv_6_len; g++) {
30                         long ret_conv_6 = InternalUtils.getU64ArrayElem(ret, g);
31                         org.ldk.structs.Utxo ret_conv_6_hu_conv = null; if (ret_conv_6 < 0 || ret_conv_6 > 4096) { ret_conv_6_hu_conv = new org.ldk.structs.Utxo(null, ret_conv_6); }
32                         if (ret_conv_6_hu_conv != null) { ret_conv_6_hu_conv.ptrs_to.AddLast(this); };
33                         ret_conv_6_arr[g] = ret_conv_6_hu_conv;
34                 }
35                 bindings.free_buffer(ret);
36                 return ret_conv_6_arr;
37         }
38
39         /**
40          * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
41          * requiring additional fees.
42          */
43         public void set_confirmed_utxos(Utxo[] val) {
44                 bindings.CoinSelection_set_confirmed_utxos(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_6 => val_conv_6 == null ? 0 : val_conv_6.ptr)));
45                 GC.KeepAlive(this);
46                 GC.KeepAlive(val);
47                 foreach (Utxo val_conv_6 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_6); }; };
48         }
49
50         /**
51          * An additional output tracking whether any change remained after coin selection. This output
52          * should always have a value above dust for its given `script_pubkey`. It should not be
53          * spent until the transaction it belongs to confirms to ensure mempool descendant limits are
54          * not met. This implies no other party should be able to spend it except us.
55          */
56         public Option_TxOutZ get_change_output() {
57                 long ret = bindings.CoinSelection_get_change_output(this.ptr);
58                 GC.KeepAlive(this);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 org.ldk.structs.Option_TxOutZ ret_hu_conv = org.ldk.structs.Option_TxOutZ.constr_from_ptr(ret);
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
62                 return ret_hu_conv;
63         }
64
65         /**
66          * An additional output tracking whether any change remained after coin selection. This output
67          * should always have a value above dust for its given `script_pubkey`. It should not be
68          * spent until the transaction it belongs to confirms to ensure mempool descendant limits are
69          * not met. This implies no other party should be able to spend it except us.
70          */
71         public void set_change_output(org.ldk.structs.Option_TxOutZ val) {
72                 bindings.CoinSelection_set_change_output(this.ptr, val.ptr);
73                 GC.KeepAlive(this);
74                 GC.KeepAlive(val);
75                 if (this != null) { this.ptrs_to.AddLast(val); };
76         }
77
78         /**
79          * Constructs a new CoinSelection given each field
80          */
81         public static CoinSelection of(Utxo[] confirmed_utxos_arg, org.ldk.structs.Option_TxOutZ change_output_arg) {
82                 long ret = bindings.CoinSelection_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(confirmed_utxos_arg, confirmed_utxos_arg_conv_6 => confirmed_utxos_arg_conv_6 == null ? 0 : confirmed_utxos_arg_conv_6.ptr)), change_output_arg.ptr);
83                 GC.KeepAlive(confirmed_utxos_arg);
84                 GC.KeepAlive(change_output_arg);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.CoinSelection ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CoinSelection(null, ret); }
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
88                 foreach (Utxo confirmed_utxos_arg_conv_6 in confirmed_utxos_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(confirmed_utxos_arg_conv_6); }; };
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(change_output_arg); };
90                 return ret_hu_conv;
91         }
92
93         internal long clone_ptr() {
94                 long ret = bindings.CoinSelection_clone_ptr(this.ptr);
95                 GC.KeepAlive(this);
96                 return ret;
97         }
98
99         /**
100          * Creates a copy of the CoinSelection
101          */
102         public CoinSelection clone() {
103                 long ret = bindings.CoinSelection_clone(this.ptr);
104                 GC.KeepAlive(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.CoinSelection ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CoinSelection(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
108                 return ret_hu_conv;
109         }
110
111 }
112 } } }