c90ea37c07a600799a0cdc235fb9f2378ed5c10e
[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 byte[] 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                 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.UpdateFee_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          * Fee rate per 1000-weight of the transaction
42          */
43         public int get_feerate_per_kw() {
44                 int ret = bindings.UpdateFee_get_feerate_per_kw(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * Fee rate per 1000-weight of the transaction
51          */
52         public void set_feerate_per_kw(int val) {
53                 bindings.UpdateFee_set_feerate_per_kw(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * Constructs a new UpdateFee given each field
60          */
61         public static UpdateFee of(byte[] channel_id_arg, int feerate_per_kw_arg) {
62                 long ret = bindings.UpdateFee_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), feerate_per_kw_arg);
63                 GC.KeepAlive(channel_id_arg);
64                 GC.KeepAlive(feerate_per_kw_arg);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
68                 return ret_hu_conv;
69         }
70
71         internal long clone_ptr() {
72                 long ret = bindings.UpdateFee_clone_ptr(this.ptr);
73                 GC.KeepAlive(this);
74                 return ret;
75         }
76
77         /**
78          * Creates a copy of the UpdateFee
79          */
80         public UpdateFee clone() {
81                 long ret = bindings.UpdateFee_clone(this.ptr);
82                 GC.KeepAlive(this);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Checks if two UpdateFees contain equal inner contents.
91          * This ignores pointers and is_owned flags and looks at the values in fields.
92          * Two objects with NULL inner values will be considered "equal" here.
93          */
94         public bool eq(org.ldk.structs.UpdateFee b) {
95                 bool ret = bindings.UpdateFee_eq(this.ptr, b == null ? 0 : b.ptr);
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(b);
98                 if (this != null) { this.ptrs_to.AddLast(b); };
99                 return ret;
100         }
101
102         public override bool Equals(object o) {
103                 if (!(o is UpdateFee)) return false;
104                 return this.eq((UpdateFee)o);
105         }
106         /**
107          * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
108          */
109         public byte[] write() {
110                 long ret = bindings.UpdateFee_write(this.ptr);
111                 GC.KeepAlive(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
114                 return ret_conv;
115         }
116
117         /**
118          * Read a UpdateFee from a byte array, created by UpdateFee_write
119          */
120         public static Result_UpdateFeeDecodeErrorZ read(byte[] ser) {
121                 long ret = bindings.UpdateFee_read(InternalUtils.encodeUint8Array(ser));
122                 GC.KeepAlive(ser);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);
125                 return ret_hu_conv;
126         }
127
128 }
129 } } }