-
Notifications
You must be signed in to change notification settings - Fork 117
fix(UTXO): remove extra opcode check in scriptSig signature parsing function #2591
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,12 +537,9 @@ impl Script { | |
| /// Usable for P2PK and P2PKH scripts. | ||
| pub fn extract_signature(&self) -> Result<Vec<u8>, String> { | ||
| match self.get_instruction(0) { | ||
| Some(Ok(instruction)) => match instruction.opcode { | ||
| Opcode::OP_PUSHBYTES_70 | Opcode::OP_PUSHBYTES_71 | Opcode::OP_PUSHBYTES_72 => match instruction.data { | ||
| Some(bytes) => Ok(bytes.to_vec()), | ||
| None => Err(format!("No data at instruction 0 of script {self:?}")), | ||
| }, | ||
| opcode => Err(format!("Unexpected opcode {opcode:?}")), | ||
| Some(Ok(instruction)) => match instruction.data { | ||
| Some(bytes) if !bytes.is_empty() => Ok(bytes.to_vec()), | ||
|
mariocynicys marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's not do the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to have at least one byte in this data because we will send a slice of len-1 of it to SecpSignature::from_der fn.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooh. nice catch. this -1 seems a lil bit dangerous. maybe we could use .saturating_sub in this situation.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed to saturating_sub, thanks |
||
| Some(_) | None => Err(format!("No data at instruction 0 of script {self:?}")), | ||
| }, | ||
| Some(Err(e)) => Err(format!("Error {e} on getting instruction 0 of script {self:?}")), | ||
| None => Err(format!("None instruction 0 of script {self:?}")), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.