78ff71d344ddee8b5c2ed7e5199eb191b5cd3ec9
[ldk-java] / c_sharp / src / org / ldk / structs / UpdateFailHTLC.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_fail_htlc`] message to be sent to or received from a peer.
11  * 
12  * [`update_fail_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 UpdateFailHTLC : CommonBase {
15         internal UpdateFailHTLC(object _dummy, long ptr) : base(ptr) { }
16         ~UpdateFailHTLC() {
17                 if (ptr != 0) { bindings.UpdateFailHTLC_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.UpdateFailHTLC_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.UpdateFailHTLC_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.UpdateFailHTLC_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.UpdateFailHTLC_set_htlc_id(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         internal long clone_ptr() {
59                 long ret = bindings.UpdateFailHTLC_clone_ptr(this.ptr);
60                 GC.KeepAlive(this);
61                 return ret;
62         }
63
64         /**
65          * Creates a copy of the UpdateFailHTLC
66          */
67         public UpdateFailHTLC clone() {
68                 long ret = bindings.UpdateFailHTLC_clone(this.ptr);
69                 GC.KeepAlive(this);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.UpdateFailHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, ret); }
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Checks if two UpdateFailHTLCs contain equal inner contents.
78          * This ignores pointers and is_owned flags and looks at the values in fields.
79          * Two objects with NULL inner values will be considered "equal" here.
80          */
81         public bool eq(org.ldk.structs.UpdateFailHTLC b) {
82                 bool ret = bindings.UpdateFailHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
83                 GC.KeepAlive(this);
84                 GC.KeepAlive(b);
85                 if (this != null) { this.ptrs_to.AddLast(b); };
86                 return ret;
87         }
88
89         public override bool Equals(object o) {
90                 if (!(o is UpdateFailHTLC)) return false;
91                 return this.eq((UpdateFailHTLC)o);
92         }
93         /**
94          * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
95          */
96         public byte[] write() {
97                 long ret = bindings.UpdateFailHTLC_write(this.ptr);
98                 GC.KeepAlive(this);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
101                 return ret_conv;
102         }
103
104         /**
105          * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
106          */
107         public static Result_UpdateFailHTLCDecodeErrorZ read(byte[] ser) {
108                 long ret = bindings.UpdateFailHTLC_read(InternalUtils.encodeUint8Array(ser));
109                 GC.KeepAlive(ser);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 Result_UpdateFailHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailHTLCDecodeErrorZ.constr_from_ptr(ret);
112                 return ret_hu_conv;
113         }
114
115 }
116 } } }