@@ -30,24 +30,31 @@ use std::time::SystemTime;
30
30
///
31
31
#[ derive( Debug ) ]
32
32
pub struct Offer {
33
- tlv_stream : OfferTlvStream ,
33
+ description : String ,
34
+ features : Option < OfferFeatures > ,
35
+ absolute_expiry : Option < Duration > ,
36
+ issuer : Option < String > ,
37
+ destination : Destination ,
38
+ quantity_min : Option < u64 > ,
39
+ quantity_max : Option < u64 > ,
40
+ signature : Option < Signature > ,
41
+ // TODO: Add more fields
34
42
}
35
43
36
44
impl Offer {
37
45
///
38
46
pub fn description ( & self ) -> & String {
39
- & self . tlv_stream . description . as_ref ( ) . unwrap ( ) . 0
47
+ & self . description
40
48
}
41
49
42
50
///
43
51
pub fn features ( & self ) -> Option < & OfferFeatures > {
44
- self . tlv_stream . features . as_ref ( )
52
+ self . features . as_ref ( )
45
53
}
46
54
47
55
///
48
56
pub fn absolute_expiry ( & self ) -> Option < Duration > {
49
- self . tlv_stream . absolute_expiry . as_ref ( )
50
- . map ( |seconds_from_epoch| Duration :: from_secs ( seconds_from_epoch. 0 ) )
57
+ self . absolute_expiry
51
58
}
52
59
53
60
///
@@ -64,33 +71,24 @@ impl Offer {
64
71
65
72
///
66
73
pub fn issuer ( & self ) -> Option < & String > {
67
- self . tlv_stream . issuer . as_ref ( ) . map ( |issuer| & issuer . 0 )
74
+ self . issuer . as_ref ( )
68
75
}
69
76
70
77
///
71
- pub fn destination ( & self ) -> Destination {
72
- if let Some ( ref node_id) = self . tlv_stream . node_id {
73
- Destination :: NodeId ( node_id)
74
- } else if let Some ( ref paths) = self . tlv_stream . paths {
75
- Destination :: Paths ( & paths. 0 )
76
- } else {
77
- unreachable ! ( )
78
- }
78
+ pub fn destination ( & self ) -> & Destination {
79
+ & self . destination
79
80
}
80
81
81
82
///
82
83
pub fn quantity_min ( & self ) -> u64 {
83
- match self . tlv_stream . quantity_min {
84
- Some ( HighZeroBytesDroppedVarInt ( quantity_min) ) => quantity_min,
85
- None => 1 ,
86
- }
84
+ self . quantity_min . unwrap_or ( 1 )
87
85
}
88
86
89
87
///
90
88
pub fn quantity_max ( & self ) -> u64 {
91
- match self . tlv_stream . quantity_max {
92
- Some ( HighZeroBytesDroppedVarInt ( quantity_max) ) => quantity_max,
93
- None => match self . tlv_stream . quantity_min {
89
+ match self . quantity_max {
90
+ Some ( quantity_max) => quantity_max,
91
+ None => match self . quantity_min {
94
92
Some ( _) => u64:: max_value ( ) ,
95
93
None => 1 ,
96
94
} ,
@@ -99,16 +97,17 @@ impl Offer {
99
97
100
98
///
101
99
pub fn signature ( & self ) -> Option < & Signature > {
102
- self . tlv_stream . signature . as_ref ( )
100
+ self . signature . as_ref ( )
103
101
}
104
102
}
105
103
106
104
///
107
- pub enum Destination < ' a > {
105
+ #[ derive( Debug ) ]
106
+ pub enum Destination {
108
107
///
109
- NodeId ( & ' a XOnlyPublicKey ) ,
108
+ NodeId ( XOnlyPublicKey ) ,
110
109
///
111
- Paths ( & ' a Vec < BlindedPath > ) ,
110
+ Paths ( Vec < BlindedPath > ) ,
112
111
}
113
112
114
113
/// An `offer` TLV stream without any semantic checks, apart from any checks performed when parsing
0 commit comments