[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / SignedRawBolt11Invoice.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  * Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be
11  * invalid.
12  * 
13  * # Invariants
14  * The hash has to be either from the deserialized invoice or from the serialized [`RawBolt11Invoice`].
15  */
16 public class SignedRawBolt11Invoice : CommonBase {
17         internal SignedRawBolt11Invoice(object _dummy, long ptr) : base(ptr) { }
18         ~SignedRawBolt11Invoice() {
19                 if (ptr != 0) { bindings.SignedRawBolt11Invoice_free(ptr); }
20         }
21
22         /**
23          * Checks if two SignedRawBolt11Invoices contain equal inner contents.
24          * This ignores pointers and is_owned flags and looks at the values in fields.
25          * Two objects with NULL inner values will be considered "equal" here.
26          */
27         public bool eq(org.ldk.structs.SignedRawBolt11Invoice b) {
28                 bool ret = bindings.SignedRawBolt11Invoice_eq(this.ptr, b == null ? 0 : b.ptr);
29                 GC.KeepAlive(this);
30                 GC.KeepAlive(b);
31                 if (this != null) { this.ptrs_to.AddLast(b); };
32                 return ret;
33         }
34
35         public override bool Equals(object o) {
36                 if (!(o is SignedRawBolt11Invoice)) return false;
37                 return this.eq((SignedRawBolt11Invoice)o);
38         }
39         internal long clone_ptr() {
40                 long ret = bindings.SignedRawBolt11Invoice_clone_ptr(this.ptr);
41                 GC.KeepAlive(this);
42                 return ret;
43         }
44
45         /**
46          * Creates a copy of the SignedRawBolt11Invoice
47          */
48         public SignedRawBolt11Invoice clone() {
49                 long ret = bindings.SignedRawBolt11Invoice_clone(this.ptr);
50                 GC.KeepAlive(this);
51                 if (ret >= 0 && ret <= 4096) { return null; }
52                 org.ldk.structs.SignedRawBolt11Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.SignedRawBolt11Invoice(null, ret); }
53                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
54                 return ret_hu_conv;
55         }
56
57         /**
58          * Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice.
59          */
60         public long hash() {
61                 long ret = bindings.SignedRawBolt11Invoice_hash(this.ptr);
62                 GC.KeepAlive(this);
63                 return ret;
64         }
65
66         public override int GetHashCode() {
67                 return (int)this.hash();
68         }
69         /**
70          * Disassembles the `SignedRawBolt11Invoice` into its three parts:
71          * 1. raw invoice
72          * 2. hash of the raw invoice
73          * 3. signature
74          */
75         public ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ into_parts() {
76                 long ret = bindings.SignedRawBolt11Invoice_into_parts(this.ptr);
77                 GC.KeepAlive(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ(null, ret);
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
81                 if (this != null) { this.ptrs_to.AddLast(this); };
82                 return ret_hu_conv;
83         }
84
85         /**
86          * The [`RawBolt11Invoice`] which was signed.
87          */
88         public RawBolt11Invoice raw_invoice() {
89                 long ret = bindings.SignedRawBolt11Invoice_raw_invoice(this.ptr);
90                 GC.KeepAlive(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.RawBolt11Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawBolt11Invoice(null, ret); }
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * The hash of the [`RawBolt11Invoice`] that was signed.
99          */
100         public byte[] signable_hash() {
101                 long ret = bindings.SignedRawBolt11Invoice_signable_hash(this.ptr);
102                 GC.KeepAlive(this);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
105                 return ret_conv;
106         }
107
108         /**
109          * Signature for the invoice.
110          */
111         public Bolt11InvoiceSignature signature() {
112                 long ret = bindings.SignedRawBolt11Invoice_signature(this.ptr);
113                 GC.KeepAlive(this);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 org.ldk.structs.Bolt11InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceSignature(null, ret); }
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Recovers the public key used for signing the invoice from the recoverable signature.
122          */
123         public Result_PayeePubKeySecp256k1ErrorZ recover_payee_pub_key() {
124                 long ret = bindings.SignedRawBolt11Invoice_recover_payee_pub_key(this.ptr);
125                 GC.KeepAlive(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 Result_PayeePubKeySecp256k1ErrorZ ret_hu_conv = Result_PayeePubKeySecp256k1ErrorZ.constr_from_ptr(ret);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Checks if the signature is valid for the included payee public key or if none exists if it's
133          * valid for the recovered signature (which should always be true?).
134          */
135         public bool check_signature() {
136                 bool ret = bindings.SignedRawBolt11Invoice_check_signature(this.ptr);
137                 GC.KeepAlive(this);
138                 return ret;
139         }
140
141         /**
142          * Read a SignedRawBolt11Invoice object from a string
143          */
144         public static Result_SignedRawBolt11InvoiceBolt11ParseErrorZ from_str(string s) {
145                 long ret = bindings.SignedRawBolt11Invoice_from_str(InternalUtils.encodeString(s));
146                 GC.KeepAlive(s);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 Result_SignedRawBolt11InvoiceBolt11ParseErrorZ ret_hu_conv = Result_SignedRawBolt11InvoiceBolt11ParseErrorZ.constr_from_ptr(ret);
149                 return ret_hu_conv;
150         }
151
152         /**
153          * Get the string representation of a SignedRawBolt11Invoice object
154          */
155         public string to_str() {
156                 long ret = bindings.SignedRawBolt11Invoice_to_str(this.ptr);
157                 GC.KeepAlive(this);
158                 if (ret >= 0 && ret <= 4096) { return null; }
159                 string ret_conv = InternalUtils.decodeString(ret);
160                 return ret_conv;
161         }
162
163 }
164 } } }