@@ -16,6 +16,7 @@ use crate::offers::invoice_error::InvoiceError;
16
16
use crate :: offers:: invoice_request:: InvoiceRequest ;
17
17
use crate :: offers:: invoice:: Bolt12Invoice ;
18
18
use crate :: offers:: parse:: Bolt12ParseError ;
19
+ #[ cfg( async_payments) ]
19
20
use crate :: offers:: static_invoice:: StaticInvoice ;
20
21
use crate :: onion_message:: packet:: OnionMessageContents ;
21
22
use crate :: util:: logger:: Logger ;
@@ -30,6 +31,7 @@ use crate::prelude::*;
30
31
const INVOICE_REQUEST_TLV_TYPE : u64 = 64 ;
31
32
const INVOICE_TLV_TYPE : u64 = 66 ;
32
33
const INVOICE_ERROR_TLV_TYPE : u64 = 68 ;
34
+ #[ cfg( async_payments) ]
33
35
const STATIC_INVOICE_TLV_TYPE : u64 = 70 ;
34
36
35
37
/// A handler for an [`OnionMessage`] containing a BOLT 12 Offers message as its payload.
@@ -74,7 +76,8 @@ pub enum OffersMessage {
74
76
/// [`Refund`]: crate::offers::refund::Refund
75
77
Invoice ( Bolt12Invoice ) ,
76
78
77
- /// A `StaticInvoice` sent in response to an [`InvoiceRequest`].
79
+ #[ cfg( async_payments) ]
80
+ /// A [`StaticInvoice`] sent in response to an [`InvoiceRequest`].
78
81
StaticInvoice ( StaticInvoice ) ,
79
82
80
83
/// An error from handling an [`OffersMessage`].
@@ -87,8 +90,9 @@ impl OffersMessage {
87
90
match tlv_type {
88
91
INVOICE_REQUEST_TLV_TYPE
89
92
| INVOICE_TLV_TYPE
90
- | STATIC_INVOICE_TLV_TYPE
91
93
| INVOICE_ERROR_TLV_TYPE => true ,
94
+ #[ cfg( async_payments) ]
95
+ STATIC_INVOICE_TLV_TYPE => true ,
92
96
_ => false ,
93
97
}
94
98
}
@@ -97,6 +101,7 @@ impl OffersMessage {
97
101
match tlv_type {
98
102
INVOICE_REQUEST_TLV_TYPE => Ok ( Self :: InvoiceRequest ( InvoiceRequest :: try_from ( bytes) ?) ) ,
99
103
INVOICE_TLV_TYPE => Ok ( Self :: Invoice ( Bolt12Invoice :: try_from ( bytes) ?) ) ,
104
+ #[ cfg( async_payments) ]
100
105
STATIC_INVOICE_TLV_TYPE => Ok ( Self :: StaticInvoice ( StaticInvoice :: try_from ( bytes) ?) ) ,
101
106
_ => Err ( Bolt12ParseError :: Decode ( DecodeError :: InvalidValue ) ) ,
102
107
}
@@ -112,6 +117,7 @@ impl fmt::Debug for OffersMessage {
112
117
OffersMessage :: Invoice ( message) => {
113
118
write ! ( f, "{:?}" , message. as_tlv_stream( ) )
114
119
}
120
+ #[ cfg( async_payments) ]
115
121
OffersMessage :: StaticInvoice ( message) => {
116
122
write ! ( f, "{:?}" , message)
117
123
}
@@ -127,6 +133,7 @@ impl OnionMessageContents for OffersMessage {
127
133
match self {
128
134
OffersMessage :: InvoiceRequest ( _) => INVOICE_REQUEST_TLV_TYPE ,
129
135
OffersMessage :: Invoice ( _) => INVOICE_TLV_TYPE ,
136
+ #[ cfg( async_payments) ]
130
137
OffersMessage :: StaticInvoice ( _) => STATIC_INVOICE_TLV_TYPE ,
131
138
OffersMessage :: InvoiceError ( _) => INVOICE_ERROR_TLV_TYPE ,
132
139
}
@@ -135,6 +142,7 @@ impl OnionMessageContents for OffersMessage {
135
142
match & self {
136
143
OffersMessage :: InvoiceRequest ( _) => "Invoice Request" ,
137
144
OffersMessage :: Invoice ( _) => "Invoice" ,
145
+ #[ cfg( async_payments) ]
138
146
OffersMessage :: StaticInvoice ( _) => "Static Invoice" ,
139
147
OffersMessage :: InvoiceError ( _) => "Invoice Error" ,
140
148
}
@@ -146,6 +154,7 @@ impl Writeable for OffersMessage {
146
154
match self {
147
155
OffersMessage :: InvoiceRequest ( message) => message. write ( w) ,
148
156
OffersMessage :: Invoice ( message) => message. write ( w) ,
157
+ #[ cfg( async_payments) ]
149
158
OffersMessage :: StaticInvoice ( message) => message. write ( w) ,
150
159
OffersMessage :: InvoiceError ( message) => message. write ( w) ,
151
160
}
0 commit comments