Skip to content

Commit 48cba29

Browse files
committed
Don't require Offer::description in API
Offers currently require a description, though this may change to be optional. Remove the description requirement from the API, setting and empty string by default.
1 parent b7635c4 commit 48cba29

File tree

7 files changed

+193
-171
lines changed

7 files changed

+193
-171
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,11 +1554,12 @@ where
15541554
/// # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
15551555
/// # let channel_manager = channel_manager.get_cm();
15561556
/// let offer = channel_manager
1557-
/// .create_offer_builder("coffee".to_string())?
1557+
/// .create_offer_builder()?
15581558
/// # ;
15591559
/// # // Needed for compiling for c_bindings
15601560
/// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
15611561
/// # let offer = builder
1562+
/// .description("coffee".to_string())
15621563
/// .amount_msats(10_000_000)
15631564
/// .build()?;
15641565
/// let bech32_offer = offer.to_string();
@@ -8553,17 +8554,15 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
85538554
///
85548555
/// [`Offer`]: crate::offers::offer::Offer
85558556
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
8556-
pub fn create_offer_builder(
8557-
&$self, description: String
8558-
) -> Result<$builder, Bolt12SemanticError> {
8557+
pub fn create_offer_builder(&$self) -> Result<$builder, Bolt12SemanticError> {
85598558
let node_id = $self.get_our_node_id();
85608559
let expanded_key = &$self.inbound_payment_key;
85618560
let entropy = &*$self.entropy_source;
85628561
let secp_ctx = &$self.secp_ctx;
85638562

85648563
let path = $self.create_blinded_path().map_err(|_| Bolt12SemanticError::MissingPaths)?;
85658564
let builder = OfferBuilder::deriving_signing_pubkey(
8566-
description, node_id, expanded_key, entropy, secp_ctx
8565+
node_id, expanded_key, entropy, secp_ctx
85678566
)
85688567
.chain_hash($self.chain_hash)
85698568
.path(path);

lightning/src/ln/offers_tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn prefers_non_tor_nodes_in_blinded_paths() {
268268
announce_node_address(charlie, &[alice, bob, david, &nodes[4], &nodes[5]], tor.clone());
269269

270270
let offer = bob.node
271-
.create_offer_builder("coffee".to_string()).unwrap()
271+
.create_offer_builder().unwrap()
272272
.amount_msats(10_000_000)
273273
.build().unwrap();
274274
assert_ne!(offer.signing_pubkey(), Some(bob_id));
@@ -283,7 +283,7 @@ fn prefers_non_tor_nodes_in_blinded_paths() {
283283
announce_node_address(&nodes[5], &[alice, bob, charlie, david, &nodes[4]], tor.clone());
284284

285285
let offer = bob.node
286-
.create_offer_builder("coffee".to_string()).unwrap()
286+
.create_offer_builder().unwrap()
287287
.amount_msats(10_000_000)
288288
.build().unwrap();
289289
assert_ne!(offer.signing_pubkey(), Some(bob_id));
@@ -333,7 +333,7 @@ fn prefers_more_connected_nodes_in_blinded_paths() {
333333
disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]);
334334

335335
let offer = bob.node
336-
.create_offer_builder("coffee".to_string()).unwrap()
336+
.create_offer_builder().unwrap()
337337
.amount_msats(10_000_000)
338338
.build().unwrap();
339339
assert_ne!(offer.signing_pubkey(), Some(bob_id));
@@ -382,7 +382,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
382382
disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]);
383383

384384
let offer = alice.node
385-
.create_offer_builder("coffee".to_string())
385+
.create_offer_builder()
386386
.unwrap()
387387
.amount_msats(10_000_000)
388388
.build().unwrap();
@@ -544,7 +544,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
544544
let bob_id = bob.node.get_our_node_id();
545545

546546
let offer = alice.node
547-
.create_offer_builder("coffee".to_string()).unwrap()
547+
.create_offer_builder().unwrap()
548548
.amount_msats(10_000_000)
549549
.build().unwrap();
550550
assert_ne!(offer.signing_pubkey(), Some(alice_id));
@@ -668,7 +668,7 @@ fn pays_for_offer_without_blinded_paths() {
668668
let bob_id = bob.node.get_our_node_id();
669669

670670
let offer = alice.node
671-
.create_offer_builder("coffee".to_string()).unwrap()
671+
.create_offer_builder().unwrap()
672672
.clear_paths()
673673
.amount_msats(10_000_000)
674674
.build().unwrap();
@@ -760,7 +760,7 @@ fn fails_creating_offer_without_blinded_paths() {
760760

761761
create_unannounced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
762762

763-
match nodes[0].node.create_offer_builder("coffee".to_string()) {
763+
match nodes[0].node.create_offer_builder() {
764764
Ok(_) => panic!("Expected error"),
765765
Err(e) => assert_eq!(e, Bolt12SemanticError::MissingPaths),
766766
}
@@ -803,7 +803,7 @@ fn fails_creating_invoice_request_for_unsupported_chain() {
803803
let bob = &nodes[1];
804804

805805
let offer = alice.node
806-
.create_offer_builder("coffee".to_string()).unwrap()
806+
.create_offer_builder().unwrap()
807807
.clear_chains()
808808
.chain(Network::Signet)
809809
.build().unwrap();
@@ -865,7 +865,7 @@ fn fails_creating_invoice_request_without_blinded_reply_path() {
865865
disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]);
866866

867867
let offer = alice.node
868-
.create_offer_builder("coffee".to_string()).unwrap()
868+
.create_offer_builder().unwrap()
869869
.amount_msats(10_000_000)
870870
.build().unwrap();
871871

@@ -899,7 +899,7 @@ fn fails_creating_invoice_request_with_duplicate_payment_id() {
899899
disconnect_peers(alice, &[charlie, david, &nodes[4], &nodes[5]]);
900900

901901
let offer = alice.node
902-
.create_offer_builder("coffee".to_string()).unwrap()
902+
.create_offer_builder().unwrap()
903903
.amount_msats(10_000_000)
904904
.build().unwrap();
905905

@@ -985,7 +985,7 @@ fn fails_sending_invoice_without_blinded_payment_paths_for_offer() {
985985
disconnect_peers(david, &[bob, &nodes[4], &nodes[5]]);
986986

987987
let offer = alice.node
988-
.create_offer_builder("coffee".to_string()).unwrap()
988+
.create_offer_builder().unwrap()
989989
.amount_msats(10_000_000)
990990
.build().unwrap();
991991

lightning/src/ln/outbound_payment.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ mod tests {
21942194
assert!(outbound_payments.has_pending_payments());
21952195

21962196
let created_at = now() - DEFAULT_RELATIVE_EXPIRY;
2197-
let invoice = OfferBuilder::new("foo".into(), recipient_pubkey())
2197+
let invoice = OfferBuilder::new(recipient_pubkey())
21982198
.amount_msats(1000)
21992199
.build().unwrap()
22002200
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
@@ -2237,7 +2237,7 @@ mod tests {
22372237
let payment_id = PaymentId([0; 32]);
22382238
let expiration = StaleExpiration::AbsoluteTimeout(Duration::from_secs(100));
22392239

2240-
let invoice = OfferBuilder::new("foo".into(), recipient_pubkey())
2240+
let invoice = OfferBuilder::new(recipient_pubkey())
22412241
.amount_msats(1000)
22422242
.build().unwrap()
22432243
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
@@ -2296,7 +2296,7 @@ mod tests {
22962296
let payment_id = PaymentId([0; 32]);
22972297
let expiration = StaleExpiration::AbsoluteTimeout(Duration::from_secs(100));
22982298

2299-
let invoice = OfferBuilder::new("foo".into(), recipient_pubkey())
2299+
let invoice = OfferBuilder::new(recipient_pubkey())
23002300
.amount_msats(1000)
23012301
.build().unwrap()
23022302
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()

0 commit comments

Comments
 (0)