@@ -118,9 +118,9 @@ impl RefundBuilder {
118
118
}
119
119
120
120
let refund = RefundContents {
121
- payer : PayerContents ( metadata) , metadata : None , description , absolute_expiry : None ,
122
- issuer : None , paths : None , chain : None , amount_msats,
123
- features : InvoiceRequestFeatures :: empty ( ) , quantity : None , payer_id, payer_note : None ,
121
+ payer : PayerContents ( metadata) , description , absolute_expiry : None , issuer : None ,
122
+ paths : None , chain : None , amount_msats, features : InvoiceRequestFeatures :: empty ( ) ,
123
+ quantity : None , payer_id, payer_note : None ,
124
124
} ;
125
125
126
126
Ok ( RefundBuilder { refund } )
@@ -229,7 +229,6 @@ pub struct Refund {
229
229
pub ( super ) struct RefundContents {
230
230
payer : PayerContents ,
231
231
// offer fields
232
- metadata : Option < Vec < u8 > > ,
233
232
description : String ,
234
233
absolute_expiry : Option < Duration > ,
235
234
issuer : Option < String > ,
@@ -395,7 +394,7 @@ impl RefundContents {
395
394
396
395
let offer = OfferTlvStreamRef {
397
396
chains : None ,
398
- metadata : self . metadata . as_ref ( ) ,
397
+ metadata : None ,
399
398
currency : None ,
400
399
amount : None ,
401
400
description : Some ( & self . description ) ,
@@ -497,6 +496,10 @@ impl TryFrom<RefundTlvStream> for RefundContents {
497
496
Some ( metadata) => PayerContents ( metadata) ,
498
497
} ;
499
498
499
+ if metadata. is_some ( ) {
500
+ return Err ( SemanticError :: UnexpectedMetadata ) ;
501
+ }
502
+
500
503
if chains. is_some ( ) {
501
504
return Err ( SemanticError :: UnexpectedChain ) ;
502
505
}
@@ -541,8 +544,8 @@ impl TryFrom<RefundTlvStream> for RefundContents {
541
544
542
545
// TODO: Should metadata be included?
543
546
Ok ( RefundContents {
544
- payer, metadata , description, absolute_expiry, issuer, paths, chain, amount_msats,
545
- features , quantity, payer_id, payer_note,
547
+ payer, description, absolute_expiry, issuer, paths, chain, amount_msats, features ,
548
+ quantity, payer_id, payer_note,
546
549
} )
547
550
}
548
551
}
@@ -949,6 +952,17 @@ mod tests {
949
952
panic ! ( "error parsing refund: {:?}" , e) ;
950
953
}
951
954
955
+ let metadata = vec ! [ 42 ; 32 ] ;
956
+ let mut tlv_stream = refund. as_tlv_stream ( ) ;
957
+ tlv_stream. 1 . metadata = Some ( & metadata) ;
958
+
959
+ match Refund :: try_from ( tlv_stream. to_bytes ( ) ) {
960
+ Ok ( _) => panic ! ( "expected error" ) ,
961
+ Err ( e) => {
962
+ assert_eq ! ( e, ParseError :: InvalidSemantics ( SemanticError :: UnexpectedMetadata ) ) ;
963
+ } ,
964
+ }
965
+
952
966
let chains = vec ! [ ChainHash :: using_genesis_block( Network :: Testnet ) ] ;
953
967
let mut tlv_stream = refund. as_tlv_stream ( ) ;
954
968
tlv_stream. 1 . chains = Some ( & chains) ;
0 commit comments