aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2019-10-02 12:09:48 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2019-10-02 13:25:48 +0200
commit752debdbdb2e174dd1ab5583e08c1e559ec0f9f4 (patch)
treef5160334d3a83e6c3c08ebf5e695b20f28780460
parent1f40a91286662a9bf40737c34b4de2f5b5fa8b96 (diff)
parent73aaf4ecf825a4d18c802ca5dd3856ce9096915e (diff)
Merge #13266: refactor: privatize SignatureExtractorChecker [moveonly]
73aaf4ecf825a4d18c802ca5dd3856ce9096915e 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 73aaf4ecf825a4d18c802ca5dd3856ce9096915e laanwj: ACK 73aaf4ecf825a4d18c802ca5dd3856ce9096915e Tree-SHA512: f7eafbce22b0e9917a8487e88d1f5a1061f2a0959ae1a097cbd9c8ea0d774edfb807da56813cb5fb26f6ca98499a0604a8ff024c198a7c8dc755164de66d972a
-rw-r--r--src/script/sign.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 13481af9c5..0ed92e8d5b 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -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 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;
+ 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;
}
- return false;
-}
+};
-namespace
-{
struct Stacks
{
std::vector<valtype> script;