txscript: Increase maximum allowed nulldata bytes

This change increases the maximum allowed bytes allowed in pushed
data to be considered a nulldata transaction.  This matches the current
value the reference implementation uses by default.
This commit is contained in:
David Hill 2015-02-28 08:50:38 -05:00
parent db8fa6f850
commit 436fb8203c
2 changed files with 19 additions and 5 deletions

View file

@ -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

View file

@ -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,