@@ -59,6 +59,7 @@ pub use de::{ParseError, ParseOrSemanticError};
59
59
/// given field:
60
60
/// * `D`: exactly one `Description` or `DescriptionHash`
61
61
/// * `H`: exactly one `PaymentHash`
62
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
62
63
pub struct InvoiceBuilder < D : tb:: Bool , H : tb:: Bool > {
63
64
currency : Currency ,
64
65
amount : Option < u64 > ,
@@ -77,11 +78,12 @@ pub struct InvoiceBuilder<D: tb::Bool, H: tb::Bool> {
77
78
/// 1. using `InvoiceBuilder`
78
79
/// 2. using `Invoice::from_signed(SignedRawInvoice)`
79
80
/// 3. using `str::parse::<Invoice>(&str)`
80
- #[ derive( Eq , PartialEq , Debug ) ]
81
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
81
82
pub struct Invoice {
82
83
signed_invoice : SignedRawInvoice ,
83
84
}
84
85
86
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
85
87
pub enum InvoiceDescription < ' f > {
86
88
Direct ( & ' f Description ) ,
87
89
Hash ( & ' f Sha256 )
@@ -92,7 +94,7 @@ pub enum InvoiceDescription<'f> {
92
94
///
93
95
/// # Invariants
94
96
/// The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
95
- #[ derive( Eq , PartialEq , Debug ) ]
97
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
96
98
pub struct SignedRawInvoice {
97
99
/// The rawInvoice that the signature belongs to
98
100
raw_invoice : RawInvoice ,
@@ -113,7 +115,7 @@ pub struct SignedRawInvoice {
113
115
/// Represents an syntactically correct Invoice for a payment on the lightning network,
114
116
/// but without the signature information.
115
117
/// De- and encoding should not lead to information loss but may lead to different hashes.
116
- #[ derive( Eq , PartialEq , Debug ) ]
118
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
117
119
pub struct RawInvoice {
118
120
/// human readable part
119
121
pub hrp : RawHrp ,
@@ -123,7 +125,7 @@ pub struct RawInvoice {
123
125
}
124
126
125
127
/// Data of the `RawInvoice` that is encoded in the human readable part
126
- #[ derive( Eq , PartialEq , Debug ) ]
128
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
127
129
pub struct RawHrp {
128
130
/// The currency deferred from the 3rd and 4th character of the bech32 transaction
129
131
pub currency : Currency ,
@@ -136,7 +138,7 @@ pub struct RawHrp {
136
138
}
137
139
138
140
/// Data of the `RawInvoice` that is encoded in the data part
139
- #[ derive( Eq , PartialEq , Debug ) ]
141
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
140
142
pub struct RawDataPart {
141
143
// TODO: find better fitting type that only allows positive timestamps to avoid checks for negative timestamps when encoding
142
144
/// generation time of the invoice as UNIX timestamp
@@ -187,7 +189,7 @@ pub enum Currency {
187
189
}
188
190
189
191
/// Tagged field which may have an unknown tag
190
- #[ derive( Eq , PartialEq , Debug ) ]
192
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
191
193
pub enum RawTaggedField {
192
194
/// Parsed tagged field with known tag
193
195
KnownSemantics ( TaggedField ) ,
@@ -196,7 +198,7 @@ pub enum RawTaggedField {
196
198
}
197
199
198
200
/// Tagged field with known tag
199
- #[ derive( Eq , PartialEq , Debug ) ]
201
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
200
202
pub enum TaggedField {
201
203
PaymentHash ( Sha256 ) ,
202
204
Description ( Description ) ,
@@ -210,33 +212,33 @@ pub enum TaggedField {
210
212
211
213
// TODO: use struct from bitcoin_hashes
212
214
/// SHA-256 hash
213
- #[ derive( Eq , PartialEq , Debug ) ]
215
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
214
216
pub struct Sha256 ( pub [ u8 ; 32 ] ) ;
215
217
216
218
/// Description string
217
219
///
218
220
/// # Invariants
219
221
/// The description can be at most 639 __bytes__ long
220
- #[ derive( Eq , PartialEq , Debug ) ]
222
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
221
223
pub struct Description ( String ) ;
222
224
223
225
/// Payee public key
224
- #[ derive( Eq , PartialEq , Debug ) ]
226
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
225
227
pub struct PayeePubKey ( pub PublicKey ) ;
226
228
227
229
/// Positive duration that defines when (relatively to the timestamp) in the future the invoice expires
228
- #[ derive( Eq , PartialEq , Debug ) ]
230
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
229
231
pub struct ExpiryTime {
230
232
pub seconds : u64
231
233
}
232
234
233
235
/// `min_final_cltv_expiry` to use for the last HTLC in the route
234
- #[ derive( Eq , PartialEq , Debug ) ]
236
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
235
237
pub struct MinFinalCltvExpiry ( pub u64 ) ;
236
238
237
239
// TODO: better types instead onf byte arrays
238
240
/// Fallback address in case no LN payment is possible
239
- #[ derive( Eq , PartialEq , Debug ) ]
241
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
240
242
pub enum Fallback {
241
243
SegWitProgram {
242
244
version : u5 ,
@@ -247,18 +249,18 @@ pub enum Fallback {
247
249
}
248
250
249
251
/// Recoverable signature
250
- #[ derive( Eq , PartialEq , Debug ) ]
252
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
251
253
pub struct Signature ( pub RecoverableSignature ) ;
252
254
253
255
/// Private routing information
254
256
///
255
257
/// # Invariants
256
258
/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
257
259
///
258
- #[ derive( Eq , PartialEq , Debug ) ]
260
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
259
261
pub struct Route ( Vec < RouteHop > ) ;
260
262
261
- #[ derive( Eq , PartialEq , Debug ) ]
263
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
262
264
pub struct RouteHop {
263
265
pub pubkey : PublicKey ,
264
266
pub short_channel_id : [ u8 ; 8 ] ,
@@ -930,7 +932,7 @@ impl Deref for SignedRawInvoice {
930
932
}
931
933
932
934
/// Errors that may occur when constructing a new `RawInvoice` or `Invoice`
933
- #[ derive( Eq , PartialEq , Debug ) ]
935
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
934
936
pub enum CreationError {
935
937
/// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new))
936
938
DescriptionTooLong ,
@@ -941,7 +943,7 @@ pub enum CreationError {
941
943
942
944
/// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the
943
945
/// requirements sections in BOLT #11
944
- #[ derive( Eq , PartialEq , Debug ) ]
946
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
945
947
pub enum SemanticError {
946
948
NoPaymentHash ,
947
949
MultiplePaymentHashes ,
@@ -955,6 +957,7 @@ pub enum SemanticError {
955
957
956
958
/// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
957
959
/// may occur.
960
+ #[ derive( Eq , PartialEq , Debug , Clone ) ]
958
961
pub enum SignOrCreationError < S > {
959
962
SignError ( S ) ,
960
963
CreationError ( CreationError ) ,
0 commit comments