Add Eclair support to invoice_deserialization target
We need to integrate Eclair’s BOLT11 invoice parsing into our existing invoice_deserialization target. Unlike other Lightning implementations, Eclair is written in Scala and runs on the JVM, introducing unique challenges for integration.
Hi @erickcestari , can I work on the issue? From Summer of Bitcoin
Hi @erickcestari , can I work on the issue? From Summer of Bitcoin
Hi @Lymah123, yes, feel free to take this on! Just a heads-up that this might be a bit challenging if you're looking for a good first issue. Let me know if you need any guidance along the way!
I agree with @erickcestari. Go ahead, @Lymah123. However, I believe we could discuss the approach here first before you implement it, this way we can avoid waste of time (especially yours).
Thank you, @erickcestari and @brunoerg. I will send over my approach and seek your insights before implementing anything.
Objective The task is to enhance the invoice_deserialization target in the existing C++ fuzzing framework (found in driver.cpp) to parse BOLT11 invoices in a way that matches Eclair’s implementation. Since Eclair is Scala-based and runs on the JVM, while our system is C++, we need a strategy to bridge this gap effectively. Current Framework Overview File: driver.cpp contains the Driver class, which manages fuzzing targets.
Target: InvoiceDeserializationTarget processes a buffer, converts it to a string, and calls deserialize_invoice on each loaded module.
Modules: Derived from BaseModule, they implement deserialize_invoice(const std::string&) returning std::optional
Behavior: The target ensures consistency across modules via assertions.
Our integration must fit this modular structure and replicate Eclair’s BOLT11 parsing logic.
Proposed Strategy
After exploring the codebase, I located the inovice_deserialization Target in the driver.cpp file. The target is located in the Driver class and the relevant function is InvoiceDeserializationTarget
Given the language mismatch (Scala vs. C++), here are the viable approaches
- Create a Scala object to parse BOLT11 invoices using Eclair.
- Compile the Scala code into a JAR file
- Create a Java Native I bridge to call the EclairParser.parseInvoice function.
- Modify the InvoiceDeserializationTarget function to call the Eclair parser through the JNI bridge.
Hi, @erickcestari and @erickcestari. That is what I was able to come up with after checked the codebase. Looking forward to your responses.
4. Modify the InvoiceDeserializationTarget function to call the Eclair parser through the JNI bridge
I think it's a good approach. However, you don't need to modify the InvoiceDeserializationTarget function. Instead, you should create a new module in BitcoinFuzz and implement the deserialize_invoice function in module.cpp. This function will then call the Eclair parser via the JNI bridge.
Alright. Thanks for that.
@erickcestari and @brunoerg . Does this mean I can proceed with the implementation? Thank you.
Alright. Thanks for that.
@erickcestari and @brunoerg . Does this mean I can proceed with the implementation? Thank you.
Yes, you can proceed with the implementation. Let us know if you need any further clarification. Thanks!
Alright. Thanks for that. @erickcestari and @brunoerg . Does this mean I can proceed with the implementation? Thank you.
Yes, you can proceed with the implementation. Let us know if you need any further clarification. Thanks!
Alright, thank you.
How is going @Lymah123?
Hi @brunoerg , it is going well. I will submit a PR for it this week. Sorry, I was sick that's why. But I am fine now. I already started working on it. Sorry about that.