[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Utxo.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  * An unspent transaction output that is available to spend resulting from a successful
11  * [`CoinSelection`] attempt.
12  */
13 public class Utxo : CommonBase {
14         internal Utxo(object _dummy, long ptr) : base(ptr) { }
15         ~Utxo() {
16                 if (ptr != 0) { bindings.Utxo_free(ptr); }
17         }
18
19         /**
20          * The unique identifier of the output.
21          */
22         public OutPoint get_outpoint() {
23                 long ret = bindings.Utxo_get_outpoint(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
27                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
28                 return ret_hu_conv;
29         }
30
31         /**
32          * The unique identifier of the output.
33          */
34         public void set_outpoint(org.ldk.structs.OutPoint val) {
35                 bindings.Utxo_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38                 if (this != null) { this.ptrs_to.AddLast(val); };
39         }
40
41         /**
42          * The output to spend.
43          */
44         public TxOut get_output() {
45                 long ret = bindings.Utxo_get_output(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 TxOut ret_conv = new TxOut(null, ret);
49                 return ret_conv;
50         }
51
52         /**
53          * The output to spend.
54          */
55         public void set_output(org.ldk.structs.TxOut val) {
56                 bindings.Utxo_set_output(this.ptr, val.ptr);
57                 GC.KeepAlive(this);
58                 GC.KeepAlive(val);
59         }
60
61         /**
62          * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
63          * with their lengths included, required to satisfy the output's script. The weight consumed by
64          * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
65          */
66         public long get_satisfaction_weight() {
67                 long ret = bindings.Utxo_get_satisfaction_weight(this.ptr);
68                 GC.KeepAlive(this);
69                 return ret;
70         }
71
72         /**
73          * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
74          * with their lengths included, required to satisfy the output's script. The weight consumed by
75          * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
76          */
77         public void set_satisfaction_weight(long val) {
78                 bindings.Utxo_set_satisfaction_weight(this.ptr, val);
79                 GC.KeepAlive(this);
80                 GC.KeepAlive(val);
81         }
82
83         /**
84          * Constructs a new Utxo given each field
85          */
86         public static Utxo of(org.ldk.structs.OutPoint outpoint_arg, org.ldk.structs.TxOut output_arg, long satisfaction_weight_arg) {
87                 long ret = bindings.Utxo_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, output_arg.ptr, satisfaction_weight_arg);
88                 GC.KeepAlive(outpoint_arg);
89                 GC.KeepAlive(output_arg);
90                 GC.KeepAlive(satisfaction_weight_arg);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.Utxo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Utxo(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint_arg); };
95                 return ret_hu_conv;
96         }
97
98         internal long clone_ptr() {
99                 long ret = bindings.Utxo_clone_ptr(this.ptr);
100                 GC.KeepAlive(this);
101                 return ret;
102         }
103
104         /**
105          * Creates a copy of the Utxo
106          */
107         public Utxo clone() {
108                 long ret = bindings.Utxo_clone(this.ptr);
109                 GC.KeepAlive(this);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 org.ldk.structs.Utxo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Utxo(null, ret); }
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
113                 return ret_hu_conv;
114         }
115
116         /**
117          * Generates a non-cryptographic 64-bit hash of the Utxo.
118          */
119         public long hash() {
120                 long ret = bindings.Utxo_hash(this.ptr);
121                 GC.KeepAlive(this);
122                 return ret;
123         }
124
125         public override int GetHashCode() {
126                 return (int)this.hash();
127         }
128         /**
129          * Checks if two Utxos contain equal inner contents.
130          * This ignores pointers and is_owned flags and looks at the values in fields.
131          * Two objects with NULL inner values will be considered "equal" here.
132          */
133         public bool eq(org.ldk.structs.Utxo b) {
134                 bool ret = bindings.Utxo_eq(this.ptr, b == null ? 0 : b.ptr);
135                 GC.KeepAlive(this);
136                 GC.KeepAlive(b);
137                 if (this != null) { this.ptrs_to.AddLast(b); };
138                 return ret;
139         }
140
141         public override bool Equals(object o) {
142                 if (!(o is Utxo)) return false;
143                 return this.eq((Utxo)o);
144         }
145         /**
146          * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output.
147          */
148         public static Utxo new_p2pkh(org.ldk.structs.OutPoint outpoint, long value, byte[] pubkey_hash) {
149                 long ret = bindings.Utxo_new_p2pkh(outpoint == null ? 0 : outpoint.ptr, value, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey_hash, 20)));
150                 GC.KeepAlive(outpoint);
151                 GC.KeepAlive(value);
152                 GC.KeepAlive(pubkey_hash);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.Utxo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Utxo(null, ret); }
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };
157                 return ret_hu_conv;
158         }
159
160 }
161 } } }