Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rename stackelem to stack_elem #411

Merged
merged 1 commit into from
May 19, 2022
Merged
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
18 changes: 9 additions & 9 deletions src/interpreter/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn pk_from_slice(slice: &[u8], require_compressed: bool) -> Result<bitcoin::Publ
}
}

fn pk_from_stackelem(
fn pk_from_stack_elem(
elem: &stack::Element<'_>,
require_compressed: bool,
) -> Result<bitcoin::PublicKey, Error> {
Expand All @@ -49,7 +49,7 @@ fn pk_from_stackelem(

// Parse the script with appropriate context to check for context errors like
// correct usage of x-only keys or multi_a
fn script_from_stackelem<Ctx: ScriptContext>(
fn script_from_stack_elem<Ctx: ScriptContext>(
elem: &stack::Element<'_>,
) -> Result<Miniscript<Ctx::Key, Ctx>, Error> {
match *elem {
Expand Down Expand Up @@ -141,7 +141,7 @@ pub(super) fn from_txdata<'txin>(
} else {
match ssig_stack.pop() {
Some(elem) => {
let pk = pk_from_stackelem(&elem, false)?;
let pk = pk_from_stack_elem(&elem, false)?;
if *spk == bitcoin::Script::new_p2pkh(&pk.to_pubkeyhash().into()) {
Ok((
Inner::PublicKey(pk.into(), PubkeyType::Pkh),
Expand All @@ -162,7 +162,7 @@ pub(super) fn from_txdata<'txin>(
} else {
match wit_stack.pop() {
Some(elem) => {
let pk = pk_from_stackelem(&elem, true)?;
let pk = pk_from_stack_elem(&elem, true)?;
if *spk == bitcoin::Script::new_v0_p2wpkh(&pk.to_pubkeyhash().into()) {
Ok((
Inner::PublicKey(pk.into(), PubkeyType::Wpkh),
Expand All @@ -183,7 +183,7 @@ pub(super) fn from_txdata<'txin>(
} else {
match wit_stack.pop() {
Some(elem) => {
let miniscript = script_from_stackelem::<Segwitv0>(&elem)?;
let miniscript = script_from_stack_elem::<Segwitv0>(&elem)?;
let script = miniscript.encode();
let miniscript = miniscript.to_no_checks_ms();
let scripthash = sha256::Hash::hash(&script[..]);
Expand Down Expand Up @@ -233,7 +233,7 @@ pub(super) fn from_txdata<'txin>(
let tap_script = wit_stack.pop().ok_or(Error::UnexpectedStackEnd)?;
let ctrl_blk =
ControlBlock::from_slice(ctrl_blk).map_err(Error::ControlBlockParse)?;
let tap_script = script_from_stackelem::<Tap>(&tap_script)?;
let tap_script = script_from_stack_elem::<Tap>(&tap_script)?;
let ms = tap_script.to_no_checks_ms();
// Creating new contexts is cheap
let secp = bitcoin::secp256k1::Secp256k1::verification_only();
Expand Down Expand Up @@ -274,7 +274,7 @@ pub(super) fn from_txdata<'txin>(
if !ssig_stack.is_empty() {
Err(Error::NonEmptyScriptSig)
} else {
let pk = pk_from_stackelem(&elem, true)?;
let pk = pk_from_stack_elem(&elem, true)?;
if slice
== &bitcoin::Script::new_v0_p2wpkh(
&pk.to_pubkeyhash().into(),
Expand Down Expand Up @@ -302,7 +302,7 @@ pub(super) fn from_txdata<'txin>(
Err(Error::NonEmptyScriptSig)
} else {
// parse wsh with Segwitv0 context
let miniscript = script_from_stackelem::<Segwitv0>(&elem)?;
let miniscript = script_from_stack_elem::<Segwitv0>(&elem)?;
let script = miniscript.encode();
let miniscript = miniscript.to_no_checks_ms();
let scripthash = sha256::Hash::hash(&script[..]);
Expand All @@ -324,7 +324,7 @@ pub(super) fn from_txdata<'txin>(
}
}
// normal p2sh parsed in Legacy context
let miniscript = script_from_stackelem::<Legacy>(&elem)?;
let miniscript = script_from_stack_elem::<Legacy>(&elem)?;
let script = miniscript.encode();
let miniscript = miniscript.to_no_checks_ms();
if wit_stack.is_empty() {
Expand Down