Add amount and consensus branch ID to zcashconsensus_verify_script
We didn't initially expose these because we assumed that this API was likely being used somewhere in the ecosystem. However, the build system for libzcashconsensus has been broken since 2018, and no issues were raised, which strongly indicates that this API is not currently in use.
This commit is contained in:
parent
ad3b68cd46
commit
5575cdd8e3
|
@ -71,9 +71,13 @@ struct ECCryptoClosure
|
|||
ECCryptoClosure instance_of_eccryptoclosure;
|
||||
}
|
||||
|
||||
int zcashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
|
||||
const unsigned char *txTo , unsigned int txToLen,
|
||||
unsigned int nIn, unsigned int flags, zcashconsensus_error* err)
|
||||
int zcashconsensus_verify_script(
|
||||
const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
|
||||
int64_t amount,
|
||||
const unsigned char *txTo, unsigned int txToLen,
|
||||
unsigned int nIn, unsigned int flags,
|
||||
uint32_t consensusBranchId,
|
||||
zcashconsensus_error* err)
|
||||
{
|
||||
try {
|
||||
TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
|
||||
|
@ -87,13 +91,11 @@ int zcashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int
|
|||
// Regardless of the verification result, the tx did not error.
|
||||
set_error(err, zcashconsensus_ERR_OK);
|
||||
PrecomputedTransactionData txdata(tx);
|
||||
CAmount am(0);
|
||||
uint32_t consensusBranchId = SPROUT_BRANCH_ID;
|
||||
return VerifyScript(
|
||||
tx.vin[nIn].scriptSig,
|
||||
CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen),
|
||||
flags,
|
||||
TransactionSignatureChecker(&tx, nIn, am, txdata),
|
||||
TransactionSignatureChecker(&tx, nIn, amount, txdata),
|
||||
consensusBranchId,
|
||||
NULL);
|
||||
} catch (const std::exception&) {
|
||||
|
|
|
@ -55,9 +55,13 @@ enum
|
|||
/// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under
|
||||
/// the additional constraints specified by flags.
|
||||
/// If not NULL, err will contain an error/success code for the operation
|
||||
EXPORT_SYMBOL int zcashconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
|
||||
const unsigned char *txTo , unsigned int txToLen,
|
||||
unsigned int nIn, unsigned int flags, zcashconsensus_error* err);
|
||||
EXPORT_SYMBOL int zcashconsensus_verify_script(
|
||||
const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
|
||||
int64_t amount,
|
||||
const unsigned char *txTo, unsigned int txToLen,
|
||||
unsigned int nIn, unsigned int flags,
|
||||
uint32_t consensusBranchId,
|
||||
zcashconsensus_error* err);
|
||||
|
||||
EXPORT_SYMBOL unsigned int zcashconsensus_version();
|
||||
|
||||
|
|
|
@ -100,7 +100,13 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, ui
|
|||
#if defined(HAVE_CONSENSUS_LIB)
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
stream << tx2;
|
||||
BOOST_CHECK_MESSAGE(zcashconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message);
|
||||
BOOST_CHECK_MESSAGE(zcashconsensus_verify_script(
|
||||
begin_ptr(scriptPubKey), scriptPubKey.size(),
|
||||
txCredit.vout[0].nValue,
|
||||
(const unsigned char*)&stream[0], stream.size(),
|
||||
0, flags,
|
||||
consensusBranchId,
|
||||
NULL) == expect,message);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue