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