Skip to content

Commit 692b827

Browse files
committed
Add DummySignatureCreator which just creates zeroed sigs
- backports bitcoin/bitcoin@9b4e7d9
1 parent 95fefe9 commit 692b827

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/script/sign.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,39 @@ CScript CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecke
296296

297297
return CombineSignatures(scriptPubKey, checker, txType, vSolutions, stack1, stack2);
298298
}
299+
300+
namespace {
301+
/** Dummy signature checker which accepts all signatures. */
302+
class DummySignatureChecker : public BaseSignatureChecker
303+
{
304+
public:
305+
DummySignatureChecker() {}
306+
307+
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const
308+
{
309+
return true;
310+
}
311+
};
312+
const DummySignatureChecker dummyChecker;
313+
}
314+
315+
const BaseSignatureChecker& DummySignatureCreator::Checker() const
316+
{
317+
return dummyChecker;
318+
}
319+
320+
bool DummySignatureCreator::CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const
321+
{
322+
// Create a dummy signature that is a valid DER-encoding
323+
vchSig.assign(72, '\000');
324+
vchSig[0] = 0x30;
325+
vchSig[1] = 69;
326+
vchSig[2] = 0x02;
327+
vchSig[3] = 33;
328+
vchSig[4] = 0x01;
329+
vchSig[4 + 33] = 0x02;
330+
vchSig[5 + 33] = 32;
331+
vchSig[6 + 33] = 0x01;
332+
vchSig[6 + 33 + 32] = SIGHASH_ALL;
333+
return true;
334+
}

src/script/sign.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class TransactionSignatureCreator : public BaseSignatureCreator {
4444
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const;
4545
};
4646

47+
/** A signature creator that just produces 72-byte empty signatyres. */
48+
class DummySignatureCreator : public BaseSignatureCreator {
49+
public:
50+
DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
51+
const BaseSignatureChecker& Checker() const;
52+
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const;
53+
};
54+
4755
/** Produce a script signature using a generic signature creator. */
4856
bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& scriptPubKey, CScript& scriptSig, bool fColdStake);
4957

0 commit comments

Comments
 (0)