6 namespace org { namespace ldk { namespace structs {
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.
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.
18 public class BigSize : CommonBase {
19 internal BigSize(object _dummy, long ptr) : base(ptr) { }
21 if (ptr != 0) { bindings.BigSize_free(ptr); }
25 long ret = bindings.BigSize_get_a(this.ptr);
30 public void set_a(long val) {
31 bindings.BigSize_set_a(this.ptr, val);
37 * Constructs a new BigSize given each field
39 public static BigSize of(long a_arg) {
40 long ret = bindings.BigSize_new(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); };
48 internal long clone_ptr() {
49 long ret = bindings.BigSize_clone_ptr(this.ptr);
55 * Creates a copy of the BigSize
57 public BigSize clone() {
58 long ret = bindings.BigSize_clone(this.ptr);
60 if (ret >= 0 && ret <= 4096) { return null; }
61 org.ldk.structs.BigSize ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BigSize(null, ret); }
62 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
67 * Generates a non-cryptographic 64-bit hash of the BigSize.
70 long ret = bindings.BigSize_hash(this.ptr);
75 public override int GetHashCode() {
76 return (int)this.hash();
79 * Checks if two BigSizes contain equal inner contents.
80 * This ignores pointers and is_owned flags and looks at the values in fields.
81 * Two objects with NULL inner values will be considered "equal" here.
83 public bool eq(org.ldk.structs.BigSize b) {
84 bool ret = bindings.BigSize_eq(this.ptr, b.ptr);
87 if (this != null) { this.ptrs_to.AddLast(b); };
91 public override bool Equals(object o) {
92 if (!(o is BigSize)) return false;
93 return this.eq((BigSize)o);
96 * Serialize the BigSize object into a byte array which can be read by BigSize_read
98 public byte[] write() {
99 long ret = bindings.BigSize_write(this.ptr);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
107 * Read a BigSize from a byte array, created by BigSize_write
109 public static Result_BigSizeDecodeErrorZ read(byte[] ser) {
110 long ret = bindings.BigSize_read(InternalUtils.encodeUint8Array(ser));
112 if (ret >= 0 && ret <= 4096) { return null; }
113 Result_BigSizeDecodeErrorZ ret_hu_conv = Result_BigSizeDecodeErrorZ.constr_from_ptr(ret);