Skip to content

Commit 7f7ae30

Browse files
committed
f Account for new variants, don't register payment in receive
1 parent eaf10ae commit 7f7ae30

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/payment/bolt12.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ impl Bolt12Payment {
8888
payee_pubkey
8989
);
9090

91-
let kind = PaymentKind::Bolt12 { hash: None, preimage: None, secret: None };
91+
let kind = PaymentKind::Bolt12Offer {
92+
hash: None,
93+
preimage: None,
94+
secret: None,
95+
offer_id: offer.id(),
96+
};
9297
let payment = PaymentDetails {
9398
id: payment_id,
9499
kind,
@@ -105,7 +110,12 @@ impl Bolt12Payment {
105110
match e {
106111
Bolt12SemanticError::DuplicatePaymentId => Err(Error::DuplicatePayment),
107112
_ => {
108-
let kind = PaymentKind::Bolt12 { hash: None, preimage: None, secret: None };
113+
let kind = PaymentKind::Bolt12Offer {
114+
hash: None,
115+
preimage: None,
116+
secret: None,
117+
offer_id: offer.id(),
118+
};
109119
let payment = PaymentDetails {
110120
id: payment_id,
111121
kind,
@@ -181,7 +191,12 @@ impl Bolt12Payment {
181191
payee_pubkey
182192
);
183193

184-
let kind = PaymentKind::Bolt12 { hash: None, preimage: None, secret: None };
194+
let kind = PaymentKind::Bolt12Offer {
195+
hash: None,
196+
preimage: None,
197+
secret: None,
198+
offer_id: offer.id(),
199+
};
185200
let payment = PaymentDetails {
186201
id: payment_id,
187202
kind,
@@ -198,7 +213,12 @@ impl Bolt12Payment {
198213
match e {
199214
Bolt12SemanticError::DuplicatePaymentId => Err(Error::DuplicatePayment),
200215
_ => {
201-
let kind = PaymentKind::Bolt12 { hash: None, preimage: None, secret: None };
216+
let kind = PaymentKind::Bolt12Offer {
217+
hash: None,
218+
preimage: None,
219+
secret: None,
220+
offer_id: offer.id(),
221+
};
202222
let payment = PaymentDetails {
203223
id: payment_id,
204224
kind,
@@ -230,17 +250,6 @@ impl Bolt12Payment {
230250
Error::OfferCreationFailed
231251
})?;
232252

233-
let id = PaymentId(offer.id().0);
234-
let payment = PaymentDetails {
235-
id,
236-
kind: PaymentKind::Bolt12 { hash: None, preimage: None, secret: None },
237-
amount_msat: Some(amount_msat),
238-
direction: PaymentDirection::Inbound,
239-
status: PaymentStatus::Pending,
240-
};
241-
242-
self.payment_store.insert(payment)?;
243-
244253
Ok(offer)
245254
}
246255

@@ -256,17 +265,6 @@ impl Bolt12Payment {
256265
Error::OfferCreationFailed
257266
})?;
258267

259-
let id = PaymentId(offer.id().0);
260-
let payment = PaymentDetails {
261-
id,
262-
kind: PaymentKind::Bolt12 { hash: None, preimage: None, secret: None },
263-
amount_msat: None,
264-
direction: PaymentDirection::Inbound,
265-
status: PaymentStatus::Pending,
266-
};
267-
268-
self.payment_store.insert(payment)?;
269-
270268
Ok(offer)
271269
}
272270
}

0 commit comments

Comments
 (0)