Skip to content

Commit

Permalink
feat: add MaxBareScriptSizeExceeded err for bare consensus check
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCho-H committed Oct 16, 2024
1 parent 1e40a8d commit 834bd3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/miniscript/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub enum ScriptContextError {
/// The Miniscript (under p2sh context) corresponding Script would be
/// larger than `MAX_SCRIPT_ELEMENT_SIZE` bytes.
MaxRedeemScriptSizeExceeded,
/// The Miniscript(under bare context) corresponding
/// Script would be larger than `MAX_SCRIPT_SIZE` bytes.
MaxBareScriptSizeExceeded,
/// The policy rules of bitcoin core only permit Script size upto 1650 bytes
MaxScriptSigSizeExceeded,
/// Impossible to satisfy the miniscript under the current context
Expand Down Expand Up @@ -80,6 +83,7 @@ impl error::Error for ScriptContextError {
| MaxOpCountExceeded
| MaxWitnessScriptSizeExceeded
| MaxRedeemScriptSizeExceeded
| MaxBareScriptSizeExceeded
| MaxScriptSigSizeExceeded
| ImpossibleSatisfaction
| TaprootMultiDisabled
Expand Down Expand Up @@ -127,6 +131,11 @@ impl fmt::Display for ScriptContextError {
"The Miniscript corresponding Script would be larger than \
MAX_SCRIPT_ELEMENT_SIZE bytes."
),
ScriptContextError::MaxBareScriptSizeExceeded => write!(
f,
"The Miniscript corresponding Script would be larger than \
MAX_SCRIPT_SIZE bytes."
),
ScriptContextError::MaxScriptSigSizeExceeded => write!(
f,
"At least one satisfaction in Miniscript would be larger than \
Expand Down Expand Up @@ -740,7 +749,7 @@ impl ScriptContext for BareCtx {
match node_checked {
Ok(_) => {
if ms.ext.pk_cost > MAX_SCRIPT_SIZE {
Err(ScriptContextError::MaxWitnessScriptSizeExceeded)
Err(ScriptContextError::MaxBareScriptSizeExceeded)
} else {
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/miniscript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ mod tests {
);
assert_eq!(
bare_multi_ms.unwrap_err().to_string(),
"The Miniscript corresponding Script would be larger than MAX_STANDARD_P2WSH_SCRIPT_SIZE bytes."
"The Miniscript corresponding Script would be larger than MAX_SCRIPT_SIZE bytes."
);
}
}
Expand Down

0 comments on commit 834bd3d

Please sign in to comment.