Skip to content

Commit 3adeeb0

Browse files
committed
Stop pre-creating PaymentStore entries in Bolt11Payment receive methods
Remove the eager `PaymentStore` insertions from `receive_inner` and `receive_via_jit_channel_inner`. Inbound payment entries will instead be created on demand by the `EventHandler` when the corresponding LDK events arrive. Outbound payment entries (created by `send` / `send_using_amount`) are kept as before so the sender always has a store record immediately after initiating a payment. Generated with the assistance of AI tools. Co-Authored-By: HAL 9000
1 parent 0202964 commit 3adeeb0

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

src/payment/bolt11.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -122,36 +122,6 @@ impl Bolt11Payment {
122122
}
123123
};
124124

125-
let payment_hash = invoice.payment_hash();
126-
let payment_secret = invoice.payment_secret();
127-
let id = PaymentId(payment_hash.0);
128-
let preimage = if manual_claim_payment_hash.is_none() {
129-
// If the user hasn't registered a custom payment hash, we're positive ChannelManager
130-
// will know the preimage at this point.
131-
let res = self
132-
.channel_manager
133-
.get_payment_preimage(payment_hash, payment_secret.clone())
134-
.ok();
135-
debug_assert!(res.is_some(), "We just let ChannelManager create an inbound payment, it can't have forgotten the preimage by now.");
136-
res
137-
} else {
138-
None
139-
};
140-
let kind = PaymentKind::Bolt11 {
141-
hash: payment_hash,
142-
preimage,
143-
secret: Some(payment_secret.clone()),
144-
};
145-
let payment = PaymentDetails::new(
146-
id,
147-
kind,
148-
amount_msat,
149-
None,
150-
PaymentDirection::Inbound,
151-
PaymentStatus::Pending,
152-
);
153-
self.payment_store.insert(payment)?;
154-
155125
Ok(invoice)
156126
}
157127

@@ -209,7 +179,6 @@ impl Bolt11Payment {
209179

210180
// Register payment in payment store.
211181
let payment_hash = invoice.payment_hash();
212-
let payment_secret = invoice.payment_secret();
213182
let lsp_fee_limits = LSPFeeLimits {
214183
max_total_opening_fee_msat: lsp_total_opening_fee,
215184
max_proportional_opening_fee_ppm_msat: lsp_prop_opening_fee,
@@ -225,25 +194,6 @@ impl Bolt11Payment {
225194
};
226195
self.payment_metadata_store.insert(metadata_entry)?;
227196

228-
let preimage =
229-
self.channel_manager.get_payment_preimage(payment_hash, payment_secret.clone()).ok();
230-
let kind = PaymentKind::Bolt11Jit {
231-
hash: payment_hash,
232-
preimage,
233-
secret: Some(payment_secret.clone()),
234-
counterparty_skimmed_fee_msat: None,
235-
lsp_fee_limits,
236-
};
237-
let payment = PaymentDetails::new(
238-
id,
239-
kind,
240-
amount_msat,
241-
None,
242-
PaymentDirection::Inbound,
243-
PaymentStatus::Pending,
244-
);
245-
self.payment_store.insert(payment)?;
246-
247197
// Persist LSP peer to make sure we reconnect on restart.
248198
self.peer_store.add_peer(peer_info)?;
249199

0 commit comments

Comments
 (0)