mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge pull request #3128
0056095
Show short scriptPubKeys correctly (Peter Todd)22de68d
Relay OP_RETURN TxOut as standard transaction type (Peter Todd) Signed-off-by: Gavin Andresen <gavinandresen@gmail.com>
This commit is contained in:
commit
837369806a
@ -63,8 +63,6 @@ uint256 CTxOut::GetHash() const
|
|||||||
|
|
||||||
std::string CTxOut::ToString() const
|
std::string CTxOut::ToString() const
|
||||||
{
|
{
|
||||||
if (scriptPubKey.size() < 6)
|
|
||||||
return "CTxOut(error)";
|
|
||||||
return strprintf("CTxOut(nValue=%"PRI64d".%08"PRI64d", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30).c_str());
|
return strprintf("CTxOut(nValue=%"PRI64d".%08"PRI64d", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
|
|||||||
|
|
||||||
if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired))
|
if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired))
|
||||||
{
|
{
|
||||||
out.push_back(Pair("type", GetTxnOutputType(TX_NONSTANDARD)));
|
out.push_back(Pair("type", GetTxnOutputType(type)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1195,7 @@ bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubK
|
|||||||
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsigned char> >& vSolutionsRet)
|
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsigned char> >& vSolutionsRet)
|
||||||
{
|
{
|
||||||
// Templates
|
// Templates
|
||||||
static map<txnouttype, CScript> mTemplates;
|
static multimap<txnouttype, CScript> mTemplates;
|
||||||
if (mTemplates.empty())
|
if (mTemplates.empty())
|
||||||
{
|
{
|
||||||
// Standard tx, sender provides pubkey, receiver adds signature
|
// Standard tx, sender provides pubkey, receiver adds signature
|
||||||
@ -1209,6 +1209,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
|
|||||||
|
|
||||||
// Empty, provably prunable, data-carrying output
|
// Empty, provably prunable, data-carrying output
|
||||||
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA));
|
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA));
|
||||||
|
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shortcut for pay-to-script-hash, which are more constrained than the other types:
|
// Shortcut for pay-to-script-hash, which are more constrained than the other types:
|
||||||
@ -1392,9 +1393,8 @@ int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned c
|
|||||||
switch (t)
|
switch (t)
|
||||||
{
|
{
|
||||||
case TX_NONSTANDARD:
|
case TX_NONSTANDARD:
|
||||||
return -1;
|
|
||||||
case TX_NULL_DATA:
|
case TX_NULL_DATA:
|
||||||
return 1;
|
return -1;
|
||||||
case TX_PUBKEY:
|
case TX_PUBKEY:
|
||||||
return 1;
|
return 1;
|
||||||
case TX_PUBKEYHASH:
|
case TX_PUBKEYHASH:
|
||||||
@ -1532,8 +1532,10 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
|
|||||||
vector<valtype> vSolutions;
|
vector<valtype> vSolutions;
|
||||||
if (!Solver(scriptPubKey, typeRet, vSolutions))
|
if (!Solver(scriptPubKey, typeRet, vSolutions))
|
||||||
return false;
|
return false;
|
||||||
if (typeRet == TX_NULL_DATA)
|
if (typeRet == TX_NULL_DATA){
|
||||||
return true;
|
// This is data, not addresses
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeRet == TX_MULTISIG)
|
if (typeRet == TX_MULTISIG)
|
||||||
{
|
{
|
||||||
|
@ -282,11 +282,24 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
|||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
|
||||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||||
|
|
||||||
// Only one TX_NULL_DATA permitted
|
// TX_NULL_DATA w/o PUSHDATA
|
||||||
|
t.vout.resize(1);
|
||||||
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
||||||
|
BOOST_CHECK(IsStandardTx(t, reason));
|
||||||
|
|
||||||
|
// Only one TX_NULL_DATA permitted in all cases
|
||||||
t.vout.resize(2);
|
t.vout.resize(2);
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||||
|
|
||||||
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||||
|
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||||
|
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||||
|
|
||||||
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
||||||
|
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||||
|
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user