]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/BlindedTail.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[ldk-java] / c_sharp / src / org / ldk / structs / BlindedTail.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  * The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in
11  * their [`Bolt12Invoice`].
12  * 
13  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
14  */
15 public class BlindedTail : CommonBase {
16         internal BlindedTail(object _dummy, long ptr) : base(ptr) { }
17         ~BlindedTail() {
18                 if (ptr != 0) { bindings.BlindedTail_free(ptr); }
19         }
20
21         /**
22          * The hops of the [`BlindedPaymentPath`] provided by the recipient.
23          */
24         public BlindedHop[] get_hops() {
25                 long ret = bindings.BlindedTail_get_hops(this.ptr);
26                 GC.KeepAlive(this);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 int ret_conv_12_len = InternalUtils.getArrayLength(ret);
29                 BlindedHop[] ret_conv_12_arr = new BlindedHop[ret_conv_12_len];
30                 for (int m = 0; m < ret_conv_12_len; m++) {
31                         long ret_conv_12 = InternalUtils.getU64ArrayElem(ret, m);
32                         org.ldk.structs.BlindedHop ret_conv_12_hu_conv = null; if (ret_conv_12 < 0 || ret_conv_12 > 4096) { ret_conv_12_hu_conv = new org.ldk.structs.BlindedHop(null, ret_conv_12); }
33                         if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
34                         ret_conv_12_arr[m] = ret_conv_12_hu_conv;
35                 }
36                 bindings.free_buffer(ret);
37                 return ret_conv_12_arr;
38         }
39
40         /**
41          * The hops of the [`BlindedPaymentPath`] provided by the recipient.
42          */
43         public void set_hops(BlindedHop[] val) {
44                 bindings.BlindedTail_set_hops(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_12 => val_conv_12.ptr)));
45                 GC.KeepAlive(this);
46                 GC.KeepAlive(val);
47         }
48
49         /**
50          * The blinding point of the [`BlindedPaymentPath`] provided by the recipient.
51          */
52         public byte[] get_blinding_point() {
53                 long ret = bindings.BlindedTail_get_blinding_point(this.ptr);
54                 GC.KeepAlive(this);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
57                 return ret_conv;
58         }
59
60         /**
61          * The blinding point of the [`BlindedPaymentPath`] provided by the recipient.
62          */
63         public void set_blinding_point(byte[] val) {
64                 bindings.BlindedTail_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(val);
67         }
68
69         /**
70          * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
71          * inferring the destination. May be 0.
72          */
73         public int get_excess_final_cltv_expiry_delta() {
74                 int ret = bindings.BlindedTail_get_excess_final_cltv_expiry_delta(this.ptr);
75                 GC.KeepAlive(this);
76                 return ret;
77         }
78
79         /**
80          * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
81          * inferring the destination. May be 0.
82          */
83         public void set_excess_final_cltv_expiry_delta(int val) {
84                 bindings.BlindedTail_set_excess_final_cltv_expiry_delta(this.ptr, val);
85                 GC.KeepAlive(this);
86                 GC.KeepAlive(val);
87         }
88
89         /**
90          * The total amount paid on this [`Path`], excluding the fees.
91          */
92         public long get_final_value_msat() {
93                 long ret = bindings.BlindedTail_get_final_value_msat(this.ptr);
94                 GC.KeepAlive(this);
95                 return ret;
96         }
97
98         /**
99          * The total amount paid on this [`Path`], excluding the fees.
100          */
101         public void set_final_value_msat(long val) {
102                 bindings.BlindedTail_set_final_value_msat(this.ptr, val);
103                 GC.KeepAlive(this);
104                 GC.KeepAlive(val);
105         }
106
107         /**
108          * Constructs a new BlindedTail given each field
109          */
110         public static BlindedTail of(BlindedHop[] hops_arg, byte[] blinding_point_arg, int excess_final_cltv_expiry_delta_arg, long final_value_msat_arg) {
111                 long ret = bindings.BlindedTail_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(hops_arg, hops_arg_conv_12 => hops_arg_conv_12.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)), excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
112                 GC.KeepAlive(hops_arg);
113                 GC.KeepAlive(blinding_point_arg);
114                 GC.KeepAlive(excess_final_cltv_expiry_delta_arg);
115                 GC.KeepAlive(final_value_msat_arg);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 org.ldk.structs.BlindedTail ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedTail(null, ret); }
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
119                 return ret_hu_conv;
120         }
121
122         internal long clone_ptr() {
123                 long ret = bindings.BlindedTail_clone_ptr(this.ptr);
124                 GC.KeepAlive(this);
125                 return ret;
126         }
127
128         /**
129          * Creates a copy of the BlindedTail
130          */
131         public BlindedTail clone() {
132                 long ret = bindings.BlindedTail_clone(this.ptr);
133                 GC.KeepAlive(this);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.BlindedTail ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedTail(null, ret); }
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
137                 return ret_hu_conv;
138         }
139
140         /**
141          * Generates a non-cryptographic 64-bit hash of the BlindedTail.
142          */
143         public long hash() {
144                 long ret = bindings.BlindedTail_hash(this.ptr);
145                 GC.KeepAlive(this);
146                 return ret;
147         }
148
149         public override int GetHashCode() {
150                 return (int)this.hash();
151         }
152         /**
153          * Checks if two BlindedTails contain equal inner contents.
154          * This ignores pointers and is_owned flags and looks at the values in fields.
155          * Two objects with NULL inner values will be considered "equal" here.
156          */
157         public bool eq(org.ldk.structs.BlindedTail b) {
158                 bool ret = bindings.BlindedTail_eq(this.ptr, b.ptr);
159                 GC.KeepAlive(this);
160                 GC.KeepAlive(b);
161                 if (this != null) { this.ptrs_to.AddLast(b); };
162                 return ret;
163         }
164
165         public override bool Equals(object o) {
166                 if (!(o is BlindedTail)) return false;
167                 return this.eq((BlindedTail)o);
168         }
169         /**
170          * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read
171          */
172         public byte[] write() {
173                 long ret = bindings.BlindedTail_write(this.ptr);
174                 GC.KeepAlive(this);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
177                 return ret_conv;
178         }
179
180         /**
181          * Read a BlindedTail from a byte array, created by BlindedTail_write
182          */
183         public static Result_BlindedTailDecodeErrorZ read(byte[] ser) {
184                 long ret = bindings.BlindedTail_read(InternalUtils.encodeUint8Array(ser));
185                 GC.KeepAlive(ser);
186                 if (ret >= 0 && ret <= 4096) { return null; }
187                 Result_BlindedTailDecodeErrorZ ret_hu_conv = Result_BlindedTailDecodeErrorZ.constr_from_ptr(ret);
188                 return ret_hu_conv;
189         }
190
191 }
192 } } }