6 namespace org { namespace ldk { namespace structs {
9 * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or
12 public class Amount : CommonBase {
13 protected Amount(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.Amount_free(ptr); }
18 internal static Amount constr_from_ptr(long ptr) {
19 long raw_ty = bindings.LDKAmount_ty_from_ptr(ptr);
21 case 0: return new Amount_Bitcoin(ptr);
22 case 1: return new Amount_Currency(ptr);
24 throw new ArgumentException("Impossible enum variant");
28 /** A Amount of type Bitcoin */
29 public class Amount_Bitcoin : Amount {
31 * The amount in millisatoshi.
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);
38 /** A Amount of type Currency */
39 public class Amount_Currency : Amount {
41 * The currency that the amount is denominated in.
43 public byte[] iso4217_code;
45 * The amount in the currency unit adjusted by the ISO 4712 exponent (e.g., USD cents).
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);
55 internal long clone_ptr() {
56 long ret = bindings.Amount_clone_ptr(this.ptr);
62 * Creates a copy of the Amount
64 public Amount clone() {
65 long ret = bindings.Amount_clone(this.ptr);
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); };
74 * Utility method to constructs a new Bitcoin-variant Amount
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); };
86 * Utility method to constructs a new Currency-variant Amount
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);
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); };