enable cryptoconditions spending
This commit is contained in:
@@ -227,21 +227,26 @@ bool CScript::IsPayToCryptoCondition() const
|
|||||||
{
|
{
|
||||||
const_iterator pc = this->begin();
|
const_iterator pc = this->begin();
|
||||||
vector<unsigned char> data;
|
vector<unsigned char> data;
|
||||||
int i;
|
int i = 0;
|
||||||
while (pc < this->end())
|
while (pc < this->end())
|
||||||
{
|
{
|
||||||
opcodetype opcode;
|
opcodetype opcode;
|
||||||
if (!this->GetOp(pc, opcode, data))
|
if (!this->GetOp(pc, opcode, data))
|
||||||
return 0;
|
return 0;
|
||||||
if (0 == i)
|
switch (i++) {
|
||||||
if (opcode != OP_PUSHDATA1)
|
case 0:
|
||||||
|
// Binary condition should be less than 76 bytes
|
||||||
|
if (!(opcode > OP_0 && opcode < OP_PUSHDATA1))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (opcode != OP_CHECKCRYPTOCONDITION)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
if (1 == i)
|
break;
|
||||||
if (opcode != OP_CHECKCRYPTOCONDITION)
|
}
|
||||||
return 0;
|
|
||||||
if (i > 1)
|
|
||||||
return 0;
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
|||||||
// Shortcut for pay-to-crypto-condition
|
// Shortcut for pay-to-crypto-condition
|
||||||
if (scriptPubKey.IsPayToCryptoCondition()) {
|
if (scriptPubKey.IsPayToCryptoCondition()) {
|
||||||
typeRet = TX_CRYPTOCONDITION;
|
typeRet = TX_CRYPTOCONDITION;
|
||||||
//vSolutionsRet.push_back("hello there");
|
// TODO: Extract solutions
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +186,8 @@ int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned c
|
|||||||
return vSolutions[0][0] + 1;
|
return vSolutions[0][0] + 1;
|
||||||
case TX_SCRIPTHASH:
|
case TX_SCRIPTHASH:
|
||||||
return 1; // doesn't include args needed by the script
|
return 1; // doesn't include args needed by the script
|
||||||
|
case TX_CRYPTOCONDITION:
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user