315e1b622d8c58ffabd9c640459fd2a834bc229d
[ldk-java] / c_sharp / src / org / ldk / structs / BigSize.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  * Lightning TLV uses a custom variable-length integer called BigSize. It is similar to Bitcoin's
11  * variable-length integers except that it is serialized in big-endian instead of little-endian.
12  * 
13  * Like Bitcoin's variable-length integer, it exhibits ambiguity in that certain values can be
14  * encoded in several different ways, which we must check for at deserialization-time. Thus, if
15  * you're looking for an example of a variable-length integer to use for your own project, move
16  * along, this is a rather poor design.
17  */
18 public class BigSize : CommonBase {
19         internal BigSize(object _dummy, long ptr) : base(ptr) { }
20         ~BigSize() {
21                 if (ptr != 0) { bindings.BigSize_free(ptr); }
22         }
23
24         public long get_a() {
25                 long ret = bindings.BigSize_get_a(this.ptr);
26                 GC.KeepAlive(this);
27                 return ret;
28         }
29
30         public void set_a(long val) {
31                 bindings.BigSize_set_a(this.ptr, val);
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * Constructs a new BigSize given each field
38          */
39         public static BigSize of(long a_arg) {
40                 long ret = bindings.BigSize_new(a_arg);
41                 GC.KeepAlive(a_arg);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 org.ldk.structs.BigSize ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BigSize(null, ret); }
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
45                 return ret_hu_conv;
46         }
47
48 }
49 } } }