-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
As part of #1698 (and earlier versions of the PR), it was pointed out that tools like Rust's bindgen
can correctly infer fixed length array arguments when the function signature uses (*arg)[size]
. This was discussed, along with possible alternatives, here: https://gnusha.org/secp256k1/2024-11-18.log.
I was able to confirm that the only (*arg)[size]
works with bindgen here, and decided to see what this would look like for the silent payments module and downstream consumers in josibake@5a10880 and josibake/bitcoin@5835d98. The patches are smaller than I expected and I was happy to see everything Just Worked ™️.
I'm opening this issue for general discussion since this would be a breaking change from the current API. This means we either:
- Only use this in convention in the silent payments module
- Use this convention in the silent payments module and new modules going forward
- Convert the rest of the API to use this convention
I do think having compile time errors for incorrectly sized arguments is quite nice and helps eliminate a whole class of errors, e.g., mixing up argument order and passing a secret key 32 byte array instead of a smallest outpoint 36 byte array, which is why I'm inclined to use this convention in the silent payments module. However, I'd like to hear the maintainers thoughts on having modules with different conventions in their respective API's, or the longer term appetite for converting the whole library to use the new convention.