Merge pull request #161 from TheBlueMatt/main
[ldk-java] / c_sharp / src / org / ldk / structs / ReceiveTlvs.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  * Data to construct a [`BlindedHop`] for receiving a payment. This payload is custom to LDK and
11  * may not be valid if received by another lightning implementation.
12  */
13 public class ReceiveTlvs : CommonBase {
14         internal ReceiveTlvs(object _dummy, long ptr) : base(ptr) { }
15         ~ReceiveTlvs() {
16                 if (ptr != 0) { bindings.ReceiveTlvs_free(ptr); }
17         }
18
19         /**
20          * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
21          */
22         public byte[] get_payment_secret() {
23                 long ret = bindings.ReceiveTlvs_get_payment_secret(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
27                 return ret_conv;
28         }
29
30         /**
31          * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
32          */
33         public void set_payment_secret(byte[] val) {
34                 bindings.ReceiveTlvs_set_payment_secret(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37         }
38
39         /**
40          * Constraints for the receiver of this payment.
41          */
42         public PaymentConstraints get_payment_constraints() {
43                 long ret = bindings.ReceiveTlvs_get_payment_constraints(this.ptr);
44                 GC.KeepAlive(this);
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 org.ldk.structs.PaymentConstraints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PaymentConstraints(null, ret); }
47                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
48                 return ret_hu_conv;
49         }
50
51         /**
52          * Constraints for the receiver of this payment.
53          */
54         public void set_payment_constraints(org.ldk.structs.PaymentConstraints val) {
55                 bindings.ReceiveTlvs_set_payment_constraints(this.ptr, val.ptr);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58                 if (this != null) { this.ptrs_to.AddLast(val); };
59         }
60
61         /**
62          * Context for the receiver of this payment.
63          */
64         public PaymentContext get_payment_context() {
65                 long ret = bindings.ReceiveTlvs_get_payment_context(this.ptr);
66                 GC.KeepAlive(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.PaymentContext ret_hu_conv = org.ldk.structs.PaymentContext.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          * Context for the receiver of this payment.
75          */
76         public void set_payment_context(org.ldk.structs.PaymentContext val) {
77                 bindings.ReceiveTlvs_set_payment_context(this.ptr, val.ptr);
78                 GC.KeepAlive(this);
79                 GC.KeepAlive(val);
80                 if (this != null) { this.ptrs_to.AddLast(val); };
81         }
82
83         /**
84          * Constructs a new ReceiveTlvs given each field
85          */
86         public static ReceiveTlvs of(byte[] payment_secret_arg, org.ldk.structs.PaymentConstraints payment_constraints_arg, org.ldk.structs.PaymentContext payment_context_arg) {
87                 long ret = bindings.ReceiveTlvs_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_secret_arg, 32)), payment_constraints_arg.ptr, payment_context_arg.ptr);
88                 GC.KeepAlive(payment_secret_arg);
89                 GC.KeepAlive(payment_constraints_arg);
90                 GC.KeepAlive(payment_context_arg);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.ReceiveTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReceiveTlvs(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_constraints_arg); };
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_context_arg); };
96                 return ret_hu_conv;
97         }
98
99         internal long clone_ptr() {
100                 long ret = bindings.ReceiveTlvs_clone_ptr(this.ptr);
101                 GC.KeepAlive(this);
102                 return ret;
103         }
104
105         /**
106          * Creates a copy of the ReceiveTlvs
107          */
108         public ReceiveTlvs clone() {
109                 long ret = bindings.ReceiveTlvs_clone(this.ptr);
110                 GC.KeepAlive(this);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 org.ldk.structs.ReceiveTlvs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ReceiveTlvs(null, ret); }
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
114                 return ret_hu_conv;
115         }
116
117         /**
118          * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
119          */
120         public byte[] write() {
121                 long ret = bindings.ReceiveTlvs_write(this.ptr);
122                 GC.KeepAlive(this);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
125                 return ret_conv;
126         }
127
128 }
129 } } }