Skip to content

Conversation

apoelstra
Copy link
Member

The last commit, which renames parse_with_ext to decode_with_ext, I think we should backport with deprecation to 12.x. This is a pretty uncommonly used function and is unlikely to bother anybody, but the current name is inconsistent with our general use of "parse" for strings and "decode" for scripts.

This is a little less space efficient but it gets rid of a lifetime
parameter on the lexer token, which is annoying because it prevents us
from putting it into error types. (Currently we convert it to a string
before putting it into an error.)

It also eliminates a whole bunch of panics where we convert slices to
hashes and .expect() on the length being right, when we know it's right.
Also clean up the names and format messages for them.
…onstructors

We have infallible constructors for all the terminals except
multi/multia. We should use them and eliminate a bunch of error paths.
The word "parse" is redundant at best, and wrong at worst (we use
"decode" when converting a script and "parse" when converting a string).
The variants were also overly verbose and the formatting text lost
information. Clean all this up.
We should backport this one to 12.x (with a deprecation). Would also be
open to doing a deprecation here in master. But this has been bugging me
for years, and also it's much less common to decode miniscript from
script than we imagined back in 2018.

Provides symmetry with encode() and consistency with the docs (though
this PR does not fix up the docs).
Copy link
Member Author

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On cdb36c1 successfully ran local tests

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK cdb36c1

@apoelstra apoelstra merged commit 2ca5a35 into rust-bitcoin:master Aug 7, 2025
31 checks passed
@apoelstra apoelstra deleted the 2025-07/decode branch August 7, 2025 17:53
heap-coder added a commit to heap-coder/rust-miniscript that referenced this pull request Sep 27, 2025
…s of the decoder and its errors

cdb36c19b536ef8d8716dd1423e7e6b96433101e miniscript: rename parse_* functions to decode_* (Andrew Poelstra)
5fea2b3cee70f02b18f1d6fbba7b777ab329e7b1 miniscript: rename and cleanup decode::KeyParseError (Andrew Poelstra)
a57fab3ca26a20140a90b8ca66408c9246fdf9cd miniscript: replace many calls to reduce0 in decode with infallible constructors (Andrew Poelstra)
5b736bdede89b15866659c4d38383db4af4240cd miniscript: move lexer errors into their own type (Andrew Poelstra)
ceadd0d4d98bf8f7bc2a80f1727769cb9e442f9a miniscript: use byte arrays in lexer (Andrew Poelstra)

Pull request description:

  The last commit, which renames `parse_with_ext` to `decode_with_ext`, I think we should backport with deprecation to 12.x. This is a pretty uncommonly used function and is unlikely to bother anybody, but the current name is inconsistent with our general use of "parse" for strings and "decode" for scripts.


ACKs for top commit:
  sanket1729:
    ACK cdb36c19b536ef8d8716dd1423e7e6b96433101e


Tree-SHA512: 8a3563dd23e49cf9331b299e237337a3d1097c15d5fe143ec9aa3f686d681fda077f019b25f0d66fccdd9a88ec489a84e144fcbb28410a671eb113f38e0fe58d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants