parent
4865d60258
commit
84ede349b0
|
@ -249,12 +249,15 @@ impl Block {
|
||||||
|
|
||||||
let cb = self.coinbase().ok_or(Bip34Error::NotPresent)?;
|
let cb = self.coinbase().ok_or(Bip34Error::NotPresent)?;
|
||||||
let input = cb.input.first().ok_or(Bip34Error::NotPresent)?;
|
let input = cb.input.first().ok_or(Bip34Error::NotPresent)?;
|
||||||
let push = input.script_sig.instructions_minimal()
|
let push = input
|
||||||
|
.script_sig
|
||||||
|
.instructions_minimal()
|
||||||
.next()
|
.next()
|
||||||
.ok_or(Bip34Error::NotPresent)?
|
.ok_or(Bip34Error::NotPresent)?
|
||||||
.map_err(to_bip34_error)?;
|
.map_err(to_bip34_error)?;
|
||||||
match (push.script_num(), push.push_bytes().map(|b| b.read_scriptint())) {
|
match (push.script_num(), push.push_bytes().map(|b| b.read_scriptint())) {
|
||||||
(Some(num), Some(Ok(_)) | None) => Ok(num.try_into().map_err(|_| Bip34Error::NegativeHeight)?),
|
(Some(num), Some(Ok(_)) | None) =>
|
||||||
|
Ok(num.try_into().map_err(|_| Bip34Error::NegativeHeight)?),
|
||||||
(_, Some(Err(err))) => Err(to_bip34_error(err)),
|
(_, Some(Err(err))) => Err(to_bip34_error(err)),
|
||||||
(None, _) => Err(Bip34Error::NotPresent),
|
(None, _) => Err(Bip34Error::NotPresent),
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,7 @@ mod primitive {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs an empty `&PushBytes`.
|
/// Constructs an empty `&PushBytes`.
|
||||||
pub fn empty() -> &'static Self {
|
pub fn empty() -> &'static Self { Self::from_slice_unchecked(&[]) }
|
||||||
Self::from_slice_unchecked(&[])
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the underlying bytes.
|
/// Returns the underlying bytes.
|
||||||
pub fn as_bytes(&self) -> &[u8] { &self.0 }
|
pub fn as_bytes(&self) -> &[u8] { &self.0 }
|
||||||
|
|
|
@ -118,7 +118,7 @@ pub mod taproot;
|
||||||
// that it is available in the event that we add some functionality there.
|
// that it is available in the event that we add some functionality there.
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use primitives::{
|
pub use primitives::{
|
||||||
block::{BlockHash, WitnessCommitment, Header as BlockHeader},
|
block::{BlockHash, Header as BlockHeader, WitnessCommitment},
|
||||||
merkle_tree::{TxMerkleNode, WitnessMerkleNode},
|
merkle_tree::{TxMerkleNode, WitnessMerkleNode},
|
||||||
opcodes::Opcode,
|
opcodes::Opcode,
|
||||||
pow::CompactTarget, // No `pow` module outside of `primitives`.
|
pow::CompactTarget, // No `pow` module outside of `primitives`.
|
||||||
|
@ -141,11 +141,13 @@ pub use crate::{
|
||||||
bip158::{FilterHash, FilterHeader},
|
bip158::{FilterHash, FilterHeader},
|
||||||
bip32::XKeyIdentifier,
|
bip32::XKeyIdentifier,
|
||||||
crypto::ecdsa,
|
crypto::ecdsa,
|
||||||
crypto::key::{self, PrivateKey, PubkeyHash, PublicKey, CompressedPublicKey, WPubkeyHash, XOnlyPublicKey},
|
crypto::key::{
|
||||||
|
self, CompressedPublicKey, PrivateKey, PubkeyHash, PublicKey, WPubkeyHash, XOnlyPublicKey,
|
||||||
|
},
|
||||||
crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
|
crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
|
||||||
merkle_tree::MerkleBlock,
|
merkle_tree::MerkleBlock,
|
||||||
network::{Network, NetworkKind, TestnetVersion},
|
|
||||||
network::params::{self, Params},
|
network::params::{self, Params},
|
||||||
|
network::{Network, NetworkKind, TestnetVersion},
|
||||||
pow::{Target, Work},
|
pow::{Target, Work},
|
||||||
psbt::Psbt,
|
psbt::Psbt,
|
||||||
sighash::{EcdsaSighashType, TapSighashType},
|
sighash::{EcdsaSighashType, TapSighashType},
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
//! Combine the ChaCha20 stream cipher with the Poly1305 message authentication code
|
//! Combine the ChaCha20 stream cipher with the Poly1305 message authentication code
|
||||||
//! to form an authenticated encryption with additional data (AEAD) algorithm.
|
//! to form an authenticated encryption with additional data (AEAD) algorithm.
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
// Experimental features we need.
|
// Experimental features we need.
|
||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||||
// Coding conventions.
|
// Coding conventions.
|
||||||
|
|
|
@ -67,10 +67,7 @@ impl SignedAmount {
|
||||||
pub fn from_int_btc(btc: i64) -> Result<SignedAmount, OutOfRangeError> {
|
pub fn from_int_btc(btc: i64) -> Result<SignedAmount, OutOfRangeError> {
|
||||||
match btc.checked_mul(100_000_000) {
|
match btc.checked_mul(100_000_000) {
|
||||||
Some(amount) => Ok(SignedAmount::from_sat(amount)),
|
Some(amount) => Ok(SignedAmount::from_sat(amount)),
|
||||||
None => Err(OutOfRangeError {
|
None => Err(OutOfRangeError { is_signed: true, is_greater_than_max: true }),
|
||||||
is_signed: true,
|
|
||||||
is_greater_than_max: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,10 +77,7 @@ impl Amount {
|
||||||
pub fn from_int_btc(btc: u64) -> Result<Amount, OutOfRangeError> {
|
pub fn from_int_btc(btc: u64) -> Result<Amount, OutOfRangeError> {
|
||||||
match btc.checked_mul(100_000_000) {
|
match btc.checked_mul(100_000_000) {
|
||||||
Some(amount) => Ok(Amount::from_sat(amount)),
|
Some(amount) => Ok(Amount::from_sat(amount)),
|
||||||
None => Err(OutOfRangeError {
|
None => Err(OutOfRangeError { is_signed: false, is_greater_than_max: true }),
|
||||||
is_signed: false,
|
|
||||||
is_greater_than_max: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue