afba6556ff15acdd6be1723e36be5dae1872f043
[ldk-java] / c_sharp / src / org / ldk / structs / TransactionU16LenLimited.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  * A wrapper for a `Transaction` which can only be constructed with [`TransactionU16LenLimited::new`]
11  * if the `Transaction`'s consensus-serialized length is <= u16::MAX.
12  * 
13  * Use [`TransactionU16LenLimited::into_transaction`] to convert into the contained `Transaction`.
14  */
15 public class TransactionU16LenLimited : CommonBase {
16         internal TransactionU16LenLimited(object _dummy, long ptr) : base(ptr) { }
17         ~TransactionU16LenLimited() {
18                 if (ptr != 0) { bindings.TransactionU16LenLimited_free(ptr); }
19         }
20
21         internal long clone_ptr() {
22                 long ret = bindings.TransactionU16LenLimited_clone_ptr(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * Creates a copy of the TransactionU16LenLimited
29          */
30         public TransactionU16LenLimited clone() {
31                 long ret = bindings.TransactionU16LenLimited_clone(this.ptr);
32                 GC.KeepAlive(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 org.ldk.structs.TransactionU16LenLimited ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TransactionU16LenLimited(null, ret); }
35                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
36                 return ret_hu_conv;
37         }
38
39         /**
40          * Checks if two TransactionU16LenLimiteds contain equal inner contents.
41          * This ignores pointers and is_owned flags and looks at the values in fields.
42          * Two objects with NULL inner values will be considered "equal" here.
43          */
44         public bool eq(org.ldk.structs.TransactionU16LenLimited b) {
45                 bool ret = bindings.TransactionU16LenLimited_eq(this.ptr, b == null ? 0 : b.ptr);
46                 GC.KeepAlive(this);
47                 GC.KeepAlive(b);
48                 if (this != null) { this.ptrs_to.AddLast(b); };
49                 return ret;
50         }
51
52         public override bool Equals(object o) {
53                 if (!(o is TransactionU16LenLimited)) return false;
54                 return this.eq((TransactionU16LenLimited)o);
55         }
56         /**
57          * Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus-
58          * serialized length is <= u16::MAX.
59          */
60         public static Result_TransactionU16LenLimitedNoneZ of(byte[] transaction) {
61                 long ret = bindings.TransactionU16LenLimited_new(InternalUtils.encodeUint8Array(transaction));
62                 GC.KeepAlive(transaction);
63                 if (ret >= 0 && ret <= 4096) { return null; }
64                 Result_TransactionU16LenLimitedNoneZ ret_hu_conv = Result_TransactionU16LenLimitedNoneZ.constr_from_ptr(ret);
65                 return ret_hu_conv;
66         }
67
68         /**
69          * Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`.
70          */
71         public byte[] into_transaction() {
72                 long ret = bindings.TransactionU16LenLimited_into_transaction(this.ptr);
73                 GC.KeepAlive(this);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
76                 if (this != null) { this.ptrs_to.AddLast(this); };
77                 return ret_conv;
78         }
79
80         /**
81          * Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read
82          */
83         public byte[] write() {
84                 long ret = bindings.TransactionU16LenLimited_write(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
88                 return ret_conv;
89         }
90
91         /**
92          * Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write
93          */
94         public static Result_TransactionU16LenLimitedDecodeErrorZ read(byte[] ser) {
95                 long ret = bindings.TransactionU16LenLimited_read(InternalUtils.encodeUint8Array(ser));
96                 GC.KeepAlive(ser);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 Result_TransactionU16LenLimitedDecodeErrorZ ret_hu_conv = Result_TransactionU16LenLimitedDecodeErrorZ.constr_from_ptr(ret);
99                 return ret_hu_conv;
100         }
101
102 }
103 } } }