lightningdevkit / rust-lightning

A highly modular Bitcoin Lightning library written in Rust. It's rust-lightning, not Rusty's Lightning!
Other
1.14k stars 358 forks source link

Base32 followups, Features serialization #3308

Open optout21 opened 1 week ago

optout21 commented 1 week ago

Some followups to Base32/Bech32 changes #3270

Bolt11InvoiceFeatures are serialized to 5-bit values internally, but in a way that is not compatible with Bech32. The grouping of bits is done in reverse (both byte order and bit order). The current native implementation could be switch to be based on rust-bech32 (increased reuse), and iterative approach (less allocations). See: https://github.com/lightningdevkit/rust-lightning/pull/3270#discussion_r1746676131

Change fn from_base32(b32: &[Fe32]) to take iterator instead of slice; see https://github.com/lightningdevkit/rust-lightning/pull/3270#discussion_r1750763305

Also: (minor) https://github.com/lightningdevkit/rust-lightning/pull/3270#discussion_r1755635294

TheBlueMatt commented 1 week ago

Also, after we bump our MSRV we can drop all the Boxes we added in serialization.

optout21 commented 3 days ago

In rust-bech32, option with no-trimming 5-bit-to-8-bit conversion is on its way. When it's available (in a new release), the pre-padding in LDK can be removed -- in Bolt11Features serialization and in invoice hash computation. https://github.com/rust-bitcoin/rust-bech32/pull/201