[C#] Update auto-generated C# bindings
[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 unique identifier for the claim of the anchor output in the commitment transaction.
31                  * 
32                  * The identifier must map to the set of external UTXOs assigned to the claim, such that
33                  * they can be reused when a new claim with the same identifier needs to be made, resulting
34                  * in a fee-bumping attempt.
35                  */
36                 public byte[] claim_id;
37                 /**
38                  * The target feerate that the transaction package, which consists of the commitment
39                  * transaction and the to-be-crafted child anchor transaction, must meet.
40                  */
41                 public int package_target_feerate_sat_per_1000_weight;
42                 /**
43                  * The channel's commitment transaction to bump the fee of. This transaction should be
44                  * broadcast along with the anchor transaction constructed as a result of consuming this
45                  * event.
46                  */
47                 public byte[] commitment_tx;
48                 /**
49                  * The absolute fee in satoshis of the commitment transaction. This can be used along the
50                  * with weight of the commitment transaction to determine its feerate.
51                  */
52                 public long commitment_tx_fee_satoshis;
53                 /**
54                  * The descriptor to sign the anchor input of the anchor transaction constructed as a
55                  * result of consuming this event.
56                  */
57                 public AnchorDescriptor anchor_descriptor;
58                 /**
59                  * The set of pending HTLCs on the commitment transaction that need to be resolved once the
60                  * commitment transaction confirms.
61                  */
62                 public HTLCOutputInCommitment[] pending_htlcs;
63                 internal BumpTransactionEvent_ChannelClose(long ptr) : base(null, ptr) {
64                         long claim_id = bindings.LDKBumpTransactionEvent_ChannelClose_get_claim_id(ptr);
65                         byte[] claim_id_conv = InternalUtils.decodeUint8Array(claim_id);
66                         this.claim_id = claim_id_conv;
67                         this.package_target_feerate_sat_per_1000_weight = bindings.LDKBumpTransactionEvent_ChannelClose_get_package_target_feerate_sat_per_1000_weight(ptr);
68                         long commitment_tx = bindings.LDKBumpTransactionEvent_ChannelClose_get_commitment_tx(ptr);
69                         byte[] commitment_tx_conv = InternalUtils.decodeUint8Array(commitment_tx);
70                         this.commitment_tx = commitment_tx_conv;
71                         this.commitment_tx_fee_satoshis = bindings.LDKBumpTransactionEvent_ChannelClose_get_commitment_tx_fee_satoshis(ptr);
72                         long anchor_descriptor = bindings.LDKBumpTransactionEvent_ChannelClose_get_anchor_descriptor(ptr);
73                         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); }
74                         if (anchor_descriptor_hu_conv != null) { anchor_descriptor_hu_conv.ptrs_to.AddLast(this); };
75                         this.anchor_descriptor = anchor_descriptor_hu_conv;
76                         long pending_htlcs = bindings.LDKBumpTransactionEvent_ChannelClose_get_pending_htlcs(ptr);
77                         int pending_htlcs_conv_24_len = InternalUtils.getArrayLength(pending_htlcs);
78                         HTLCOutputInCommitment[] pending_htlcs_conv_24_arr = new HTLCOutputInCommitment[pending_htlcs_conv_24_len];
79                         for (int y = 0; y < pending_htlcs_conv_24_len; y++) {
80                                 long pending_htlcs_conv_24 = InternalUtils.getU64ArrayElem(pending_htlcs, y);
81                                 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); }
82                                 if (pending_htlcs_conv_24_hu_conv != null) { pending_htlcs_conv_24_hu_conv.ptrs_to.AddLast(this); };
83                                 pending_htlcs_conv_24_arr[y] = pending_htlcs_conv_24_hu_conv;
84                         }
85                         bindings.free_buffer(pending_htlcs);
86                         this.pending_htlcs = pending_htlcs_conv_24_arr;
87                 }
88         }
89         /** A BumpTransactionEvent of type HTLCResolution */
90         public class BumpTransactionEvent_HTLCResolution : BumpTransactionEvent {
91                 /**
92                  * The unique identifier for the claim of the HTLCs in the confirmed commitment
93                  * transaction.
94                  * 
95                  * The identifier must map to the set of external UTXOs assigned to the claim, such that
96                  * they can be reused when a new claim with the same identifier needs to be made, resulting
97                  * in a fee-bumping attempt.
98                  */
99                 public byte[] claim_id;
100                 /**
101                  * The target feerate that the resulting HTLC transaction must meet.
102                  */
103                 public int target_feerate_sat_per_1000_weight;
104                 /**
105                  * The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably
106                  * by the same transaction.
107                  */
108                 public HTLCDescriptor[] htlc_descriptors;
109                 /**
110                  * The locktime required for the resulting HTLC transaction.
111                  */
112                 public int tx_lock_time;
113                 internal BumpTransactionEvent_HTLCResolution(long ptr) : base(null, ptr) {
114                         long claim_id = bindings.LDKBumpTransactionEvent_HTLCResolution_get_claim_id(ptr);
115                         byte[] claim_id_conv = InternalUtils.decodeUint8Array(claim_id);
116                         this.claim_id = claim_id_conv;
117                         this.target_feerate_sat_per_1000_weight = bindings.LDKBumpTransactionEvent_HTLCResolution_get_target_feerate_sat_per_1000_weight(ptr);
118                         long htlc_descriptors = bindings.LDKBumpTransactionEvent_HTLCResolution_get_htlc_descriptors(ptr);
119                         int htlc_descriptors_conv_16_len = InternalUtils.getArrayLength(htlc_descriptors);
120                         HTLCDescriptor[] htlc_descriptors_conv_16_arr = new HTLCDescriptor[htlc_descriptors_conv_16_len];
121                         for (int q = 0; q < htlc_descriptors_conv_16_len; q++) {
122                                 long htlc_descriptors_conv_16 = InternalUtils.getU64ArrayElem(htlc_descriptors, q);
123                                 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); }
124                                 if (htlc_descriptors_conv_16_hu_conv != null) { htlc_descriptors_conv_16_hu_conv.ptrs_to.AddLast(this); };
125                                 htlc_descriptors_conv_16_arr[q] = htlc_descriptors_conv_16_hu_conv;
126                         }
127                         bindings.free_buffer(htlc_descriptors);
128                         this.htlc_descriptors = htlc_descriptors_conv_16_arr;
129                         this.tx_lock_time = bindings.LDKBumpTransactionEvent_HTLCResolution_get_tx_lock_time(ptr);
130                 }
131         }
132         internal long clone_ptr() {
133                 long ret = bindings.BumpTransactionEvent_clone_ptr(this.ptr);
134                 GC.KeepAlive(this);
135                 return ret;
136         }
137
138         /**
139          * Creates a copy of the BumpTransactionEvent
140          */
141         public BumpTransactionEvent clone() {
142                 long ret = bindings.BumpTransactionEvent_clone(this.ptr);
143                 GC.KeepAlive(this);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 org.ldk.structs.BumpTransactionEvent ret_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(ret);
146                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
147                 return ret_hu_conv;
148         }
149
150         /**
151          * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent
152          */
153         public static BumpTransactionEvent channel_close(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) {
154                 long ret = bindings.BumpTransactionEvent_channel_close(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 == null ? 0 : anchor_descriptor.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(pending_htlcs, pending_htlcs_conv_24 => pending_htlcs_conv_24 == null ? 0 : pending_htlcs_conv_24.ptr)));
155                 GC.KeepAlive(claim_id);
156                 GC.KeepAlive(package_target_feerate_sat_per_1000_weight);
157                 GC.KeepAlive(commitment_tx);
158                 GC.KeepAlive(commitment_tx_fee_satoshis);
159                 GC.KeepAlive(anchor_descriptor);
160                 GC.KeepAlive(pending_htlcs);
161                 if (ret >= 0 && ret <= 4096) { return null; }
162                 org.ldk.structs.BumpTransactionEvent ret_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(ret);
163                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
164                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(anchor_descriptor); };
165                 foreach (HTLCOutputInCommitment pending_htlcs_conv_24 in pending_htlcs) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(pending_htlcs_conv_24); }; };
166                 return ret_hu_conv;
167         }
168
169         /**
170          * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent
171          */
172         public static BumpTransactionEvent htlcresolution(byte[] claim_id, int target_feerate_sat_per_1000_weight, HTLCDescriptor[] htlc_descriptors, int tx_lock_time) {
173                 long ret = bindings.BumpTransactionEvent_htlcresolution(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 == null ? 0 : htlc_descriptors_conv_16.ptr)), tx_lock_time);
174                 GC.KeepAlive(claim_id);
175                 GC.KeepAlive(target_feerate_sat_per_1000_weight);
176                 GC.KeepAlive(htlc_descriptors);
177                 GC.KeepAlive(tx_lock_time);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.BumpTransactionEvent ret_hu_conv = org.ldk.structs.BumpTransactionEvent.constr_from_ptr(ret);
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
181                 foreach (HTLCDescriptor htlc_descriptors_conv_16 in htlc_descriptors) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlc_descriptors_conv_16); }; };
182                 return ret_hu_conv;
183         }
184
185         /**
186          * Checks if two BumpTransactionEvents contain equal inner contents.
187          * This ignores pointers and is_owned flags and looks at the values in fields.
188          */
189         public bool eq(org.ldk.structs.BumpTransactionEvent b) {
190                 bool ret = bindings.BumpTransactionEvent_eq(this.ptr, b == null ? 0 : b.ptr);
191                 GC.KeepAlive(this);
192                 GC.KeepAlive(b);
193                 return ret;
194         }
195
196         public override bool Equals(object o) {
197                 if (!(o is BumpTransactionEvent)) return false;
198                 return this.eq((BumpTransactionEvent)o);
199         }
200 }
201 } } }