Skip to content

Commit

Permalink
Use Amount for verify_with_flags
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed May 1, 2021
1 parent d1f4c0a commit 69117a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/blockdata/script.rs
Expand Up @@ -451,7 +451,7 @@ impl Script {
#[cfg(feature="bitcoinconsensus")]
/// Shorthand for [Self::verify_with_flags] with flag [bitcoinconsensus::VERIFY_ALL]
pub fn verify (&self, index: usize, amount: u64, spending: &[u8]) -> Result<(), Error> {
self.verify_with_flags(index, amount, spending, ::bitcoinconsensus::VERIFY_ALL)
self.verify_with_flags(index, ::Amount::from_sat(amount), spending, ::bitcoinconsensus::VERIFY_ALL)
}

#[cfg(feature="bitcoinconsensus")]
Expand All @@ -461,8 +461,8 @@ impl Script {
/// * `amount` - the amount this script guards
/// * `spending` - the transaction that attempts to spend the output holding this script
/// * `flags` - verification flags, see [bitcoinconsensus::VERIFY_ALL] and similar
pub fn verify_with_flags<F: Into<u32>>(&self, index: usize, amount: u64, spending: &[u8], flags: F) -> Result<(), Error> {
Ok(bitcoinconsensus::verify_with_flags (&self.0[..], amount, spending, index, flags.into())?)
pub fn verify_with_flags<F: Into<u32>>(&self, index: usize, amount: ::Amount, spending: &[u8], flags: F) -> Result<(), Error> {
Ok(bitcoinconsensus::verify_with_flags (&self.0[..], amount.as_sat(), spending, index, flags.into())?)
}

/// Write the assembly decoding of the script bytes to the formatter.
Expand Down
2 changes: 1 addition & 1 deletion src/blockdata/transaction.rs
Expand Up @@ -478,7 +478,7 @@ impl Transaction {
let flags: u32 = flags.into();
for (idx, input) in self.input.iter().enumerate() {
if let Some(output) = spent(&input.previous_output) {
output.script_pubkey.verify_with_flags(idx, output.value, tx.as_slice(), flags)?;
output.script_pubkey.verify_with_flags(idx, ::Amount::from_sat(output.value), tx.as_slice(), flags)?;
} else {
return Err(script::Error::UnknownSpentOutput(input.previous_output.clone()));
}
Expand Down

0 comments on commit 69117a1

Please sign in to comment.