if (nVersion > CTransaction::CURRENT_VERSION)
return false;
+ unsigned int nDataOut = 0;
+ txnouttype whichType;
BOOST_FOREACH(const CTxIn& txin, vin)
{
// Biggest 'standard' txin is a 3-signature 3-of-3 CHECKMULTISIG
}
}
BOOST_FOREACH(const CTxOut& txout, vout) {
- if (!::IsStandard(txout.scriptPubKey))
- return false;
- if (txout.nValue == 0)
- return false;
- if (fEnforceCanonical && !txout.scriptPubKey.HasCanonicalPushes()) {
+ if (!::IsStandard(txout.scriptPubKey, whichType)) {
return false;
}
+ if (whichType == TX_NULL_DATA)
+ nDataOut++;
+ else {
+ if (txout.nValue == 0) {
+ return false;
+ }
+ if (fEnforceCanonical && !txout.scriptPubKey.HasCanonicalPushes()) {
+ return false;
+ }
+ }
+ }
+
+ // only one OP_RETURN txout is permitted
+ if (nDataOut > 1) {
+ return false;
}
+
return true;
}
case TX_PUBKEYHASH: return "pubkeyhash";
case TX_SCRIPTHASH: return "scripthash";
case TX_MULTISIG: return "multisig";
+ case TX_NULL_DATA: return "nulldata";
}
return NULL;
}
// Sender provides N pubkeys, receivers provides M signatures
mTemplates.insert(make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG));
+
+ // Empty, provably prunable, data-carrying output
+ mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA));
}
// Shortcut for pay-to-script-hash, which are more constrained than the other types:
else
break;
}
+ else if (opcode2 == OP_SMALLDATA)
+ {
+ // small pushdata, <= 80 bytes
+ if (vch1.size() > 80)
+ break;
+ }
else if (opcode1 != opcode2 || vch1 != vch2)
{
// Others must match exactly
switch (whichTypeRet)
{
case TX_NONSTANDARD:
+ case TX_NULL_DATA:
return false;
case TX_PUBKEY:
keyID = CPubKey(vSolutions[0]).GetID();
{
case TX_NONSTANDARD:
return -1;
+ case TX_NULL_DATA:
+ return 1;
case TX_PUBKEY:
return 1;
case TX_PUBKEYHASH:
return -1;
}
-bool IsStandard(const CScript& scriptPubKey)
+bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
{
vector<valtype> vSolutions;
- txnouttype whichType;
if (!Solver(scriptPubKey, whichType, vSolutions))
return false;
switch (whichType)
{
case TX_NONSTANDARD:
+ case TX_NULL_DATA:
return false;
case TX_PUBKEY:
keyID = CPubKey(vSolutions[0]).GetID();
vector<valtype> vSolutions;
if (!Solver(scriptPubKey, typeRet, vSolutions))
return false;
+ if (typeRet == TX_NULL_DATA)
+ return true;
if (typeRet == TX_MULTISIG)
{
switch (txType)
{
case TX_NONSTANDARD:
+ case TX_NULL_DATA:
// Don't know anything about this, assume bigger one is correct:
if (sigs1.size() >= sigs2.size())
return PushAll(sigs1);
TX_PUBKEYHASH,
TX_SCRIPTHASH,
TX_MULTISIG,
+ TX_NULL_DATA,
};
class CNoDestination {
// template matching params
+ OP_SMALLDATA = 0xf9,
OP_SMALLINTEGER = 0xfa,
OP_PUBKEYS = 0xfb,
OP_PUBKEYHASH = 0xfd,
bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType);
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions);
-bool IsStandard(const CScript& scriptPubKey);
+bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
bool IsMine(const CKeyStore& keystore, const CTxDestination &dest);
void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector<CKeyID> &vKeys);