Skip to content

Commit ae7e5d7

Browse files
committed
Merge pull request #3737 from jgarzik/op-return-size
script: reduce OP_RETURN standard relay bytes to 40
2 parents e3e65d2 + 8175c79 commit ae7e5d7

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/script.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,8 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
12981298
}
12991299
else if (opcode2 == OP_SMALLDATA)
13001300
{
1301-
// small pushdata, <= 80 bytes
1302-
if (vch1.size() > 80)
1301+
// small pushdata, <= MAX_OP_RETURN_RELAY bytes
1302+
if (vch1.size() > MAX_OP_RETURN_RELAY)
13031303
break;
13041304
}
13051305
else if (opcode1 != opcode2 || vch1 != vch2)

src/script.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CKeyStore;
2323
class CTransaction;
2424

2525
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
26+
static const unsigned int MAX_OP_RETURN_RELAY = 40; // bytes
2627

2728
/** Signature hash types/flags */
2829
enum

src/test/transaction_tests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
280280
t.vout[0].scriptPubKey = CScript() << OP_1;
281281
BOOST_CHECK(!IsStandardTx(t, reason));
282282

283-
// 80-byte TX_NULL_DATA (standard)
284-
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
283+
// 40-byte TX_NULL_DATA (standard)
284+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
285285
BOOST_CHECK(IsStandardTx(t, reason));
286286

287-
// 81-byte TX_NULL_DATA (non-standard)
288-
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
287+
// 41-byte TX_NULL_DATA (non-standard)
288+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
289289
BOOST_CHECK(!IsStandardTx(t, reason));
290290

291291
// TX_NULL_DATA w/o PUSHDATA
@@ -295,11 +295,11 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
295295

296296
// Only one TX_NULL_DATA permitted in all cases
297297
t.vout.resize(2);
298-
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
299-
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
298+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
299+
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
300300
BOOST_CHECK(!IsStandardTx(t, reason));
301301

302-
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
302+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
303303
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
304304
BOOST_CHECK(!IsStandardTx(t, reason));
305305

0 commit comments

Comments
 (0)