Skip to content
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

feat: add MaxBareScriptSizeExceeded err for bare consensus check #756

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading