Skip to content

Commit

Permalink
mempool std sig op count check
Browse files Browse the repository at this point in the history
  • Loading branch information
0xA001113 committed Oct 23, 2024
1 parent 6799c51 commit 01db7eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions crypto/txscript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn parse_script<T: VerifiableTransaction, Reused: SigHashReusedValues>(
script.iter().batching(|it| deserialize_next_opcode(it))
}

#[must_use]
pub fn get_sig_op_count<T: VerifiableTransaction, Reused: SigHashReusedValues>(
signature_script: &[u8],
prev_script_public_key: &ScriptPublicKey,
Expand Down
2 changes: 1 addition & 1 deletion mining/errors/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub enum NonStandardError {
RejectInsufficientFee(TransactionId, u64, u64),

#[error("transaction input #{1} has {2} signature operations which is more than the allowed max amount of {3}")]
RejectSignatureCount(TransactionId, usize, u8, u8),
RejectSignatureCount(TransactionId, usize, u64, u8),
}

impl NonStandardError {
Expand Down
5 changes: 2 additions & 3 deletions mining/src/mempool/check_transaction_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ impl Mempool {
ScriptClass::PubKey => {}
ScriptClass::PubKeyECDSA => {}
ScriptClass::ScriptHash => {
get_sig_op_count::<PopulatedTransaction, SigHashReusedValuesUnsync>(
let num_sig_ops = get_sig_op_count::<PopulatedTransaction, SigHashReusedValuesUnsync>(
&input.signature_script,
&entry.script_public_key,
);
let num_sig_ops = 1;
if num_sig_ops > MAX_STANDARD_P2SH_SIG_OPS {
if num_sig_ops > MAX_STANDARD_P2SH_SIG_OPS as u64 {
return Err(NonStandardError::RejectSignatureCount(transaction_id, i, num_sig_ops, MAX_STANDARD_P2SH_SIG_OPS));
}
}
Expand Down

0 comments on commit 01db7eb

Please sign in to comment.