Add BOLT12 support to LSPS2 flow#817
Conversation
|
🎉 This PR is now ready for review! |
c62ca3a to
b0eef7c
Compare
2210e23 to
db9b5ae
Compare
f894fad to
2fb92ba
Compare
2fb92ba to
fc22dd0
Compare
jkczyz
left a comment
There was a problem hiding this comment.
Doesn't look like HAL 9000 likes to wrap commit messages.
|
|
||
| impl LSPS2Bolt12PaymentMetadataDecoder for LdkNodeLSPS2Bolt12PaymentMetadataDecoder { | ||
| fn decode_lsps2_invoice_parameters( | ||
| &self, payment_metadata: &BTreeMap<u64, Vec<u8>>, |
There was a problem hiding this comment.
Maybe have LdkNodeLSPS2Bolt12PaymentMetadataDecoder wrap &BTreeMap<u64, Vec<u8>>?
| payment_metadata | ||
| .get(&LDK_NODE_BOLT12_PAYMENT_METADATA_KEY) | ||
| .and_then(|encoded| PaymentMetadata::read(&mut &encoded[..]).ok()) | ||
| .and_then(|metadata| metadata.lsps2_bolt12_invoice_parameters) | ||
| .into_iter() | ||
| .collect() |
There was a problem hiding this comment.
I assume this wants to return a Vec to support multiple LSPs? How do we plan to support that in PaymentMetadata?
| let mut offer_builder = if let Some(payment_metadata) = payment_metadata { | ||
| self.channel_manager.create_offer_builder_using_router(PaymentMetadataMessageRouter { | ||
| inner: Arc::clone(&self.message_router), | ||
| payment_metadata, | ||
| }) | ||
| } else { | ||
| self.channel_manager.create_offer_builder() | ||
| } | ||
| .map_err(|e| { | ||
| log_error!(self.logger, "Failed to create offer builder: {:?}", e); | ||
| Error::OfferCreationFailed | ||
| })?; | ||
|
|
||
| if let Some(expiry_secs) = expiry_secs { | ||
| let absolute_expiry = (SystemTime::now() + Duration::from_secs(expiry_secs as u64)) | ||
| .duration_since(UNIX_EPOCH) | ||
| .unwrap(); | ||
| offer_builder = offer_builder.absolute_expiry(absolute_expiry); | ||
| } | ||
|
|
||
| offer_builder.description(description.to_string()).build().map_err(|e| { | ||
| log_error!(self.logger, "Failed to create offer: {:?}", e); | ||
| Error::OfferCreationFailed | ||
| }) |
| Arc<Logger>, | ||
| Arc<KeysManager>, | ||
| >; | ||
| pub(crate) type MessageRouter = InnerMessageRouter; |
There was a problem hiding this comment.
Why not PaymentMetadataMessageRouter?
I really need to set some strict git commit hook scripts... |
Point the Rust Lightning overrides at the unmerged LSPS2 PRs and carry the temporary API updates needed to compile LDK Node. Co-Authored-By: HAL 9000
Use the rebased Rust Lightning LSPS2 branch revision. Co-Authored-By: HAL 9000
Co-Authored-By: HAL 9000
Encode LSPS2 parameters in shared payment metadata, so BOLT11 invoices and BOLT12 contexts can carry fee limits for intercepted payments. Co-Authored-By: HAL 9000
Route BOLT12 payments through the LSPS2-aware router and expose JIT-channel receive flows with the LSP invoice parameters needed for intercepted payments. Co-Authored-By: HAL 9000
Use the lower-level readiness future before fetching the async offer. This keeps LSPS2 JIT receive compatible with the LDK API cleanup. Co-Authored-By: HAL 9000
Exercise fixed, variable, and async BOLT12 receive flows with LSPS2 JIT channels, payment metadata, and fee-limit handling. Co-Authored-By: HAL 9000
Use the multi-LSP builder APIs introduced on main in the LSPS2 BOLT12 tests. Co-Authored-By: HAL 9000
fc22dd0 to
8d1efeb
Compare
Based on lightningdevkit/rust-lightning#4463
We implement the LSPS2 flow for BOLT12 and async payments.