[C#] Run tests against release library in determinism CI run
[ldk-java] / c_sharp / src / org / ldk / structs / BumpTransactionEvent.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  * Represents the different types of transactions, originating from LDK, to be bumped.
10  */
11 public class BumpTransactionEvent : CommonBase {
12         protected BumpTransactionEvent(object _dummy, long ptr) : base(ptr) { }
13         ~BumpTransactionEvent() {
14                 if (ptr != 0) { bindings.BumpTransactionEvent_free(ptr); }
15         }
16
17         internal static BumpTransactionEvent constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKBumpTransactionEvent_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new BumpTransactionEvent_ChannelClose(ptr);
21                         case 1: return new BumpTransactionEvent_HTLCResolution(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A BumpTransactionEvent of type ChannelClose */
28         public class BumpTransactionEvent_ChannelClose : BumpTransactionEvent {
29                 /**
30                  * The `channel_id` of the channel which has been closed.
31                  */
32                 public ChannelId channel_id;
33                 /**
34                  * Counterparty in the closed channel.
35                  */
36                 public byte[] counterparty_node_id;
37                 /**
38                  * The unique identifier for the claim of the anchor output in the commitment transaction.
39                  * 
40                  * The identifier must map to the set of external UTXOs assigned to the claim, such that
41                  * they can be reused when a new claim with the same identifier needs to be made, resulting
42                  * in a fee-bumping attempt.
43                  */
44                 public byte[] claim_id;
45                 /**
46                  * The target feerate that the transaction package, which consists of the commitment
47                  * transaction and the to-be-crafted child anchor transaction, must meet.
48                  */
49                 public int package_target_feerate_sat_per_1000_weight;
50                 /**
51                  * The channel's commitment transaction to bump the fee of. This transaction should be
52                  * broadcast along with the anchor transaction constructed as a result of consuming this
53                  * event.
54                  */
55                 public byte[] commitment_tx;
56                 /**
57                  * The absolute fee in satoshis of the commitment transaction. This can be used along the
58                  * with weight of the commitment transaction to determine its feerate.
59                  */
60                 public long commitment_tx_fee_satoshis;
61                 /**
62                  * The descriptor to sign the anchor input of the anchor transaction constructed as a
63                  * result of consuming this event.
64                  */
65                 public AnchorDescriptor anchor_descriptor;
66                 /**
67                  * The set of pending HTLCs on the commitment transaction that need to be resolved once the
68                  * commitment transaction confirms.
69                  */
70                 public HTLCOutputInCommitment[] pending_htlcs;
71                 internal BumpTransactionEvent_ChannelClose(long ptr) : base(null, ptr) {
72                         long channel_id = bindings.LDKBumpTransactionEvent_ChannelClose_get_channel_id(ptr);
73                         org.ldk.structs.ChannelId channel_id_hu_conv = null; if (channel_id < 0 || channel_id > 4096) { channel_id_hu_conv = new org.ldk.structs.ChannelId(null, channel_id); }
74                         if (channel_id_hu_conv != null) { channel_id_hu_conv.ptrs_to.AddLast(this); };
75                         this.channel_id = channel_id_hu_conv;
76                         long counterparty_node_id = bindings.LDKBumpTransactionEvent_ChannelClose_get_counterparty_node_id(ptr);
77                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
78                         this.counterparty_node_id = counterparty_node_id_conv;
79                         long claim_id = bindings.LDKBumpTransactionEvent_ChannelClose_get_claim_id(ptr);
80                         byte[] claim_id_conv = InternalUtils.decodeUint8Array(claim_id);
81                         this.claim_id = claim_id_conv;
82                         this.package_target_feerate_sat_per_1000_weight = bindings.LDKBumpTransactionEvent_ChannelClose_get_package_target_feerate_sat_per_1000_weight(ptr);
83                         long commitment_tx = bindings.LDKBumpTransactionEvent_ChannelClose_get_commitment_tx(ptr);
84                         byte[] commitment_tx_conv = InternalUtils.decodeUint8Array(commitment_tx);
85                         this.commitment_tx = commitment_tx_conv;
86                         this.commitment_tx_fee_satoshis = bindings.LDKBumpTransactionEvent_ChannelClose_get_commitment_tx_fee_satoshis(ptr);
87                         long anchor_descriptor = bindings.LDKBumpTransactionEvent_ChannelClose_get_anchor_descriptor(ptr);
88                         org.ldk.structs.AnchorDescriptor anchor_descriptor_hu_conv = null; if (anchor_descriptor < 0 || anchor_descriptor > 4096) { anchor_descriptor_hu_conv = new org.ldk.structs.AnchorDescriptor(null, anchor_descriptor); }
89                         if (anchor_descriptor_hu_conv != null) { anchor_descriptor_hu_conv.ptrs_to.AddLast(this); };
90                         this.anchor_descriptor = anchor_descriptor_hu_conv;
91                         long pending_htlcs = bindings.LDKBumpTransactionEvent_ChannelClose_get_pending_htlcs(ptr);
92                         int pending_htlcs_conv_24_len = InternalUtils.getArrayLength(pending_htlcs);
93                         HTLCOutputInCommitment[] pending_htlcs_conv_24_arr = new HTLCOutputInCommitment[pending_htlcs_conv_24_len];
94                         for (int y = 0; y < pending_htlcs_conv_24_len; y++) {
95                                 long pending_htlcs_conv_24 = InternalUtils.getU64ArrayElem(pending_htlcs, y);
96                                 org.ldk.structs.HTLCOutputInCommitment pending_htlcs_conv_24_hu_conv = null; if (pending_htlcs_conv_24 < 0 || pending_htlcs_conv_24 > 4096) { pending_htlcs_conv_24_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, pending_htlcs_conv_24); }
97                                 if (pending_htlcs_conv_24_hu_conv != null) { pending_htlcs_conv_24_hu_conv.ptrs_to.AddLast(this); };
98                                 pending_htlcs_conv_24_arr[y] = pending_htlcs_conv_24_hu_conv;
99                         }
100                         bindings.free_buffer(pending_htlcs);
101                         this.pending_htlcs = pending_htlcs_conv_24_arr;
102                 }
103         }
104         /** A BumpTransactionEvent of type HTLCResolution */
105         public class BumpTransactionEvent_HTLCResolution : BumpTransactionEvent {
106                 /**
107                  * The `channel_id` of the channel which has been closed.
108                  */
109                 public ChannelId channel_id;
110                 /**
111                  * Counterparty in the closed channel.
112                  */
113                 public byte[] counterparty_node_id;
114                 /**
115                  * The unique identifier for the claim of the HTLCs in the confirmed commitment
116                  * transaction.
117                  * 
118                  * The identifier must map to the set of external UTXOs assigned to the claim, such that
119                  * they can be reused when a new claim with the same identifier needs to be made, resulting
120                  * in a fee-bumping attempt.
121                  */
122                 public byte[] claim_id;
123                 /**
124                  * The target feerate that the resulting HTLC transaction must meet.
125                  */
126                 public int target_feerate_sat_per_1000_weight;
127                 /**
128                  * The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably
129                  * by the same transaction.
130                  */
131                 public HTLCDescriptor[] htlc_descriptors;
132                 /**
133                  * The locktime required for the resulting HTLC transaction.
134                  */
135                 public int tx_lock_time;
136                 internal BumpTransactionEvent_HTLCResolution(long ptr) : base(null, ptr) {
137                         long channel_id = bindings.LDKBumpTransactionEvent_HTLCResolution_get_channel_id(ptr);
138                         org.ldk.structs.ChannelId channel_id_hu_conv = null; if (channel_id < 0 || channel_id > 4096) { channel_id_hu_conv = new org.ldk.structs.ChannelId(null, channel_id); }
139                         if (channel_id_hu_conv != null) { channel_id_hu_conv.ptrs_to.AddLast(this); };
140                         this.channel_id = channel_id_hu_conv;
141                         long counterparty_node_id = bindings.LDKBumpTransactionEvent_HTLCResolution_get_counterparty_node_id(ptr);
142                         byte[] counterparty_node_id_conv = InternalUtils.decodeUint8Array(counterparty_node_id);
143                         this.counterparty_node_id = counterparty_node_id_conv;
144                         long claim_id = bindings.LDKBumpTransactionEvent_HTLCResolution_get_claim_id(ptr);
145                         byte[] claim_id_conv = InternalUtils.decodeUint8Array(claim_id);
146                         this.claim_id = claim_id_conv;
147                         this.target_feerate_sat_per_1000_weight = bindings.LDKBumpTransactionEvent_HTLCResolution_get_target_feerate_sat_per_1000_weight(ptr);
148                         long htlc_descriptors = bindings.LDKBumpTransactionEvent_HTLCResolution_get_htlc_descriptors(ptr);
149                         int htlc_descriptors_conv_16_len = InternalUtils.getArrayLength(htlc_descriptors);
150                         HTLCDescriptor[] htlc_descriptors_conv_16_arr = new HTLCDescriptor[htlc_descriptors_conv_16_len];
151                         for (int q = 0; q < htlc_descriptors_conv_16_len; q++) {
152                                 long htlc_descriptors_conv_16 = InternalUtils.getU64ArrayElem(htlc_descriptors, q);
153                                 org.ldk.structs.HTLCDescriptor htlc_descriptors_conv_16_hu_conv = null; if (htlc_descriptors_conv_16 < 0 || htlc_descriptors_conv_16 > 4096) { htlc_descriptors_conv_16_hu_conv = new org.ldk.structs.HTLCDescriptor(null, htlc_descriptors_conv_16); }
154                                 if (htlc_descriptors_conv_16_hu_conv != null) { htlc_descriptors_conv_16_hu_conv.ptrs_to.AddLast(this); };
155                                 htlc_descriptors_conv_16_arr[q] = htlc_descriptors_conv_16_hu_conv;
156                         }
157                         bindings.free_buffer(htlc_descriptors);
158                         this.htlc_descriptors = htlc_descriptors_conv_16_arr;
159                         this.tx_lock_time = bindings.LDKBumpTransactionEvent_HTLCResolution_get_tx_lock_time(ptr);
160                 }
161         }
162         internal long clone_ptr() {
163                 long ret = bindings.BumpTransactionEvent_clone_ptr(this.ptr);
164                 GC.KeepAlive(this);
165                 return ret;
166         }
167
168         /**
169          * Creates a copy of the BumpTransactionEvent
170          */
171         public BumpTransactionEvent clone() {
172                 long ret = bindings.BumpTransactionEvent_clone(this.ptr);
173                 GC.KeepAlive(this);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 org.ldk.structs.BumpTransactionEvent ret_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(ret);
176                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent
182          */
183         public static BumpTransactionEvent channel_close(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id, byte[] claim_id, int package_target_feerate_sat_per_1000_weight, byte[] commitment_tx, long commitment_tx_fee_satoshis, org.ldk.structs.AnchorDescriptor anchor_descriptor, HTLCOutputInCommitment[] pending_htlcs) {
184                 long ret = bindings.BumpTransactionEvent_channel_close(channel_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(claim_id, 32)), package_target_feerate_sat_per_1000_weight, InternalUtils.encodeUint8Array(commitment_tx), commitment_tx_fee_satoshis, anchor_descriptor.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(pending_htlcs, pending_htlcs_conv_24 => pending_htlcs_conv_24.ptr)));
185                 GC.KeepAlive(channel_id);
186                 GC.KeepAlive(counterparty_node_id);
187                 GC.KeepAlive(claim_id);
188                 GC.KeepAlive(package_target_feerate_sat_per_1000_weight);
189                 GC.KeepAlive(commitment_tx);
190                 GC.KeepAlive(commitment_tx_fee_satoshis);
191                 GC.KeepAlive(anchor_descriptor);
192                 GC.KeepAlive(pending_htlcs);
193                 if (ret >= 0 && ret <= 4096) { return null; }
194                 org.ldk.structs.BumpTransactionEvent ret_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(ret);
195                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
196                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id); };
197                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(anchor_descriptor); };
198                 foreach (HTLCOutputInCommitment pending_htlcs_conv_24 in pending_htlcs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(pending_htlcs_conv_24); }; };
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent
204          */
205         public static BumpTransactionEvent htlcresolution(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id, byte[] claim_id, int target_feerate_sat_per_1000_weight, HTLCDescriptor[] htlc_descriptors, int tx_lock_time) {
206                 long ret = bindings.BumpTransactionEvent_htlcresolution(channel_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(claim_id, 32)), target_feerate_sat_per_1000_weight, InternalUtils.encodeUint64Array(InternalUtils.mapArray(htlc_descriptors, htlc_descriptors_conv_16 => htlc_descriptors_conv_16.ptr)), tx_lock_time);
207                 GC.KeepAlive(channel_id);
208                 GC.KeepAlive(counterparty_node_id);
209                 GC.KeepAlive(claim_id);
210                 GC.KeepAlive(target_feerate_sat_per_1000_weight);
211                 GC.KeepAlive(htlc_descriptors);
212                 GC.KeepAlive(tx_lock_time);
213                 if (ret >= 0 && ret <= 4096) { return null; }
214                 org.ldk.structs.BumpTransactionEvent ret_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(ret);
215                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
216                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id); };
217                 foreach (HTLCDescriptor htlc_descriptors_conv_16 in htlc_descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlc_descriptors_conv_16); }; };
218                 return ret_hu_conv;
219         }
220
221         /**
222          * Checks if two BumpTransactionEvents contain equal inner contents.
223          * This ignores pointers and is_owned flags and looks at the values in fields.
224          */
225         public bool eq(org.ldk.structs.BumpTransactionEvent b) {
226                 bool ret = bindings.BumpTransactionEvent_eq(this.ptr, b.ptr);
227                 GC.KeepAlive(this);
228                 GC.KeepAlive(b);
229                 return ret;
230         }
231
232         public override bool Equals(object o) {
233                 if (!(o is BumpTransactionEvent)) return false;
234                 return this.eq((BumpTransactionEvent)o);
235         }
236 }
237 } } }