[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / UpdateFee.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_fee`] message to be sent to or received from a peer
11  * 
12  * [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
13  */
14 public class UpdateFee : CommonBase {
15         internal UpdateFee(object _dummy, long ptr) : base(ptr) { }
16         ~UpdateFee() {
17                 if (ptr != 0) { bindings.UpdateFee_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public ChannelId get_channel_id() {
24                 long ret = bindings.UpdateFee_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.UpdateFee_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          * Fee rate per 1000-weight of the transaction
44          */
45         public int get_feerate_per_kw() {
46                 int ret = bindings.UpdateFee_get_feerate_per_kw(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * Fee rate per 1000-weight of the transaction
53          */
54         public void set_feerate_per_kw(int val) {
55                 bindings.UpdateFee_set_feerate_per_kw(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * Constructs a new UpdateFee given each field
62          */
63         public static UpdateFee of(org.ldk.structs.ChannelId channel_id_arg, int feerate_per_kw_arg) {
64                 long ret = bindings.UpdateFee_new(channel_id_arg.ptr, feerate_per_kw_arg);
65                 GC.KeepAlive(channel_id_arg);
66                 GC.KeepAlive(feerate_per_kw_arg);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
71                 return ret_hu_conv;
72         }
73
74         internal long clone_ptr() {
75                 long ret = bindings.UpdateFee_clone_ptr(this.ptr);
76                 GC.KeepAlive(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the UpdateFee
82          */
83         public UpdateFee clone() {
84                 long ret = bindings.UpdateFee_clone(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Generates a non-cryptographic 64-bit hash of the UpdateFee.
94          */
95         public long hash() {
96                 long ret = bindings.UpdateFee_hash(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         public override int GetHashCode() {
102                 return (int)this.hash();
103         }
104         /**
105          * Checks if two UpdateFees contain equal inner contents.
106          * This ignores pointers and is_owned flags and looks at the values in fields.
107          * Two objects with NULL inner values will be considered "equal" here.
108          */
109         public bool eq(org.ldk.structs.UpdateFee b) {
110                 bool ret = bindings.UpdateFee_eq(this.ptr, b.ptr);
111                 GC.KeepAlive(this);
112                 GC.KeepAlive(b);
113                 if (this != null) { this.ptrs_to.AddLast(b); };
114                 return ret;
115         }
116
117         public override bool Equals(object o) {
118                 if (!(o is UpdateFee)) return false;
119                 return this.eq((UpdateFee)o);
120         }
121         /**
122          * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
123          */
124         public byte[] write() {
125                 long ret = bindings.UpdateFee_write(this.ptr);
126                 GC.KeepAlive(this);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
129                 return ret_conv;
130         }
131
132         /**
133          * Read a UpdateFee from a byte array, created by UpdateFee_write
134          */
135         public static Result_UpdateFeeDecodeErrorZ read(byte[] ser) {
136                 long ret = bindings.UpdateFee_read(InternalUtils.encodeUint8Array(ser));
137                 GC.KeepAlive(ser);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);
140                 return ret_hu_conv;
141         }
142
143 }
144 } } }