Skip to content

Option for Fe32->bytes conversion (fes_to_bytes) to not drop last partial values #198

@optout21

Description

@optout21

This is a minor feature request:
The Fe32->bytes conversion -- fes_to_bytes in primitives/iter.rs -- drops the last incomplete byte:

If the total number of bits is not a multiple of 8, any trailing bits are simply dropped

In some use cases padding with 0 bits is needed (rather than dropping bits). Currently this can be achieved by appending the input with 0, 1, or 2 0 values (depending the input length), before doing the conversion.
It would be nice if this is provided as a possibility in conversion (e.g. by a different method fes_to_bytes_pad or an parameter flag).

An example with pre-padding is here: https://github.com/lightningdevkit/rust-lightning/blob/main/lightning-invoice/src/lib.rs#L963

If the idea is accepted/clarified, I can prepare a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions