Merge #13266: refactor: privatize SignatureExtractorChecker [moveonly]

73aaf4ecf8 Make SignatureExtractorChecker private to its own file (Ben Woosley)

Pull request description:

  ~If we add a CTxIn constructor to SignatureData, then constructing the
  SignatureData directly is no more verbose than calling DataFromTransaction,
  and grants the caller additional flexibiliy in how to provide the CTxIn.~

  A simple change to enhance encapsulation.

ACKs for top commit:
  MarcoFalke:
    utACK 73aaf4ecf8
  laanwj:
    ACK 73aaf4ecf8

Tree-SHA512: f7eafbce22b0e9917a8487e88d1f5a1061f2a0959ae1a097cbd9c8ea0d774edfb807da56813cb5fb26f6ca98499a0604a8ff024c198a7c8dc755164de66d972a
This commit is contained in:
Wladimir J. van der Laan 2019-10-02 12:09:48 +02:00
commit 752debdbdb
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -244,6 +244,7 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
return sigdata.complete;
}
namespace {
class SignatureExtractorChecker final : public BaseSignatureChecker
{
private:
@ -252,21 +253,17 @@ private:
public:
SignatureExtractorChecker(SignatureData& sigdata, BaseSignatureChecker& checker) : sigdata(sigdata), checker(checker) {}
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override;
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override
{
if (checker.CheckSig(scriptSig, vchPubKey, scriptCode, sigversion)) {
CPubKey pubkey(vchPubKey);
sigdata.signatures.emplace(pubkey.GetID(), SigPair(pubkey, scriptSig));
return true;
}
return false;
}
};
bool SignatureExtractorChecker::CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const
{
if (checker.CheckSig(scriptSig, vchPubKey, scriptCode, sigversion)) {
CPubKey pubkey(vchPubKey);
sigdata.signatures.emplace(pubkey.GetID(), SigPair(pubkey, scriptSig));
return true;
}
return false;
}
namespace
{
struct Stacks
{
std::vector<valtype> script;