|
48 | 48 | //! .issuer("Foo Bar".to_string())
|
49 | 49 | //! .path(create_blinded_path())
|
50 | 50 | //! .path(create_another_blinded_path())
|
51 |
| -//! .build() |
52 |
| -//! .unwrap(); |
| 51 | +//! .build()?; |
53 | 52 | //!
|
54 | 53 | //! // Encode as a bech32 string for use in a QR code.
|
55 | 54 | //! let encoded_offer = offer.to_string();
|
@@ -189,11 +188,11 @@ impl OfferBuilder {
|
189 | 188 | }
|
190 | 189 |
|
191 | 190 | /// Builds an [`Offer`] from the builder's settings.
|
192 |
| - pub fn build(self) -> Result<Offer, ()> { |
| 191 | + pub fn build(self) -> Result<Offer, SemanticError> { |
193 | 192 | // TODO: Also check for Amount::Currency
|
194 | 193 | if let Some(Amount::Currency { .. }) = self.offer.amount {
|
195 | 194 | } else if self.offer.amount_msats() > MAX_VALUE_MSAT {
|
196 |
| - return Err(()); |
| 195 | + return Err(SemanticError::InvalidAmount); |
197 | 196 | }
|
198 | 197 |
|
199 | 198 | let mut bytes = Vec::new();
|
@@ -550,6 +549,7 @@ mod tests {
|
550 | 549 | use core::time::Duration;
|
551 | 550 | use crate::ln::features::OfferFeatures;
|
552 | 551 | use crate::ln::msgs::MAX_VALUE_MSAT;
|
| 552 | + use crate::offers::parse::SemanticError; |
553 | 553 | use crate::onion_message::{BlindedHop, BlindedPath};
|
554 | 554 | use crate::util::ser::Writeable;
|
555 | 555 | use crate::util::string::PrintableString;
|
@@ -686,7 +686,7 @@ mod tests {
|
686 | 686 | let invalid_amount = Amount::Bitcoin { amount_msats: MAX_VALUE_MSAT + 1 };
|
687 | 687 | match OfferBuilder::new("foo".into(), pubkey(42)).amount(invalid_amount).build() {
|
688 | 688 | Ok(_) => panic!("expected error"),
|
689 |
| - Err(e) => assert_eq!(e, ()), |
| 689 | + Err(e) => assert_eq!(e, SemanticError::InvalidAmount), |
690 | 690 | }
|
691 | 691 | }
|
692 | 692 |
|
|
0 commit comments