}
let refund = RefundContents {
- payer: PayerContents(metadata), metadata: None, description, absolute_expiry: None,
- issuer: None, paths: None, chain: None, amount_msats,
- features: InvoiceRequestFeatures::empty(), quantity: None, payer_id, payer_note: None,
+ payer: PayerContents(metadata), description, absolute_expiry: None, issuer: None,
+ paths: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
+ quantity: None, payer_id, payer_note: None,
};
Ok(RefundBuilder { refund })
pub(super) struct RefundContents {
payer: PayerContents,
// offer fields
- metadata: Option<Vec<u8>>,
description: String,
absolute_expiry: Option<Duration>,
issuer: Option<String>,
let offer = OfferTlvStreamRef {
chains: None,
- metadata: self.metadata.as_ref(),
+ metadata: None,
currency: None,
amount: None,
description: Some(&self.description),
Some(metadata) => PayerContents(metadata),
};
+ if metadata.is_some() {
+ return Err(SemanticError::UnexpectedMetadata);
+ }
+
if chains.is_some() {
return Err(SemanticError::UnexpectedChain);
}
Some(payer_id) => payer_id,
};
- // TODO: Should metadata be included?
Ok(RefundContents {
- payer, metadata, description, absolute_expiry, issuer, paths, chain, amount_msats,
- features, quantity, payer_id, payer_note,
+ payer, description, absolute_expiry, issuer, paths, chain, amount_msats, features,
+ quantity, payer_id, payer_note,
})
}
}
panic!("error parsing refund: {:?}", e);
}
+ let metadata = vec![42; 32];
+ let mut tlv_stream = refund.as_tlv_stream();
+ tlv_stream.1.metadata = Some(&metadata);
+
+ match Refund::try_from(tlv_stream.to_bytes()) {
+ Ok(_) => panic!("expected error"),
+ Err(e) => {
+ assert_eq!(e, ParseError::InvalidSemantics(SemanticError::UnexpectedMetadata));
+ },
+ }
+
let chains = vec![ChainHash::using_genesis_block(Network::Testnet)];
let mut tlv_stream = refund.as_tlv_stream();
tlv_stream.1.chains = Some(&chains);