Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / structs / Invoice.swift
1 import LDKCHeaders
2
3 public class Invoice {
4
5     public internal(set) var cOpaqueStruct: LDKInvoice?;
6
7         
8
9     public init(pointer: LDKInvoice){
10                 self.cOpaqueStruct = pointer
11         }
12
13     /* STRUCT_METHODS_START */
14
15     public func eq(a: Invoice, b: Invoice) -> Bool {
16         
17         return withUnsafePointer(to: a.cOpaqueStruct!) { (aPointer: UnsafePointer<LDKInvoice>) in
18 withUnsafePointer(to: b.cOpaqueStruct!) { (bPointer: UnsafePointer<LDKInvoice>) in
19 Invoice_eq(aPointer, bPointer)
20 }
21 };
22     }
23
24     public func clone(orig: Invoice) -> Invoice {
25         
26         return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKInvoice>) in
27 Invoice(pointer: Invoice_clone(origPointer))
28 };
29     }
30
31     public func into_signed_raw() -> SignedRawInvoice {
32         
33         return SignedRawInvoice(pointer: Invoice_into_signed_raw(self.cOpaqueStruct!));
34     }
35
36     public func check_signature() -> Result_NoneSemanticErrorZ {
37         
38         return Result_NoneSemanticErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
39 Invoice_check_signature(this_argPointer)
40 });
41     }
42
43     public func from_signed(signed_invoice: SignedRawInvoice) -> Result_InvoiceSemanticErrorZ {
44         
45         return Result_InvoiceSemanticErrorZ(pointer: Invoice_from_signed(signed_invoice.cOpaqueStruct!));
46     }
47
48     public func timestamp() -> UInt64 {
49         
50         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
51 Invoice_timestamp(this_argPointer)
52 };
53     }
54
55     public func payment_hash() -> [UInt8] {
56         
57         return Bindings.tuple32_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
58 Invoice_payment_hash(this_argPointer)
59 }.pointee);
60     }
61
62     public func payee_pub_key() -> [UInt8] {
63         
64         return Bindings.LDKPublicKey_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
65 Invoice_payee_pub_key(this_argPointer)
66 });
67     }
68
69     public func payment_secret() -> [UInt8] {
70         
71         return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
72 Invoice_payment_secret(this_argPointer)
73 });
74     }
75
76     public func features() -> InvoiceFeatures {
77         
78         return InvoiceFeatures(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
79 Invoice_features(this_argPointer)
80 });
81     }
82
83     public func recover_payee_pub_key() -> [UInt8] {
84         
85         return Bindings.LDKPublicKey_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
86 Invoice_recover_payee_pub_key(this_argPointer)
87 });
88     }
89
90     public func expiry_time() -> UInt64 {
91         
92         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
93 Invoice_expiry_time(this_argPointer)
94 };
95     }
96
97     public func min_final_cltv_expiry() -> UInt64 {
98         
99         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
100 Invoice_min_final_cltv_expiry(this_argPointer)
101 };
102     }
103
104     public func private_routes() -> [LDKPrivateRoute] {
105         
106         return Bindings.LDKCVec_PrivateRouteZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
107 Invoice_private_routes(this_argPointer)
108 });
109     }
110
111     public func route_hints() -> [LDKRouteHint] {
112         
113         return Bindings.LDKCVec_RouteHintZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
114 Invoice_route_hints(this_argPointer)
115 });
116     }
117
118     public func currency() -> LDKCurrency {
119         
120         return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
121 Invoice_currency(this_argPointer)
122 };
123     }
124
125     public func amount_pico_btc() -> Option_u64Z {
126         
127         return Option_u64Z(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInvoice>) in
128 Invoice_amount_pico_btc(this_argPointer)
129 });
130     }
131
132     public func from_str(s: String) -> Result_InvoiceNoneZ {
133         
134         return Result_InvoiceNoneZ(pointer: Invoice_from_str(Bindings.new_LDKStr(string: s)));
135     }
136
137     public func to_str(o: Invoice) -> String {
138         
139         return Bindings.LDKStr_to_string(nativeType: withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKInvoice>) in
140 Invoice_to_str(oPointer)
141 });
142     }
143
144                                 
145         deinit {
146                                         if self.cOpaqueStruct?.is_owned == false {
147
148                                         
149                                         
150                 Invoice_free(self.cOpaqueStruct!)
151                                         
152 }
153                                 
154         }
155                         
156     /* STRUCT_METHODS_END */
157
158 }