crate::ix!();
pub trait VerifyECDSASignature {
fn verify_ecdsa_signature(&self,
vch_sig: &Vec<u8>,
vch_pub_key: &crate::PubKey,
sighash: &u256) -> bool;
}
pub trait VerifySchnorrSignature {
fn verify_schnorr_signature(&self,
sig: &[u8],
pubkey: &crate::XOnlyPubKey,
sighash: &u256) -> bool;
}
pub const SIGHASH_ALL: usize = 1;
pub const SIGHASH_NONE: usize = 2;
pub const SIGHASH_SINGLE: usize = 3;
pub const SIGHASH_ANYONECANPAY: usize = 0x80;
pub const SIGHASH_DEFAULT: usize = 0;
pub const SIGHASH_OUTPUT_MASK: usize = 3;
pub const SIGHASH_INPUT_MASK: usize = 0x80;
bitflags!{
pub struct ScriptVerificationFlags: u32 {
const SCRIPT_VERIFY_NONE = 0;
const SCRIPT_VERIFY_P2SH = 1 << 0;
const SCRIPT_VERIFY_STRICTENC = 1 << 1;
const SCRIPT_VERIFY_DERSIG = 1 << 2;
const SCRIPT_VERIFY_LOW_S = 1 << 3;
const SCRIPT_VERIFY_NULLDUMMY = 1 << 4;
const SCRIPT_VERIFY_SIGPUSHONLY = 1 << 5;
const SCRIPT_VERIFY_MINIMALDATA = 1 << 6;
const SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS = 1 << 7;
const SCRIPT_VERIFY_CLEANSTACK = 1 << 8;
const SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY = 1 << 9;
const SCRIPT_VERIFY_CHECKSEQUENCEVERIFY = 1 << 10;
const SCRIPT_VERIFY_WITNESS = 1 << 11;
const SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM = 1 << 12;
const SCRIPT_VERIFY_MINIMALIF = 1 << 13;
const SCRIPT_VERIFY_NULLFAIL = 1 << 14;
const SCRIPT_VERIFY_WITNESS_PUBKEYTYPE = 1 << 15;
const SCRIPT_VERIFY_CONST_SCRIPTCODE = 1 << 16;
const SCRIPT_VERIFY_TAPROOT = 1 << 17;
const SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION = 1 << 18;
const SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS = 1 << 19;
const SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE = 1 << 20;
const SCRIPT_VERIFY_END_MARKER = 1 << 21;
const MANDATORY_SCRIPT_VERIFY_FLAGS = Self::SCRIPT_VERIFY_P2SH.bits;
const STANDARD_SCRIPT_VERIFY_FLAGS =
Self::MANDATORY_SCRIPT_VERIFY_FLAGS.bits
| Self::SCRIPT_VERIFY_DERSIG.bits
| Self::SCRIPT_VERIFY_STRICTENC.bits
| Self::SCRIPT_VERIFY_MINIMALDATA.bits
| Self::SCRIPT_VERIFY_NULLDUMMY.bits
| Self::SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS.bits
| Self::SCRIPT_VERIFY_CLEANSTACK.bits
| Self::SCRIPT_VERIFY_MINIMALIF.bits
| Self::SCRIPT_VERIFY_NULLFAIL.bits
| Self::SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY.bits
| Self::SCRIPT_VERIFY_CHECKSEQUENCEVERIFY.bits
| Self::SCRIPT_VERIFY_LOW_S.bits
| Self::SCRIPT_VERIFY_WITNESS.bits
| Self::SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM.bits
| Self::SCRIPT_VERIFY_WITNESS_PUBKEYTYPE.bits
| Self::SCRIPT_VERIFY_CONST_SCRIPTCODE.bits
| Self::SCRIPT_VERIFY_TAPROOT.bits
| Self::SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION.bits
| Self::SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS.bits
| Self::SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE.bits;
const STANDARD_NOT_MANDATORY_VERIFY_FLAGS =
Self::STANDARD_SCRIPT_VERIFY_FLAGS.bits
& !Self::MANDATORY_SCRIPT_VERIFY_FLAGS.bits;
}
}
pub enum SigVersion
{
BASE = 0,
WITNESS_V0 = 1,
TAPROOT = 2,
TAPSCRIPT = 3,
}
pub struct ScriptExecutionData {
tapleaf_hash_init: bool,
tapleaf_hash: u256,
codeseparator_pos_init: bool,
codeseparator_pos: u32,
annex_init: bool,
annex_present: bool,
annex_hash: u256,
validation_weight_left_init: bool,
validation_weight_left: i64,
}
pub const WITNESS_V0_SCRIPTHASH_SIZE: usize = 32;
pub const WITNESS_V0_KEYHASH_SIZE: usize = 20;
pub const WITNESS_V1_TAPROOT_SIZE: usize = 32;
pub const TAPROOT_LEAF_MASK: u8 = 0xfe;
pub const TAPROOT_LEAF_TAPSCRIPT: u8 = 0xc0;
pub const TAPROOT_CONTROL_BASE_SIZE: usize = 33;
pub const TAPROOT_CONTROL_NODE_SIZE: usize = 32;
pub const TAPROOT_CONTROL_MAX_NODE_COUNT: usize = 128;
pub const TAPROOT_CONTROL_MAX_SIZE: usize = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT;
pub type valtype = Vec<u8>;
#[inline] pub fn set_success(ret: *mut ScriptError) -> bool {
todo!();
}
#[inline] pub fn set_error(
ret: *mut ScriptError,
serror: ScriptError) -> bool {
todo!();
}
pub fn cast_to_bool(vch: &ValType) -> bool {
todo!();
}
macro_rules! stacktop {
($i:ident) => {
}
}
macro_rules! altstacktop {
($i:ident) => {
}
}
#[inline] pub fn popstack(stack: &mut Vec<ValType>) {
todo!();
}
pub fn is_compressed_or_uncompressed_pub_key(vch_pub_key: &ValType) -> bool {
todo!();
}
pub fn is_compressed_pub_key(vch_pub_key: &ValType) -> bool {
todo!();
}
pub fn is_valid_signature_encoding(sig: &Vec<u8>) -> bool {
todo!();
}
pub fn is_low_der_signature(
vch_sig: &ValType,
serror: *mut ScriptError) -> bool {
todo!();
}
pub fn is_defined_hashtype_signature(vch_sig: &ValType) -> bool {
todo!();
}
pub fn check_signature_encoding(
vch_sig: &Vec<u8>,
flags: u32,
serror: *mut ScriptError) -> bool {
todo!();
}
pub fn check_pub_key_encoding(
vch_pub_key: &ValType,
flags: u32,
sigversion: &SigVersion,
serror: *mut ScriptError) -> bool {
todo!();
}
pub fn check_minimal_push(
data: &ValType,
opcode: OpcodeType) -> bool {
todo!();
}
pub fn find_and_delete(
script: &mut Script,
b: &Script) -> i32 {
todo!();
}
pub struct ConditionStack {
stack_size: u32,
first_false_pos: u32, }
pub mod condition_stack {
pub const NO_FALSE: u32 = u32::MAX;
}
impl ConditionStack {
pub fn empty(&self) -> bool {
todo!();
}
pub fn all_true(&self) -> bool {
todo!();
}
pub fn push_back(&mut self, f: bool) {
todo!();
}
pub fn pop_back(&mut self) {
todo!();
}
pub fn toggle_top(&mut self) {
todo!();
}
}
pub fn eval_checksig_pre_tapscript(
vch_sig: &ValType,
vch_pub_key: &ValType,
pbegincodehash: Box<ScriptIterator>,
pend: Box<ScriptIterator>,
flags: u32,
checker: &Box<dyn BaseSignatureChecker>,
sigversion: SigVersion,
serror: *mut ScriptError,
success: &mut bool) -> bool {
todo!();
}
pub fn eval_checksig_tapscript(
sig: &ValType,
pubkey: &ValType,
execdata: &mut ScriptExecutionData,
flags: u32,
checker: &Box<dyn BaseSignatureChecker>,
sigversion: SigVersion,
serror: *mut ScriptError,
success: &mut bool) -> bool {
todo!();
}
pub fn eval_checksig(
sig: &ValType,
pubkey: &ValType,
pbegincodehash: Box<ScriptIterator>,
pend: Box<ScriptIterator>,
execdata: &mut ScriptExecutionData,
flags: u32,
checker: &Box<dyn BaseSignatureChecker>,
sigversion: SigVersion,
serror: *mut ScriptError,
success: &mut bool) -> bool {
todo!();
}
pub fn eval_script_with_execdata(
stack: &mut Vec<Vec<u8>>,
script: &Script,
flags: u32,
checker: &Box<dyn BaseSignatureChecker>,
sigversion: SigVersion,
execdata: &mut ScriptExecutionData,
serror: Option<*mut ScriptError>) -> bool {
todo!();
}
pub fn eval_script(
stack: &mut Vec<Vec<u8>>,
script: &Script,
flags: u32,
checker: &Box<dyn BaseSignatureChecker>,
sigversion: SigVersion,
serror: Option<*mut ScriptError>) -> bool {
todo!();
}
pub fn get_prevoutssha256<T>(tx_to: &T) -> u256 {
todo!();
}
pub fn get_sequencessha256<T>(tx_to: &T) -> u256 {
todo!();
}
pub fn get_outputssha256<T>(tx_to: &T) -> u256 {
todo!();
}
pub fn execute_witness_script(
stack_span: &[ValType],
exec_script: &Script,
flags: u32,
sigversion: SigVersion,
checker: &Box<dyn BaseSignatureChecker>,
execdata: &mut ScriptExecutionData,
serror: *mut ScriptError) -> bool {
todo!();
}
pub fn compute_tapleaf_hash(
leaf_version: u8,
script: &Script) -> u256 {
todo!();
}
pub fn compute_taproot_merkle_root(
control: &[u8],
tapleaf_hash: &u256) -> u256 {
todo!();
}
pub fn verify_taproot_commitment(
control: &Vec<u8>,
program: &Vec<u8>,
tapleaf_hash: &u256) -> bool {
todo!();
}
pub fn verify_witness_program(
witness: &ScriptWitness,
witversion: i32,
program: &Vec<u8>,
flags: u32,
checker: &Box<dyn BaseSignatureChecker>,
serror: *mut ScriptError,
is_p2sh: bool) -> bool {
todo!();
}
pub fn verify_script_with_checker<C: BaseSignatureChecker>(
script_sig: &Script,
script_pub_key: &Script,
witness: *const ScriptWitness,
flags: u32,
checker: &C,
serror: Option<*mut ScriptError>) -> bool {
todo!();
}
pub fn witness_sig_ops(
witversion: i32,
witprogram: &Vec<u8>,
witness: &ScriptWitness) -> usize {
todo!();
}
pub fn count_witness_sig_ops(
script_sig: &Script,
script_pub_key: &Script,
witness: *const ScriptWitness,
flags: u32) -> usize {
todo!();
}