@@ -69,7 +69,7 @@ struct ECCryptoClosure
6969ECCryptoClosure instance_of_eccryptoclosure;
7070}
7171
72- int bitcoinconsensus_verify_script (const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
72+ static int verify_script (const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CAmount amount ,
7373 const unsigned char *txTo , unsigned int txToLen,
7474 unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
7575{
@@ -82,16 +82,36 @@ int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned i
8282 if (tx.GetSerializeSize (SER_NETWORK, PROTOCOL_VERSION) != txToLen)
8383 return set_error (err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
8484
85- // Regardless of the verification result, the tx did not error.
86- set_error (err, bitcoinconsensus_ERR_OK);
85+ // Regardless of the verification result, the tx did not error.
86+ set_error (err, bitcoinconsensus_ERR_OK);
8787
88- CAmount am (0 );
89- return VerifyScript (tx.vin [nIn].scriptSig , CScript (scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit .vtxinwit .size () ? &tx.wit .vtxinwit [nIn].scriptWitness : NULL , flags, TransactionSignatureChecker (&tx, nIn, am), NULL );
88+ return VerifyScript (tx.vin [nIn].scriptSig , CScript (scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit .vtxinwit .size () ? &tx.wit .vtxinwit [nIn].scriptWitness : NULL , flags, TransactionSignatureChecker (&tx, nIn, amount), NULL );
9089 } catch (const std::exception&) {
9190 return set_error (err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
9291 }
9392}
9493
94+ int bitcoinconsensus_verify_script_with_amount (const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount,
95+ const unsigned char *txTo , unsigned int txToLen,
96+ unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
97+ {
98+ CAmount am (amount);
99+ return ::verify_script (scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err);
100+ }
101+
102+
103+ int bitcoinconsensus_verify_script (const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
104+ const unsigned char *txTo , unsigned int txToLen,
105+ unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
106+ {
107+ if (flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) {
108+ return set_error (err, bitcoinconsensus_ERR_AMOUNT_REQUIRED);
109+ }
110+
111+ CAmount am (0 );
112+ return ::verify_script (scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err);
113+ }
114+
95115unsigned int bitcoinconsensus_version ()
96116{
97117 // Just use the API version for now
0 commit comments