kernel: add `btck_witness_stack_to_bytes` #36911

pull yuvicc wants to merge 2 commits into bitcoin:master from yuvicc:kernel-witness-stack-to-bytes changing 4 files +39 −0
  1. yuvicc commented at 5:13 AM on November 19, 2026: contributor

    I agree the O(n²) cost of reading a whole witness with btck_witness_stack_get_item_at needs fixing. I'm less sure a new callback type is the best way to do it which #36909 is doing. Instead we could expose the witness's serialized bytes and let the bindings or caller decide how to decode them, this also follows the *_to_bytes functions we already have in the API.

  2. kernel: add btck_witness_stack_to_bytes
    Expose the consensus serialization of a witness stack, so all of its
    items can be read in a single call.
    1df6615612
  3. test: check witness stack serialization in test_kernel 97d464fec3
  4. DrahtBot added the label Validation on Nov 19, 2026
  5. DrahtBot commented at 5:13 AM on November 19, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  6. pzafonte commented at 6:58 PM on November 19, 2026: contributor

    Yuvicc, thanks for putting this up. It looks like it comes down to where the items are decoded. btck_witness_stack_get_items decodes them in the kernel and returns pointers that are valid for the duration of the existence of the witness stack and btck_witness_stack_to_bytes returns the serialization and each binding would decode the items themselves.

    What I'm trying to accomplish is to make an efficient form of the design that the API already has (btck_witness_stack_get_item_at) and to decode once in the kernel so that consumers don't need to reimplement consensus parsing.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-19 19:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me