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