///
/// [`Offer`]: crate::offers::offer::Offer
/// [`Offer::amount`]: crate::offers::offer::Offer::amount
- pub fn amount(&$self) -> Option<&Amount> {
+ pub fn amount(&$self) -> Option<Amount> {
$contents.amount()
}
}
}
- fn amount(&self) -> Option<&Amount> {
+ fn amount(&self) -> Option<Amount> {
match self {
InvoiceContents::ForOffer { invoice_request, .. } =>
invoice_request.inner.offer.amount(),
assert_eq!(unsigned_invoice.payer_metadata(), &[1; 32]);
assert_eq!(unsigned_invoice.offer_chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
assert_eq!(unsigned_invoice.metadata(), None);
- assert_eq!(unsigned_invoice.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
+ assert_eq!(unsigned_invoice.amount(), Some(Amount::Bitcoin { amount_msats: 1000 }));
assert_eq!(unsigned_invoice.description(), Some(PrintableString("")));
assert_eq!(unsigned_invoice.offer_features(), Some(&OfferFeatures::empty()));
assert_eq!(unsigned_invoice.absolute_expiry(), None);
assert_eq!(invoice.payer_metadata(), &[1; 32]);
assert_eq!(invoice.offer_chains(), Some(vec![ChainHash::using_genesis_block(Network::Bitcoin)]));
assert_eq!(invoice.metadata(), None);
- assert_eq!(invoice.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
+ assert_eq!(invoice.amount(), Some(Amount::Bitcoin { amount_msats: 1000 }));
assert_eq!(invoice.description(), Some(PrintableString("")));
assert_eq!(invoice.offer_features(), Some(&OfferFeatures::empty()));
assert_eq!(invoice.absolute_expiry(), None);
assert_eq!(unsigned_invoice_request.payer_metadata(), &[1; 32]);
assert_eq!(unsigned_invoice_request.chains(), vec![ChainHash::using_genesis_block(Network::Bitcoin)]);
assert_eq!(unsigned_invoice_request.metadata(), None);
- assert_eq!(unsigned_invoice_request.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
+ assert_eq!(unsigned_invoice_request.amount(), Some(Amount::Bitcoin { amount_msats: 1000 }));
assert_eq!(unsigned_invoice_request.description(), Some(PrintableString("")));
assert_eq!(unsigned_invoice_request.offer_features(), &OfferFeatures::empty());
assert_eq!(unsigned_invoice_request.absolute_expiry(), None);
assert_eq!(invoice_request.payer_metadata(), &[1; 32]);
assert_eq!(invoice_request.chains(), vec![ChainHash::using_genesis_block(Network::Bitcoin)]);
assert_eq!(invoice_request.metadata(), None);
- assert_eq!(invoice_request.amount(), Some(&Amount::Bitcoin { amount_msats: 1000 }));
+ assert_eq!(invoice_request.amount(), Some(Amount::Bitcoin { amount_msats: 1000 }));
assert_eq!(invoice_request.description(), Some(PrintableString("")));
assert_eq!(invoice_request.offer_features(), &OfferFeatures::empty());
assert_eq!(invoice_request.absolute_expiry(), None);
}
/// The minimum amount required for a successful payment of a single item.
- pub fn amount(&$self) -> Option<&$crate::offers::offer::Amount> {
+ pub fn amount(&$self) -> Option<$crate::offers::offer::Amount> {
$contents.amount()
}
self.metadata.as_ref().and_then(|metadata| metadata.as_bytes())
}
- pub fn amount(&self) -> Option<&Amount> {
- self.amount.as_ref()
+ pub fn amount(&self) -> Option<Amount> {
+ self.amount
}
pub fn description(&self) -> Option<PrintableString> {
/// The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or
/// another currency.
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Amount {
/// An amount of bitcoin.
Bitcoin {
.build()
.unwrap();
let tlv_stream = offer.as_tlv_stream();
- assert_eq!(offer.amount(), Some(&bitcoin_amount));
+ assert_eq!(offer.amount(), Some(bitcoin_amount));
assert_eq!(tlv_stream.amount, Some(1000));
assert_eq!(tlv_stream.currency, None);