Skip to content

Commit ee8019a

Browse files
committed
f - remove refund_for from SendInvoice
1 parent cbc8b9f commit ee8019a

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
@@ -141,8 +141,8 @@ impl OfferBuilder {
141141
}
142142

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

@@ -296,11 +296,6 @@ impl Offer {
296296
),
297297
};
298298

299-
let (send_invoice, refund_for) = match &self.send_invoice {
300-
None => (None, None),
301-
Some(SendInvoice { refund_for }) => (Some(&()), refund_for.as_ref()),
302-
};
303-
304299
reference::OfferTlvStream {
305300
chains: self.chains.as_ref().map(Into::into),
306301
currency,
@@ -313,8 +308,7 @@ impl Offer {
313308
quantity_min: self.quantity_min.map(Into::into),
314309
quantity_max: self.quantity_max.map(Into::into),
315310
node_id: self.node_id.as_ref(),
316-
send_invoice,
317-
refund_for,
311+
send_invoice: self.send_invoice.as_ref().map(|_| &()),
318312
signature: self.signature.as_ref(),
319313
}
320314
}
@@ -357,7 +351,6 @@ tlv_stream!(struct OfferTlvStream {
357351
(22, quantity_min: u64),
358352
(24, quantity_max: u64),
359353
(30, node_id: PublicKey),
360-
(34, refund_for: PaymentHash),
361354
(54, send_invoice: Empty),
362355
(240, signature: Signature),
363356
});
@@ -389,7 +382,6 @@ mod tests {
389382
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
390383
use core::num::NonZeroU64;
391384
use core::time::Duration;
392-
use ln::PaymentHash;
393385
use ln::features::OfferFeatures;
394386

395387
fn pubkey() -> PublicKey {
@@ -441,7 +433,6 @@ mod tests {
441433
assert_eq!(tlv_stream.quantity_min, None);
442434
assert_eq!(tlv_stream.quantity_max, None);
443435
assert_eq!(tlv_stream.node_id, Some(&pubkey()));
444-
assert_eq!(tlv_stream.refund_for, None);
445436
assert_eq!(tlv_stream.send_invoice, None);
446437
assert_eq!(tlv_stream.signature, None);
447438
}
@@ -754,31 +745,11 @@ mod tests {
754745

755746
#[test]
756747
fn builds_offer_with_send_invoice() {
757-
let refund_for = Some(PaymentHash([0; 32]));
758-
759-
let offer = OfferBuilder::new("foo".into(), Destination::NodeId(pubkey()))
760-
.send_invoice(SendInvoice { refund_for: None })
761-
.build();
762-
let tlv_stream = offer.as_tlv_stream();
763-
assert_eq!(offer.send_invoice(), Some(&SendInvoice { refund_for: None }));
764-
assert_eq!(tlv_stream.refund_for, None);
765-
assert_eq!(tlv_stream.send_invoice, Some(&()));
766-
767-
let offer = OfferBuilder::new("foo".into(), Destination::NodeId(pubkey()))
768-
.send_invoice(SendInvoice { refund_for })
769-
.build();
770-
let tlv_stream = offer.as_tlv_stream();
771-
assert_eq!(offer.send_invoice(), Some(&SendInvoice { refund_for }));
772-
assert_eq!(tlv_stream.refund_for, refund_for.as_ref());
773-
assert_eq!(tlv_stream.send_invoice, Some(&()));
774-
775748
let offer = OfferBuilder::new("foo".into(), Destination::NodeId(pubkey()))
776-
.send_invoice(SendInvoice { refund_for })
777-
.send_invoice(SendInvoice { refund_for: None })
749+
.send_invoice()
778750
.build();
779751
let tlv_stream = offer.as_tlv_stream();
780-
assert_eq!(offer.send_invoice(), Some(&SendInvoice { refund_for: None }));
781-
assert_eq!(tlv_stream.refund_for, None);
752+
assert_eq!(offer.send_invoice(), Some(&SendInvoice));
782753
assert_eq!(tlv_stream.send_invoice, Some(&()));
783754
}
784755
}

0 commit comments

Comments
 (0)