[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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 ChannelId 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                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The channel ID
34          */
35         public void set_channel_id(org.ldk.structs.ChannelId val) {
36                 bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The HTLC ID
44          */
45         public long get_htlc_id() {
46                 long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * The HTLC ID
53          */
54         public void set_htlc_id(long val) {
55                 bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The pre-image of the payment hash, allowing HTLC redemption
62          */
63         public byte[] get_payment_preimage() {
64                 long ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
65                 GC.KeepAlive(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
68                 return ret_conv;
69         }
70
71         /**
72          * The pre-image of the payment hash, allowing HTLC redemption
73          */
74         public void set_payment_preimage(byte[] val) {
75                 bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * Constructs a new UpdateFulfillHTLC given each field
82          */
83         public static UpdateFulfillHTLC of(org.ldk.structs.ChannelId channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) {
84                 long ret = bindings.UpdateFulfillHTLC_new(channel_id_arg.ptr, htlc_id_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage_arg, 32)));
85                 GC.KeepAlive(channel_id_arg);
86                 GC.KeepAlive(htlc_id_arg);
87                 GC.KeepAlive(payment_preimage_arg);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
92                 return ret_hu_conv;
93         }
94
95         internal long clone_ptr() {
96                 long ret = bindings.UpdateFulfillHTLC_clone_ptr(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         /**
102          * Creates a copy of the UpdateFulfillHTLC
103          */
104         public UpdateFulfillHTLC clone() {
105                 long ret = bindings.UpdateFulfillHTLC_clone(this.ptr);
106                 GC.KeepAlive(this);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
115          */
116         public long hash() {
117                 long ret = bindings.UpdateFulfillHTLC_hash(this.ptr);
118                 GC.KeepAlive(this);
119                 return ret;
120         }
121
122         public override int GetHashCode() {
123                 return (int)this.hash();
124         }
125         /**
126          * Checks if two UpdateFulfillHTLCs 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.UpdateFulfillHTLC b) {
131                 bool ret = bindings.UpdateFulfillHTLC_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 UpdateFulfillHTLC)) return false;
140                 return this.eq((UpdateFulfillHTLC)o);
141         }
142         /**
143          * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
144          */
145         public byte[] write() {
146                 long ret = bindings.UpdateFulfillHTLC_write(this.ptr);
147                 GC.KeepAlive(this);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
150                 return ret_conv;
151         }
152
153         /**
154          * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
155          */
156         public static Result_UpdateFulfillHTLCDecodeErrorZ read(byte[] ser) {
157                 long ret = bindings.UpdateFulfillHTLC_read(InternalUtils.encodeUint8Array(ser));
158                 GC.KeepAlive(ser);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);
161                 return ret_hu_conv;
162         }
163
164 }
165 } } }