[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / WatchedOutput.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  * A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
11  * 
12  * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
13  * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
14  * [`Confirm::transactions_confirmed`].
15  * 
16  * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
17  * may have been spent there. See [`Filter::register_output`] for details.
18  * 
19  * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
20  * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
21  */
22 public class WatchedOutput : CommonBase {
23         internal WatchedOutput(object _dummy, long ptr) : base(ptr) { }
24         ~WatchedOutput() {
25                 if (ptr != 0) { bindings.WatchedOutput_free(ptr); }
26         }
27
28         /**
29          * First block where the transaction output may have been spent.
30          */
31         public Option_ThirtyTwoBytesZ get_block_hash() {
32                 long ret = bindings.WatchedOutput_get_block_hash(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
36                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
37                 return ret_hu_conv;
38         }
39
40         /**
41          * First block where the transaction output may have been spent.
42          */
43         public void set_block_hash(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
44                 bindings.WatchedOutput_set_block_hash(this.ptr, val.ptr);
45                 GC.KeepAlive(this);
46                 GC.KeepAlive(val);
47                 if (this != null) { this.ptrs_to.AddLast(val); };
48         }
49
50         /**
51          * Outpoint identifying the transaction output.
52          */
53         public OutPoint get_outpoint() {
54                 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
58                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Outpoint identifying the transaction output.
64          */
65         public void set_outpoint(org.ldk.structs.OutPoint val) {
66                 bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
67                 GC.KeepAlive(this);
68                 GC.KeepAlive(val);
69                 if (this != null) { this.ptrs_to.AddLast(val); };
70         }
71
72         /**
73          * Spending condition of the transaction output.
74          */
75         public byte[] get_script_pubkey() {
76                 long ret = bindings.WatchedOutput_get_script_pubkey(this.ptr);
77                 GC.KeepAlive(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
80                 return ret_conv;
81         }
82
83         /**
84          * Spending condition of the transaction output.
85          */
86         public void set_script_pubkey(byte[] val) {
87                 bindings.WatchedOutput_set_script_pubkey(this.ptr, InternalUtils.encodeUint8Array(val));
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(val);
90         }
91
92         /**
93          * Constructs a new WatchedOutput given each field
94          */
95         public static WatchedOutput of(org.ldk.structs.Option_ThirtyTwoBytesZ block_hash_arg, org.ldk.structs.OutPoint outpoint_arg, byte[] script_pubkey_arg) {
96                 long ret = bindings.WatchedOutput_new(block_hash_arg.ptr, outpoint_arg == null ? 0 : outpoint_arg.ptr, InternalUtils.encodeUint8Array(script_pubkey_arg));
97                 GC.KeepAlive(block_hash_arg);
98                 GC.KeepAlive(outpoint_arg);
99                 GC.KeepAlive(script_pubkey_arg);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
103                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(block_hash_arg); };
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint_arg); };
105                 return ret_hu_conv;
106         }
107
108         internal long clone_ptr() {
109                 long ret = bindings.WatchedOutput_clone_ptr(this.ptr);
110                 GC.KeepAlive(this);
111                 return ret;
112         }
113
114         /**
115          * Creates a copy of the WatchedOutput
116          */
117         public WatchedOutput clone() {
118                 long ret = bindings.WatchedOutput_clone(this.ptr);
119                 GC.KeepAlive(this);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Checks if two WatchedOutputs contain equal inner contents.
128          * This ignores pointers and is_owned flags and looks at the values in fields.
129          * Two objects with NULL inner values will be considered "equal" here.
130          */
131         public bool eq(org.ldk.structs.WatchedOutput b) {
132                 bool ret = bindings.WatchedOutput_eq(this.ptr, b == null ? 0 : b.ptr);
133                 GC.KeepAlive(this);
134                 GC.KeepAlive(b);
135                 if (this != null) { this.ptrs_to.AddLast(b); };
136                 return ret;
137         }
138
139         public override bool Equals(object o) {
140                 if (!(o is WatchedOutput)) return false;
141                 return this.eq((WatchedOutput)o);
142         }
143         /**
144          * Generates a non-cryptographic 64-bit hash of the WatchedOutput.
145          */
146         public long hash() {
147                 long ret = bindings.WatchedOutput_hash(this.ptr);
148                 GC.KeepAlive(this);
149                 return ret;
150         }
151
152         public override int GetHashCode() {
153                 return (int)this.hash();
154         }
155 }
156 } } }