[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / UpdateFulfillHTLC.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  * An [`update_fulfill_htlc`] message to be sent to or received from a peer.
11  * 
12  * [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
13  */
14 public class UpdateFulfillHTLC : CommonBase {
15         internal UpdateFulfillHTLC(object _dummy, long ptr) : base(ptr) { }
16         ~UpdateFulfillHTLC() {
17                 if (ptr != 0) { bindings.UpdateFulfillHTLC_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
28                 return ret_conv;
29         }
30
31         /**
32          * The channel ID
33          */
34         public void set_channel_id(byte[] val) {
35                 bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * The HTLC ID
42          */
43         public long get_htlc_id() {
44                 long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * The HTLC ID
51          */
52         public void set_htlc_id(long val) {
53                 bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * The pre-image of the payment hash, allowing HTLC redemption
60          */
61         public byte[] get_payment_preimage() {
62                 long ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
63                 GC.KeepAlive(this);
64                 if (ret >= 0 && ret <= 4096) { return null; }
65                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
66                 return ret_conv;
67         }
68
69         /**
70          * The pre-image of the payment hash, allowing HTLC redemption
71          */
72         public void set_payment_preimage(byte[] val) {
73                 bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * Constructs a new UpdateFulfillHTLC given each field
80          */
81         public static UpdateFulfillHTLC of(byte[] channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) {
82                 long ret = bindings.UpdateFulfillHTLC_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), htlc_id_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage_arg, 32)));
83                 GC.KeepAlive(channel_id_arg);
84                 GC.KeepAlive(htlc_id_arg);
85                 GC.KeepAlive(payment_preimage_arg);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
89                 return ret_hu_conv;
90         }
91
92         internal long clone_ptr() {
93                 long ret = bindings.UpdateFulfillHTLC_clone_ptr(this.ptr);
94                 GC.KeepAlive(this);
95                 return ret;
96         }
97
98         /**
99          * Creates a copy of the UpdateFulfillHTLC
100          */
101         public UpdateFulfillHTLC clone() {
102                 long ret = bindings.UpdateFulfillHTLC_clone(this.ptr);
103                 GC.KeepAlive(this);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
107                 return ret_hu_conv;
108         }
109
110         /**
111          * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
112          */
113         public long hash() {
114                 long ret = bindings.UpdateFulfillHTLC_hash(this.ptr);
115                 GC.KeepAlive(this);
116                 return ret;
117         }
118
119         public override int GetHashCode() {
120                 return (int)this.hash();
121         }
122         /**
123          * Checks if two UpdateFulfillHTLCs contain equal inner contents.
124          * This ignores pointers and is_owned flags and looks at the values in fields.
125          * Two objects with NULL inner values will be considered "equal" here.
126          */
127         public bool eq(org.ldk.structs.UpdateFulfillHTLC b) {
128                 bool ret = bindings.UpdateFulfillHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
129                 GC.KeepAlive(this);
130                 GC.KeepAlive(b);
131                 if (this != null) { this.ptrs_to.AddLast(b); };
132                 return ret;
133         }
134
135         public override bool Equals(object o) {
136                 if (!(o is UpdateFulfillHTLC)) return false;
137                 return this.eq((UpdateFulfillHTLC)o);
138         }
139         /**
140          * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
141          */
142         public byte[] write() {
143                 long ret = bindings.UpdateFulfillHTLC_write(this.ptr);
144                 GC.KeepAlive(this);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
147                 return ret_conv;
148         }
149
150         /**
151          * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
152          */
153         public static Result_UpdateFulfillHTLCDecodeErrorZ read(byte[] ser) {
154                 long ret = bindings.UpdateFulfillHTLC_read(InternalUtils.encodeUint8Array(ser));
155                 GC.KeepAlive(ser);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
158                 return ret_hu_conv;
159         }
160
161 }
162 } } }