Skip to content

Commit d85b5d9

Browse files
committed
f - remove refund_for from SendInvoice
1 parent 4c2d25b commit d85b5d9

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

lightning/src/offers/offer.rs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ impl OfferBuilder {
142142
}
143143

144144
///
145-
pub fn send_invoice(mut self, send_invoice: SendInvoice) -> Self {
146-
self.offer.send_invoice = Some(send_invoice);
145+
pub fn send_invoice(mut self) -> Self {
146+
self.offer.send_invoice = Some(SendInvoice);
147147
self
148148
}
149149

@@ -308,11 +308,6 @@ impl Offer {
308308
),
309309
};
310310

311-
let (send_invoice, refund_for) = match &self.send_invoice {
312-
None => (None, None),
313-
Some(SendInvoice { refund_for }) => (Some(&()), refund_for.as_ref()),
314-
};
315-
316311
reference::OfferTlvStream {
317312
chains: self.chains.as_ref().map(Into::into),
318313
currency,
@@ -325,8 +320,7 @@ impl Offer {
325320
quantity_min: self.quantity_min.map(Into::into),
326321
quantity_max: self.quantity_max.map(Into::into),
327322
node_id: self.node_id.as_ref(),
328-
send_invoice,
329-
refund_for,
323+
send_invoice: self.send_invoice.as_ref().map(|_| &()),
330324
signature: self.signature.as_ref(),
331325
}
332326
}
@@ -369,7 +363,6 @@ tlv_stream!(struct OfferTlvStream {
369363
(22, quantity_min: u64),
370364
(24, quantity_max: u64),
371365
(30, node_id: PublicKey),
372-
(34, refund_for: PaymentHash),
373366
(54, send_invoice: Empty),
374367
(240, signature: Signature),
375368
});
@@ -401,7 +394,6 @@ mod tests {
401394
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
402395
use core::num::NonZeroU64;
403396
use core::time::Duration;
404-
use ln::PaymentHash;
405397
use ln::features::OfferFeatures;
406398

407399
fn pubkey() -> PublicKey {
@@ -453,7 +445,6 @@ mod tests {
453445
assert_eq!(tlv_stream.quantity_min, None);
454446
assert_eq!(tlv_stream.quantity_max, None);
455447
assert_eq!(tlv_stream.node_id, Some(&pubkey()));
456-
assert_eq!(tlv_stream.refund_for, None);
457448
assert_eq!(tlv_stream.send_invoice, None);
458449
assert_eq!(tlv_stream.signature, None);
459450
}
@@ -766,31 +757,11 @@ mod tests {
766757

767758
#[test]
768759
fn builds_offer_with_send_invoice() {
769-
let refund_for = Some(PaymentHash([0; 32]));
770-
771-
let offer = OfferBuilder::new("foo".into(), Destination::NodeId(pubkey()))
772-
.send_invoice(SendInvoice { refund_for: None })
773-
.build();
774-
let tlv_stream = offer.as_tlv_stream();
775-
assert_eq!(offer.send_invoice(), Some(&SendInvoice { refund_for: None }));
776-
assert_eq!(tlv_stream.refund_for, None);
777-
assert_eq!(tlv_stream.send_invoice, Some(&()));
778-
779-
let offer = OfferBuilder::new("foo".into(), Destination::NodeId(pubkey()))
780-
.send_invoice(SendInvoice { refund_for })
781-
.build();
782-
let tlv_stream = offer.as_tlv_stream();
783-
assert_eq!(offer.send_invoice(), Some(&SendInvoice { refund_for }));
784-
assert_eq!(tlv_stream.refund_for, refund_for.as_ref());
785-
assert_eq!(tlv_stream.send_invoice, Some(&()));
786-
787760
let offer = OfferBuilder::new("foo".into(), Destination::NodeId(pubkey()))
788-
.send_invoice(SendInvoice { refund_for })
789-
.send_invoice(SendInvoice { refund_for: None })
761+
.send_invoice()
790762
.build();
791763
let tlv_stream = offer.as_tlv_stream();
792-
assert_eq!(offer.send_invoice(), Some(&SendInvoice { refund_for: None }));
793-
assert_eq!(tlv_stream.refund_for, None);
764+
assert_eq!(offer.send_invoice(), Some(&SendInvoice));
794765
assert_eq!(tlv_stream.send_invoice, Some(&()));
795766
}
796767
}

0 commit comments

Comments
 (0)