[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / Amount.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  * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or
10  * another currency.
11  */
12 public class Amount : CommonBase {
13         protected Amount(object _dummy, long ptr) : base(ptr) { }
14         ~Amount() {
15                 if (ptr != 0) { bindings.Amount_free(ptr); }
16         }
17
18         internal static Amount constr_from_ptr(long ptr) {
19                 long raw_ty = bindings.LDKAmount_ty_from_ptr(ptr);
20                 switch (raw_ty) {
21                         case 0: return new Amount_Bitcoin(ptr);
22                         case 1: return new Amount_Currency(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A Amount of type Bitcoin */
29         public class Amount_Bitcoin : Amount {
30                 /**
31                  * The amount in millisatoshi.
32                  */
33                 public long amount_msats;
34                 internal Amount_Bitcoin(long ptr) : base(null, ptr) {
35                         this.amount_msats = bindings.LDKAmount_Bitcoin_get_amount_msats(ptr);
36                 }
37         }
38         /** A Amount of type Currency */
39         public class Amount_Currency : Amount {
40                 /**
41                  * The currency that the amount is denominated in.
42                  */
43                 public byte[] iso4217_code;
44                 /**
45                  * The amount in the currency unit adjusted by the ISO 4712 exponent (e.g., USD cents).
46                  */
47                 public long amount;
48                 internal Amount_Currency(long ptr) : base(null, ptr) {
49                         long iso4217_code = bindings.LDKAmount_Currency_get_iso4217_code(ptr);
50                         byte[] iso4217_code_conv = InternalUtils.decodeUint8Array(iso4217_code);
51                         this.iso4217_code = iso4217_code_conv;
52                         this.amount = bindings.LDKAmount_Currency_get_amount(ptr);
53                 }
54         }
55         internal long clone_ptr() {
56                 long ret = bindings.Amount_clone_ptr(this.ptr);
57                 GC.KeepAlive(this);
58                 return ret;
59         }
60
61         /**
62          * Creates a copy of the Amount
63          */
64         public Amount clone() {
65                 long ret = bindings.Amount_clone(this.ptr);
66                 GC.KeepAlive(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.Amount ret_hu_conv = org.ldk.structs.Amount.constr_from_ptr(ret);
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Utility method to constructs a new Bitcoin-variant Amount
75          */
76         public static Amount bitcoin(long amount_msats) {
77                 long ret = bindings.Amount_bitcoin(amount_msats);
78                 GC.KeepAlive(amount_msats);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 org.ldk.structs.Amount ret_hu_conv = org.ldk.structs.Amount.constr_from_ptr(ret);
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
82                 return ret_hu_conv;
83         }
84
85         /**
86          * Utility method to constructs a new Currency-variant Amount
87          */
88         public static Amount currency(byte[] iso4217_code, long amount) {
89                 long ret = bindings.Amount_currency(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(iso4217_code, 3)), amount);
90                 GC.KeepAlive(iso4217_code);
91                 GC.KeepAlive(amount);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.Amount ret_hu_conv = org.ldk.structs.Amount.constr_from_ptr(ret);
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
95                 return ret_hu_conv;
96         }
97
98 }
99 } } }