[Feature] Compressed Descriptor Format Decoder (#791)#919
Conversation
|
Any coordinators that support this output descriptor encoding/decoding? |
|
Can we make the system return an error if the data is incomplete? Right now, it processes partial data instead of stopping immediately? |
|
@newtonick Not yet! Since this format was proposed on the Delving Bitcoin research forums, no major coordinators have adopted it in their live releases yet. I put this together mostly as an experimental proof-of-concept. I wanted to see if it was possible to decode the compressed format in pure Python natively and keep the footprint tiny (~150 LOC). I'm totally fine leaving this as an open draft, or even closing it for now if you think it's too early. I just wanted to explore the math and get a head start on solving the dense QR scanning issues in case coordinators decide to adopt this standard in the future. |
|
@itssaharsh I skipped adding strict boundary and underflow checks for this initial push because I was just experimenting with whether the pure Python math worked, and I wanted to keep the PR extremely minimal and readable as a Proof of Concept. Since this is strictly an experimental draft right now, I didn't want to get bogged down in deep error handling just yet. |
Description
Problem or Issue being addressed
Targets #791
Josh Doman published a project in Rust that achieves a 30-40% size reduction for Bitcoin output descriptors by using a binary tag and LEB128 variable-length integer encoding. I tried to replicate this natively in Python.
Solution
This PR introduces a minimal proof of concept for the decoder, strictly isolated to
src/seedsigner/helpers/descriptor_codec.py.ByteStreamclass that recursively consumes Template bytes while sliding along the Payload buffer.Wsh,Sh,SortedMulti,CompressedFullKey, andXPubprimitive tags.tests/test_descriptor_codec.pyintercepts the raw encoded hex from the Rust reference library's most complex integration test and asserts that our pure Python codec identically reconstructs the string format. More tests can be added if this direction is relevant.Additional Information
This is explicitly a Draft to request feedback before taking any next step and validation if this direction is still a relevant priority for the project. If given the green flag, I can work on this PR to actually integrate this.
Screenshots
Currently N/A. No UI/functionality changes were made.
This pull request is categorized as a:
Checklist
I ran
pytestlocallyI included screenshots of any new or modified screens
Should be part of the PR description above.
I added or updated tests
Any new or altered functionality should be covered in a unit test. Any new or updated sequences require FlowTests.
I tested this PR hands-on on the following platform(s):
I have reviewed these notes:
Thank you! Please join our Devs' Telegram group to get more involved.
Part of Summer of Bitcoin