Skip to content

Commit 8373698

Browse files
committed
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 <[email protected]>
2 parents 1dffbf0 + 0056095 commit 8373698

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

src/core.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ uint256 CTxOut::GetHash() const
6363

6464
std::string CTxOut::ToString() const
6565
{
66-
if (scriptPubKey.size() < 6)
67-
return "CTxOut(error)";
6866
return strprintf("CTxOut(nValue=%"PRI64d".%08"PRI64d", scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30).c_str());
6967
}
7068

src/rpcrawtransaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
2929

3030
if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired))
3131
{
32-
out.push_back(Pair("type", GetTxnOutputType(TX_NONSTANDARD)));
32+
out.push_back(Pair("type", GetTxnOutputType(type)));
3333
return;
3434
}
3535

src/script.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubK
11951195
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsigned char> >& vSolutionsRet)
11961196
{
11971197
// Templates
1198-
static map<txnouttype, CScript> mTemplates;
1198+
static multimap<txnouttype, CScript> mTemplates;
11991199
if (mTemplates.empty())
12001200
{
12011201
// Standard tx, sender provides pubkey, receiver adds signature
@@ -1209,6 +1209,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
12091209

12101210
// Empty, provably prunable, data-carrying output
12111211
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA));
1212+
mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN));
12121213
}
12131214

12141215
// 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
13921393
switch (t)
13931394
{
13941395
case TX_NONSTANDARD:
1395-
return -1;
13961396
case TX_NULL_DATA:
1397-
return 1;
1397+
return -1;
13981398
case TX_PUBKEY:
13991399
return 1;
14001400
case TX_PUBKEYHASH:
@@ -1532,8 +1532,10 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
15321532
vector<valtype> vSolutions;
15331533
if (!Solver(scriptPubKey, typeRet, vSolutions))
15341534
return false;
1535-
if (typeRet == TX_NULL_DATA)
1536-
return true;
1535+
if (typeRet == TX_NULL_DATA){
1536+
// This is data, not addresses
1537+
return false;
1538+
}
15371539

15381540
if (typeRet == TX_MULTISIG)
15391541
{

src/test/transaction_tests.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,24 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
282282
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
283283
BOOST_CHECK(!IsStandardTx(t, reason));
284284

285-
// Only one TX_NULL_DATA permitted
285+
// TX_NULL_DATA w/o PUSHDATA
286+
t.vout.resize(1);
287+
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
288+
BOOST_CHECK(IsStandardTx(t, reason));
289+
290+
// Only one TX_NULL_DATA permitted in all cases
286291
t.vout.resize(2);
287292
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
288293
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
289294
BOOST_CHECK(!IsStandardTx(t, reason));
295+
296+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
297+
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
298+
BOOST_CHECK(!IsStandardTx(t, reason));
299+
300+
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
301+
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
302+
BOOST_CHECK(!IsStandardTx(t, reason));
290303
}
291304

292305
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)