42056273bc156666411a991e290d1d3ab15d8d11
[ldk-java] / c_sharp / src / org / ldk / structs / UpdateAddHTLC.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_add_htlc message to be sent or received from a peer
11  */
12 public class UpdateAddHTLC : CommonBase {
13         internal UpdateAddHTLC(object _dummy, long ptr) : base(ptr) { }
14         ~UpdateAddHTLC() {
15                 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
16         }
17
18         /**
19          * The channel ID
20          */
21         public byte[] get_channel_id() {
22                 byte[] ret = bindings.UpdateAddHTLC_get_channel_id(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * The channel ID
29          */
30         public void set_channel_id(byte[] val) {
31                 bindings.UpdateAddHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * The HTLC ID
38          */
39         public long get_htlc_id() {
40                 long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
41                 GC.KeepAlive(this);
42                 return ret;
43         }
44
45         /**
46          * The HTLC ID
47          */
48         public void set_htlc_id(long val) {
49                 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
50                 GC.KeepAlive(this);
51                 GC.KeepAlive(val);
52         }
53
54         /**
55          * The HTLC value in milli-satoshi
56          */
57         public long get_amount_msat() {
58                 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
59                 GC.KeepAlive(this);
60                 return ret;
61         }
62
63         /**
64          * The HTLC value in milli-satoshi
65          */
66         public void set_amount_msat(long val) {
67                 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
68                 GC.KeepAlive(this);
69                 GC.KeepAlive(val);
70         }
71
72         /**
73          * The payment hash, the pre-image of which controls HTLC redemption
74          */
75         public byte[] get_payment_hash() {
76                 byte[] ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
77                 GC.KeepAlive(this);
78                 return ret;
79         }
80
81         /**
82          * The payment hash, the pre-image of which controls HTLC redemption
83          */
84         public void set_payment_hash(byte[] val) {
85                 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(val);
88         }
89
90         /**
91          * The expiry height of the HTLC
92          */
93         public int get_cltv_expiry() {
94                 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
95                 GC.KeepAlive(this);
96                 return ret;
97         }
98
99         /**
100          * The expiry height of the HTLC
101          */
102         public void set_cltv_expiry(int val) {
103                 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
104                 GC.KeepAlive(this);
105                 GC.KeepAlive(val);
106         }
107
108         internal long clone_ptr() {
109                 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
110                 GC.KeepAlive(this);
111                 return ret;
112         }
113
114         /**
115          * Creates a copy of the UpdateAddHTLC
116          */
117         public UpdateAddHTLC clone() {
118                 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
119                 GC.KeepAlive(this);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Checks if two UpdateAddHTLCs contain equal inner contents.
128          * This ignores pointers and is_owned flags and looks at the values in fields.
129          * Two objects with NULL inner values will be considered "equal" here.
130          */
131         public bool eq(org.ldk.structs.UpdateAddHTLC b) {
132                 bool ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
133                 GC.KeepAlive(this);
134                 GC.KeepAlive(b);
135                 if (this != null) { this.ptrs_to.AddLast(b); };
136                 return ret;
137         }
138
139         public override bool Equals(object o) {
140                 if (!(o is UpdateAddHTLC)) return false;
141                 return this.eq((UpdateAddHTLC)o);
142         }
143         /**
144          * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
145          */
146         public byte[] write() {
147                 byte[] ret = bindings.UpdateAddHTLC_write(this.ptr);
148                 GC.KeepAlive(this);
149                 return ret;
150         }
151
152         /**
153          * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
154          */
155         public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
156                 long ret = bindings.UpdateAddHTLC_read(ser);
157                 GC.KeepAlive(ser);
158                 if (ret >= 0 && ret <= 4096) { return null; }
159                 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
160                 return ret_hu_conv;
161         }
162
163 }
164 } } }