Closed rajarshimaitra closed 8 months ago
What is a "Lightning Descriptor Template"?
I don't think we actually store the descriptor anywhere?
@afilini would you be able to elaborate on this?
The problem is that afaik the BOLT 3 scripts can't be expressed using descriptors, or rather they can, but when encoded they produce different bitcoin scripts which makes them incompatible with the current lightning protocol.
The idea is to take advantage of the DescriptorTrait
from rust-miniscript
: it should be possible to implement this manually for a given struct and then we can update bdk to take a generic type that implements the trait instead of just requiring a Descriptor
.
Long story short, if you want to use bdk to build lightning transactions you can write a struct, implement the trait and bdk will be able to generate the right scripts, spend from them, etc.
I think the "first stage" should just be to update bdk to take or at least store internally a generic type that implements the trait.
The "second stage" could be to also provide the structs which implement the trait for lightning, but in my opinion that should go in a separate package (like bdk-lightning or something).
This would be very useful in general to help people migrate to bdk: for instance, Blockstream Green uses a script that is essentially a 2-of-2 which after a while becomes a 1-of-2 that the user can spend by itself. To optimize the size of the script they used a weird op-code (I think OP_DEPTH), so if they represent the same policy as a descriptor they get out a different script.
With this generic trait thing it would be possible for them to migrate to bdk by implementing the trait to return the right script manually (not that they are thinking/planning to do so, I'm just taking them as an example because I know the product very well)
As with https://github.com/bitcoindevkit/bdk/issues/486, I think this project is also in the high difficulty zone, and will need a lot of context for students to tackle this.
I don't think I have done justice in the project description. @afilini if you can send me a small description of the full context and possible approach for it, that would be really great.
Looking back at this, I think this is not necessarily hard in terms of Bitcoin knowledge required, but it is pretty technical in rust terms because there are generic types and traits involved.
I'm just putting this out as a note for students looking into this task, I think this would be hard for you if you are not familiar with rust and its type system
Closing this issue since we don't have anyone to mentor it this year, can reopen next year if we have more folks who can mentor.
Description
In order for BDK to extend beyond just a Bitcoin wallet, it needs a more powerful descriptor capability. This project aims at improving the descriptors used in the library. Instead of having a concrete descriptor type, design a descriptor trait that can be implemented on any generic structure. This will allow it to have more powerful descriptors, which will help in more advanced applications of BDK, as well as the Bitcoin wallet descriptor ecosystem further, like having a “Lightning Descriptor Template”, etc. **Expected Outcomes** - Through understanding of [descriptors](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md). - Basic understanding of the [rust-miniscript](https://github.com/rust-bitcoin/rust-miniscript) library. - A descriptor trait in BDK library, that can be implemented for any generic structures. **Resources** **Skills Required**Mentor(s)
Difficulty : Hard
Competency Test (optional)