diff --git a/txscript/script.go b/txscript/script.go index 2149dfe8..530a6ef6 100644 --- a/txscript/script.go +++ b/txscript/script.go @@ -134,6 +134,10 @@ var ( ) const ( + // maxDataCarrierSize is the maximum number of bytes allowed in pushed + // data to be considered a nulldata transaction + maxDataCarrierSize = 80 + // maxStackSize is the maximum combined height of stack and alt stack // during execution. maxStackSize = 1000 @@ -303,7 +307,8 @@ func isMultiSig(pops []parsedOpcode) bool { // false otherwise. func isNullData(pops []parsedOpcode) bool { // A nulldata transaction is either a single OP_RETURN or an - // OP_RETURN SMALLDATA (where SMALLDATA is a push data up to 40 bytes). + // OP_RETURN SMALLDATA (where SMALLDATA is a push data up to + // maxDataCarrierSize bytes). l := len(pops) if l == 1 && pops[0].opcode.value == OP_RETURN { return true @@ -312,7 +317,7 @@ func isNullData(pops []parsedOpcode) bool { return l == 2 && pops[0].opcode.value == OP_RETURN && pops[1].opcode.value <= OP_PUSHDATA4 && - len(pops[1].data) <= 40 + len(pops[1].data) <= maxDataCarrierSize } // isPushOnly returns true if the script only pushes data, false otherwise. @@ -1728,7 +1733,6 @@ func CalcScriptInfo(sigscript, pkscript []byte, bip16 bool) (*ScriptInfo, error) shInputs := expectedInputs(shPops, shClass) if shInputs == -1 { - // We have no fucking clue, then. si.ExpectedInputs = -1 } else { si.ExpectedInputs += shInputs diff --git a/txscript/script_test.go b/txscript/script_test.go index 4c094ca9..904fa793 100644 --- a/txscript/script_test.go +++ b/txscript/script_test.go @@ -2263,7 +2263,12 @@ var scriptTypeTests = []scriptTypeTest{ script: []byte{ txscript.OP_RETURN, txscript.OP_PUSHDATA1, - 0x28, // 40 + 0x50, // 80 + 0x04, 0x67, 0x08, 0xaf, 0xdb, 0x0f, 0xe5, 0x54, + 0x82, 0x71, 0x96, 0x7f, 0x1a, 0x67, 0x13, 0x0b, + 0x71, 0x05, 0xcd, 0x6a, 0x82, 0x8e, 0x03, 0x90, + 0x9a, 0x67, 0x96, 0x2e, 0x0e, 0xa1, 0xf6, 0x1d, + 0xeb, 0x64, 0x9f, 0x6b, 0xc3, 0xf4, 0xce, 0xf3, 0x04, 0x67, 0x08, 0xaf, 0xdb, 0x0f, 0xe5, 0x54, 0x82, 0x71, 0x96, 0x7f, 0x1a, 0x67, 0x13, 0x0b, 0x71, 0x05, 0xcd, 0x6a, 0x82, 0x8e, 0x03, 0x90, @@ -2278,7 +2283,12 @@ var scriptTypeTests = []scriptTypeTest{ script: []byte{ txscript.OP_RETURN, txscript.OP_PUSHDATA1, - 0x29, // 41 + 0x51, // 81 + 0x04, 0x67, 0x08, 0xaf, 0xdb, 0x0f, 0xe5, 0x54, + 0x82, 0x71, 0x96, 0x7f, 0x1a, 0x67, 0x13, 0x0b, + 0x71, 0x05, 0xcd, 0x6a, 0x82, 0x8e, 0x03, 0x90, + 0x9a, 0x67, 0x96, 0x2e, 0x0e, 0xa1, 0xf6, 0x1d, + 0xeb, 0x64, 0x9f, 0x6b, 0xc3, 0xf4, 0xce, 0xf3, 0x04, 0x67, 0x08, 0xaf, 0xdb, 0x0f, 0xe5, 0x54, 0x82, 0x71, 0x96, 0x7f, 0x1a, 0x67, 0x13, 0x0b, 0x71, 0x05, 0xcd, 0x6a, 0x82, 0x8e, 0x03, 0x90,