mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-08 07:06:43 +00:00
gofmt
This commit is contained in:
parent
8fe24958bb
commit
53ba8fb834
12
script.go
12
script.go
@ -718,7 +718,7 @@ func (s *Script) SetAltStack(data [][]byte) {
|
|||||||
|
|
||||||
// GetSigOpCount provides a quick count of the number of signature operations
|
// GetSigOpCount provides a quick count of the number of signature operations
|
||||||
// in a script. a CHECKSIG operations counts for 1, and a CHECK_MULTISIG for 20.
|
// in a script. a CHECKSIG operations counts for 1, and a CHECK_MULTISIG for 20.
|
||||||
func GetSigOpCount(script [] byte) (int, error) {
|
func GetSigOpCount(script []byte) (int, error) {
|
||||||
pops, err := parseScript(script)
|
pops, err := parseScript(script)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -751,7 +751,7 @@ func GetPreciseSigOpCount(scriptSig, scriptPubKey []byte, bip16 bool) (int, erro
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
shScript := sigPops[len(sigPops) - 1].data
|
shScript := sigPops[len(sigPops)-1].data
|
||||||
// Means that sigPops is jus OP_1 - OP_16, no sigops there.
|
// Means that sigPops is jus OP_1 - OP_16, no sigops there.
|
||||||
if shScript == nil {
|
if shScript == nil {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
@ -774,19 +774,19 @@ func getSigOpCount(pops []parsedOpcode, precise bool) int {
|
|||||||
for i, pop := range pops {
|
for i, pop := range pops {
|
||||||
switch pop.opcode.value {
|
switch pop.opcode.value {
|
||||||
case OP_CHECKSIG:
|
case OP_CHECKSIG:
|
||||||
fallthrough;
|
fallthrough
|
||||||
case OP_CHECKSIGVERIFY:
|
case OP_CHECKSIGVERIFY:
|
||||||
nSigs++
|
nSigs++
|
||||||
case OP_CHECK_MULTISIG:
|
case OP_CHECK_MULTISIG:
|
||||||
fallthrough;
|
fallthrough
|
||||||
case OP_CHECKMULTISIGVERIFY:
|
case OP_CHECKMULTISIGVERIFY:
|
||||||
// If we are being precise then look for familiar
|
// If we are being precise then look for familiar
|
||||||
// patterns for multisig, for now all we recognise is
|
// patterns for multisig, for now all we recognise is
|
||||||
// OP_1 - OP_16 to signify the number of pubkeys.
|
// OP_1 - OP_16 to signify the number of pubkeys.
|
||||||
// Otherwise, we use the max of 20.
|
// Otherwise, we use the max of 20.
|
||||||
if precise && i > 0 &&
|
if precise && i > 0 &&
|
||||||
pops[i - 1].opcode.value >= OP_1 &&
|
pops[i-1].opcode.value >= OP_1 &&
|
||||||
pops[i - 1].opcode.value <= OP_16 {
|
pops[i-1].opcode.value <= OP_16 {
|
||||||
nSigs += int(pops[i-1].opcode.value -
|
nSigs += int(pops[i-1].opcode.value -
|
||||||
(OP_1 - 1))
|
(OP_1 - 1))
|
||||||
} else {
|
} else {
|
||||||
|
@ -1302,8 +1302,8 @@ func TestBadPC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
pcTests := []pcTest{
|
pcTests := []pcTest{
|
||||||
pcTest{
|
pcTest{
|
||||||
script:2,
|
script: 2,
|
||||||
off:0,
|
off: 0,
|
||||||
},
|
},
|
||||||
pcTest{
|
pcTest{
|
||||||
script: 0,
|
script: 0,
|
||||||
@ -1419,7 +1419,7 @@ func TestCheckErrorCondition(t *testing.T) {
|
|||||||
t.Errorf("failed to create script: %v", err)
|
t.Errorf("failed to create script: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(pkScript) - 1; i++ {
|
for i := 0; i < len(pkScript)-1; i++ {
|
||||||
done, err := engine.Step()
|
done, err := engine.Step()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to step %dth time: %v", i, err)
|
t.Errorf("failed to step %dth time: %v", i, err)
|
||||||
@ -1452,4 +1452,3 @@ func TestCheckErrorCondition(t *testing.T) {
|
|||||||
t.Errorf("unexpected error %v on final check", err)
|
t.Errorf("unexpected error %v on final check", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ var stackTests = []stackTest{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
[][]byte{{0x80, 0x00 }},
|
[][]byte{{0x80, 0x00}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dup",
|
"dup",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user