Add new ScriptFlag ScriptStrictMultiSig.
ScriptStrictMultiSig verifies that the stack item used by CHECKMULTISIG is zero length.
This commit is contained in:
parent
be325b9d9c
commit
a591c7ec03
2 changed files with 14 additions and 1 deletions
|
@ -1891,11 +1891,16 @@ func opcodeCheckMultiSig(op *parsedOpcode, s *Script) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// bug in bitcoind mean we pop one more stack value than should be used.
|
// bug in bitcoind mean we pop one more stack value than should be used.
|
||||||
_, err = s.dstack.PopByteArray()
|
dummy, err := s.dstack.PopByteArray()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.strictMultiSig && len(dummy) != 0 {
|
||||||
|
return fmt.Errorf("multisig dummy argument is not zero length: %d",
|
||||||
|
len(dummy))
|
||||||
|
}
|
||||||
|
|
||||||
if len(signatures) == 0 {
|
if len(signatures) == 0 {
|
||||||
s.dstack.PushBool(nsig == 0)
|
s.dstack.PushBool(nsig == 0)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -207,6 +207,7 @@ type Script struct {
|
||||||
numOps int
|
numOps int
|
||||||
bip16 bool // treat execution as pay-to-script-hash
|
bip16 bool // treat execution as pay-to-script-hash
|
||||||
der bool // enforce DER encoding
|
der bool // enforce DER encoding
|
||||||
|
strictMultiSig bool // verify multisig stack item is zero length
|
||||||
savedFirstStack [][]byte // stack from first script for bip16 scripts
|
savedFirstStack [][]byte // stack from first script for bip16 scripts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,6 +509,10 @@ const (
|
||||||
// recognized by creator of the transaction. Performing a canonical
|
// recognized by creator of the transaction. Performing a canonical
|
||||||
// check enforces script signatures use a unique DER format.
|
// check enforces script signatures use a unique DER format.
|
||||||
ScriptCanonicalSignatures
|
ScriptCanonicalSignatures
|
||||||
|
|
||||||
|
// ScriptStrictMultiSig defines whether to verify the stack item
|
||||||
|
// used by CHECKMULTISIG is zero length.
|
||||||
|
ScriptStrictMultiSig
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewScript returns a new script engine for the provided tx and input idx with
|
// NewScript returns a new script engine for the provided tx and input idx with
|
||||||
|
@ -550,6 +555,9 @@ func NewScript(scriptSig []byte, scriptPubKey []byte, txidx int, tx *btcwire.Msg
|
||||||
if flags&ScriptCanonicalSignatures == ScriptCanonicalSignatures {
|
if flags&ScriptCanonicalSignatures == ScriptCanonicalSignatures {
|
||||||
m.der = true
|
m.der = true
|
||||||
}
|
}
|
||||||
|
if flags&ScriptStrictMultiSig == ScriptStrictMultiSig {
|
||||||
|
m.strictMultiSig = true
|
||||||
|
}
|
||||||
|
|
||||||
m.tx = *tx
|
m.tx = *tx
|
||||||
m.txidx = txidx
|
m.txidx = txidx
|
||||||
|
|
Loading…
Reference in a new issue