Skip to content

Commit 7ae7596

Browse files
committed
Merge #756: feat: add MaxBareScriptSizeExceeded err for bare consensus check
834bd3d feat: add MaxBareScriptSizeExceeded err for bare consensus check (ChrisCho-H) Pull request description: `BareCtx` consensus validity check returns `MaxWitnessScriptSizeExceeded` err when exceeding script size limit, which is wrong and confusing. Adding `MaxBareScriptSizeExceeded` and using it instead can clearly give a correct message on compile error. ACKs for top commit: apoelstra: ACK 834bd3d; successfully ran local tests; Yeah, this seems like a good idea Tree-SHA512: 4dae0617bdaf1aee7ffd74875471a9dc550b4e3fdd4499894d4172c047f8dbf8b3ca5dff92868999f2ed0356400b9327003b6ac249cd428606204dc5f0506c04
2 parents 1e40a8d + 834bd3d commit 7ae7596

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/miniscript/context.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ pub enum ScriptContextError {
5252
/// The Miniscript (under p2sh context) corresponding Script would be
5353
/// larger than `MAX_SCRIPT_ELEMENT_SIZE` bytes.
5454
MaxRedeemScriptSizeExceeded,
55+
/// The Miniscript(under bare context) corresponding
56+
/// Script would be larger than `MAX_SCRIPT_SIZE` bytes.
57+
MaxBareScriptSizeExceeded,
5558
/// The policy rules of bitcoin core only permit Script size upto 1650 bytes
5659
MaxScriptSigSizeExceeded,
5760
/// Impossible to satisfy the miniscript under the current context
@@ -80,6 +83,7 @@ impl error::Error for ScriptContextError {
8083
| MaxOpCountExceeded
8184
| MaxWitnessScriptSizeExceeded
8285
| MaxRedeemScriptSizeExceeded
86+
| MaxBareScriptSizeExceeded
8387
| MaxScriptSigSizeExceeded
8488
| ImpossibleSatisfaction
8589
| TaprootMultiDisabled
@@ -127,6 +131,11 @@ impl fmt::Display for ScriptContextError {
127131
"The Miniscript corresponding Script would be larger than \
128132
MAX_SCRIPT_ELEMENT_SIZE bytes."
129133
),
134+
ScriptContextError::MaxBareScriptSizeExceeded => write!(
135+
f,
136+
"The Miniscript corresponding Script would be larger than \
137+
MAX_SCRIPT_SIZE bytes."
138+
),
130139
ScriptContextError::MaxScriptSigSizeExceeded => write!(
131140
f,
132141
"At least one satisfaction in Miniscript would be larger than \
@@ -740,7 +749,7 @@ impl ScriptContext for BareCtx {
740749
match node_checked {
741750
Ok(_) => {
742751
if ms.ext.pk_cost > MAX_SCRIPT_SIZE {
743-
Err(ScriptContextError::MaxWitnessScriptSizeExceeded)
752+
Err(ScriptContextError::MaxBareScriptSizeExceeded)
744753
} else {
745754
Ok(())
746755
}

src/miniscript/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ mod tests {
16941694
);
16951695
assert_eq!(
16961696
bare_multi_ms.unwrap_err().to_string(),
1697-
"The Miniscript corresponding Script would be larger than MAX_STANDARD_P2WSH_SCRIPT_SIZE bytes."
1697+
"The Miniscript corresponding Script would be larger than MAX_SCRIPT_SIZE bytes."
16981698
);
16991699
}
17001700
}

0 commit comments

Comments
 (0)