Use deprecated is_provably_unspendable()
This commit is contained in:
parent
a82862818e
commit
f8302d7cb5
@ -13,7 +13,9 @@ use crate::elements::registry::{AssetMeta, AssetRegistry};
|
||||
use crate::errors::*;
|
||||
use crate::new_index::schema::{Operation, TxHistoryInfo, TxHistoryKey, TxHistoryRow};
|
||||
use crate::new_index::{db::DBFlush, ChainQuery, DBRow, Mempool, Query};
|
||||
use crate::util::{bincode_util, full_hash, Bytes, FullHash, TransactionStatus, TxInput};
|
||||
use crate::util::{
|
||||
bincode_util, full_hash, Bytes, FullHash, IsProvablyUnspendable, TransactionStatus, TxInput,
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref NATIVE_ASSET_ID: AssetId =
|
||||
@ -261,7 +263,7 @@ fn index_tx_assets(
|
||||
value: pegout.value,
|
||||
}),
|
||||
));
|
||||
} else if txo.script_pubkey.is_op_return() && !txo.is_fee() {
|
||||
} else if txo.script_pubkey.is_provably_unspendable_() && !txo.is_fee() {
|
||||
if let (Asset::Explicit(asset_id), Value::Explicit(value)) = (txo.asset, txo.value) {
|
||||
if value > 0 {
|
||||
history.push((
|
||||
|
||||
@ -10,7 +10,7 @@ use crate::new_index::{compute_script_hash, Query, SpendingInput, Utxo};
|
||||
use crate::util::{
|
||||
create_socket, electrum_merkle, extract_tx_prevouts, full_hash, get_innerscripts, get_tx_fee,
|
||||
has_prevout, is_coinbase, transaction_sigop_count, BlockHeaderMeta, BlockId, FullHash,
|
||||
ScriptToAddr, ScriptToAsm, SegwitDetection, TransactionStatus,
|
||||
IsProvablyUnspendable, ScriptToAddr, ScriptToAsm, SegwitDetection, TransactionStatus,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "liquid"))]
|
||||
@ -369,7 +369,7 @@ impl TxOutValue {
|
||||
"fee"
|
||||
} else if script.is_empty() {
|
||||
"empty"
|
||||
} else if script.is_op_return() {
|
||||
} else if script.is_provably_unspendable_() {
|
||||
"op_return"
|
||||
} else if script.is_p2pk() {
|
||||
"p2pk"
|
||||
|
||||
@ -8,7 +8,9 @@ pub mod fees;
|
||||
|
||||
pub use self::block::{BlockHeaderMeta, BlockId, BlockMeta, BlockStatus, HeaderEntry, HeaderList};
|
||||
pub use self::fees::get_tx_fee;
|
||||
pub use self::script::{get_innerscripts, ScriptToAddr, ScriptToAsm, SegwitDetection};
|
||||
pub use self::script::{
|
||||
get_innerscripts, IsProvablyUnspendable, ScriptToAddr, ScriptToAsm, SegwitDetection,
|
||||
};
|
||||
pub use self::transaction::{
|
||||
extract_tx_prevouts, has_prevout, is_coinbase, is_spendable, serialize_outpoint,
|
||||
sigops::transaction_sigop_count, TransactionStatus, TxInput,
|
||||
|
||||
@ -9,6 +9,41 @@ pub struct InnerScripts {
|
||||
pub witness_script: Option<Script>,
|
||||
}
|
||||
|
||||
pub trait IsProvablyUnspendable {
|
||||
fn is_provably_unspendable_(&self) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "liquid"))]
|
||||
impl IsProvablyUnspendable for bitcoin::Script {
|
||||
// is_provably_unspendable() is deprecated in rust-bitcoin
|
||||
// so we re-implement it here. Copy pasted.
|
||||
fn is_provably_unspendable_(&self) -> bool {
|
||||
use bitcoin::blockdata::opcodes::{
|
||||
Class::{IllegalOp, ReturnOp},
|
||||
ClassifyContext, Opcode,
|
||||
};
|
||||
|
||||
match self.as_bytes().first() {
|
||||
Some(b) => {
|
||||
let first = Opcode::from(*b);
|
||||
let class = first.classify(ClassifyContext::Legacy);
|
||||
|
||||
class == ReturnOp || class == IllegalOp
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "liquid")]
|
||||
impl IsProvablyUnspendable for elements::Script {
|
||||
#[inline(always)]
|
||||
fn is_provably_unspendable_(&self) -> bool {
|
||||
// Not deprecated yet
|
||||
self.is_provably_unspendable()
|
||||
}
|
||||
}
|
||||
|
||||
// Extension trait for segwit script detection that works across bitcoin and elements
|
||||
pub trait SegwitDetection {
|
||||
fn segwit_is_p2wpkh(&self) -> bool;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::chain::{BlockHash, OutPoint, Transaction, TxIn, TxOut, Txid};
|
||||
use crate::errors;
|
||||
use crate::util::BlockId;
|
||||
use crate::util::{BlockId, IsProvablyUnspendable};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -71,9 +71,9 @@ pub fn has_prevout(txin: &TxIn) -> bool {
|
||||
|
||||
pub fn is_spendable(txout: &TxOut) -> bool {
|
||||
#[cfg(not(feature = "liquid"))]
|
||||
return !txout.script_pubkey.is_op_return();
|
||||
return !txout.script_pubkey.is_provably_unspendable_();
|
||||
#[cfg(feature = "liquid")]
|
||||
return !txout.is_fee() && !txout.script_pubkey.is_op_return();
|
||||
return !txout.is_fee() && !txout.script_pubkey.is_provably_unspendable_();
|
||||
}
|
||||
|
||||
/// Extract the previous TxOuts of a Transaction's TxIns
|
||||
|
||||
Loading…
Reference in New Issue
Block a user