Skip to content

Commit 9b4e7d9

Browse files
sipaTheBlueMatt
authored andcommitted
Add DummySignatureCreator which just creates zeroed sigs
1 parent eba2f06 commit 9b4e7d9

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
@@ -275,3 +275,39 @@ CScript CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecke
275275

276276
return CombineSignatures(scriptPubKey, checker, txType, vSolutions, stack1, stack2);
277277
}
278+
279+
namespace {
280+
/** Dummy signature checker which accepts all signatures. */
281+
class DummySignatureChecker : public BaseSignatureChecker
282+
{
283+
public:
284+
DummySignatureChecker() {}
285+
286+
bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode) const
287+
{
288+
return true;
289+
}
290+
};
291+
const DummySignatureChecker dummyChecker;
292+
}
293+
294+
const BaseSignatureChecker& DummySignatureCreator::Checker() const
295+
{
296+
return dummyChecker;
297+
}
298+
299+
bool DummySignatureCreator::CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode) const
300+
{
301+
// Create a dummy signature that is a valid DER-encoding
302+
vchSig.assign(72, '\000');
303+
vchSig[0] = 0x30;
304+
vchSig[1] = 69;
305+
vchSig[2] = 0x02;
306+
vchSig[3] = 33;
307+
vchSig[4] = 0x01;
308+
vchSig[4 + 33] = 0x02;
309+
vchSig[5 + 33] = 32;
310+
vchSig[6 + 33] = 0x01;
311+
vchSig[6 + 33 + 32] = SIGHASH_ALL;
312+
return true;
313+
}

src/script/sign.h

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

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

0 commit comments

Comments
 (0)