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