Merged
Conversation
Contributor
|
Rustfmt is unhappy but otherwise lgtm |
98a78ca to
0718263
Compare
Member
Author
|
oops. ran cargo fmt |
Contributor
This was referenced Sep 11, 2020
Member
Author
|
Thanks! Cherry-picked your commit, let's see if it works now. |
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
dr-orlovsky
suggested changes
Sep 18, 2020
Contributor
dr-orlovsky
left a comment
There was a problem hiding this comment.
Propose to use this diff, which simplifies code a bit:
diff --git a/src/descriptor/create_descriptor.rs b/src/descriptor/create_descriptor.rs
index d36a7cb..6d5a08b 100644
--- a/src/descriptor/create_descriptor.rs
+++ b/src/descriptor/create_descriptor.rs
@@ -24,9 +24,9 @@ use ToPublicKey;
/// NOTE: Miniscript pushes should only be either boolean, 1 or 0, signatures, and hash preimages.
/// As per the current implementation, PUSH_NUM2 results in an error
fn instr_to_stackelem<'txin>(
- ins: &Result<Instruction<'txin>, bitcoin::blockdata::script::Error>,
+ ins: Result<Instruction<'txin>, bitcoin::blockdata::script::Error>,
) -> Result<StackElement<'txin>, Error> {
- match *ins {
+ match ins {
//Also covers the dissatisfied case as PushBytes0
Ok(Instruction::PushBytes(v)) => Ok(StackElement::from(v)),
Ok(Instruction::Op(opcodes::all::OP_PUSHNUM_1)) => Ok(StackElement::Satisfied),
@@ -42,7 +42,7 @@ fn parse_scriptsig_top<'txin>(
) -> Result<(Vec<u8>, Stack<'txin>), Error> {
let stack: Result<Vec<StackElement>, Error> = script_sig
.instructions_minimal()
- .map(|instr| instr_to_stackelem(&instr))
+ .map(instr_to_stackelem)
.collect();
let mut stack = stack?;
if let Some(StackElement::Push(pk_bytes)) = stack.pop() {
@@ -64,7 +64,7 @@ fn verify_p2pk<'txin>(
if let Ok(pk) = bitcoin::PublicKey::from_slice(&pk_bytes[1..script_pubkey_len - 1]) {
let stack: Result<Vec<StackElement>, Error> = script_sig
.instructions_minimal()
- .map(|instr| instr_to_stackelem(&instr))
+ .map(instr_to_stackelem)
.collect();
if !witness.is_empty() {
Err(Error::NonEmptyWitness)
@@ -228,7 +228,7 @@ pub fn from_txin_with_witness_stack<'txin>(
//bare
let stack: Result<Vec<StackElement>, Error> = script_sig
.instructions_minimal()
- .map(|instr| instr_to_stackelem(&instr))
+ .map(instr_to_stackelem)
.collect();
if !witness.is_empty() {
return Err(Error::NonEmptyWitness);| let stack: Result<Vec<StackElement>, Error> = script_sig | ||
| .iter(true) | ||
| .instructions_minimal() | ||
| .map(|instr| instr_to_stackelem(&instr)) |
Contributor
There was a problem hiding this comment.
Why not simply .map(instr_to_stackelem)? I tried locally, it compiles well with all versions, starting from MSRV
Member
There was a problem hiding this comment.
I think this is unrelated to the intent of the PR. It is indeed a useful simplification. Can you raise another PR for this?
sanket1729
approved these changes
Sep 18, 2020
Member
Author
|
Can you make a commit with these changes that I can cherry-pick? |
Contributor
|
@apoelstra here it is: #133 |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.