-
Notifications
You must be signed in to change notification settings - Fork 152
update rust-bitcoin to 0.24.0 #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rustfmt is unhappy but otherwise lgtm |
98a78ca
to
0718263
Compare
oops. ran cargo fmt |
Thanks! Cherry-picked your commit, let's see if it works now. |
Signed-off-by: Antoine Poinsot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
@@ -39,7 +41,7 @@ fn parse_scriptsig_top<'txin>( | |||
script_sig: &'txin bitcoin::Script, | |||
) -> Result<(Vec<u8>, Stack<'txin>), Error> { | |||
let stack: Result<Vec<StackElement>, Error> = script_sig | |||
.iter(true) | |||
.instructions_minimal() | |||
.map(|instr| instr_to_stackelem(&instr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply .map(instr_to_stackelem)
? I tried locally, it compiles well with all versions, starting from MSRV
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unrelated to the intent of the PR. It is indeed a useful simplification. Can you raise another PR for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #133
Can you make a commit with these changes that I can cherry-pick? |
@apoelstra here it is: #133 |
No description provided.