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
Point the Rust Lightning dependency overrides at the unmerged LSPS2 PR revisions and carry the temporary API updates needed for LDK Node to compile against them. Co-Authored-By: HAL 9000
Encode LSPS2 parameters in a shared payment metadata type so both BOLT11 invoices and BOLT12 payment contexts can carry the fee limits needed when handling intercepted payments. Co-Authored-By: HAL 9000
Route BOLT12 payments through the LSPS2-aware router and expose JIT-channel receive flows so offers can carry the LSP invoice parameters needed for intercepted payments. Co-Authored-By: HAL 9000
Exercise fixed, variable, and async BOLT12 receive flows with LSPS2 JIT channels so the payment metadata and fee-limit handling remain covered. Co-Authored-By: HAL 9000
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... |
Based on lightningdevkit/rust-lightning#4463
We implement the LSPS2 flow for BOLT12 and async payments.