aboutsummaryrefslogtreecommitdiff
path: root/src/script.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-10-21 22:47:24 -0700
committerGavin Andresen <gavinandresen@gmail.com>2013-10-21 22:47:24 -0700
commitbe484db274e6de7e7b6880d04b2d84e20b719b9a (patch)
treecd0bef85a328ee5d111545f6862b9cbb42fd0aac /src/script.cpp
parent10dc3c74737eea1f2de694c6582caf3027926034 (diff)
parenta79342479f577013f2fd2573fb32585d6f4981b3 (diff)
Merge pull request #2738 from jgarzik/op_return
Relay OP_RETURN data TxOut as standard transaction type.
Diffstat (limited to 'src/script.cpp')
-rw-r--r--src/script.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/script.cpp b/src/script.cpp
index 4e4e95a678..63f632795a 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -79,6 +79,7 @@ const char* GetTxnOutputType(txnouttype t)
case TX_PUBKEYHASH: return "pubkeyhash";
case TX_SCRIPTHASH: return "scripthash";
case TX_MULTISIG: return "multisig";
+ case TX_NULL_DATA: return "nulldata";
}
return NULL;
}
@@ -220,6 +221,7 @@ const char* GetOpName(opcodetype opcode)
// template matching params
case OP_PUBKEYHASH : return "OP_PUBKEYHASH";
case OP_PUBKEY : return "OP_PUBKEY";
+ case OP_SMALLDATA : return "OP_SMALLDATA";
case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE";
default:
@@ -1204,6 +1206,9 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
// 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:
@@ -1288,6 +1293,12 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
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
@@ -1350,6 +1361,7 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash
switch (whichTypeRet)
{
case TX_NONSTANDARD:
+ case TX_NULL_DATA:
return false;
case TX_PUBKEY:
keyID = CPubKey(vSolutions[0]).GetID();
@@ -1381,6 +1393,8 @@ int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned c
{
case TX_NONSTANDARD:
return -1;
+ case TX_NULL_DATA:
+ return 1;
case TX_PUBKEY:
return 1;
case TX_PUBKEYHASH:
@@ -1395,10 +1409,9 @@ int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned c
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;
@@ -1457,6 +1470,7 @@ bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
switch (whichType)
{
case TX_NONSTANDARD:
+ case TX_NULL_DATA:
return false;
case TX_PUBKEY:
keyID = CPubKey(vSolutions[0]).GetID();
@@ -1518,6 +1532,8 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
vector<valtype> vSolutions;
if (!Solver(scriptPubKey, typeRet, vSolutions))
return false;
+ if (typeRet == TX_NULL_DATA)
+ return true;
if (typeRet == TX_MULTISIG)
{
@@ -1733,6 +1749,7 @@ static CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo,
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);