core: fix CalculateNetworkFee() for multisig contracts

We return m from the vm.ParseMultiSigContract and n is the length of pubs,
invocation script then pushes m signatures for n keys.
This commit is contained in:
Roman Khimov 2020-07-13 18:05:46 +03:00
parent afc5ee1ded
commit 3134e364b2

View file

@ -136,8 +136,8 @@ func CalculateNetworkFee(script []byte) (int64, int) {
if vm.IsSignatureContract(script) { if vm.IsSignatureContract(script) {
size += 67 + io.GetVarSize(script) size += 67 + io.GetVarSize(script)
netFee += opcodePrice(opcode.PUSHDATA1, opcode.PUSHNULL) + crypto.ECDSAVerifyPrice netFee += opcodePrice(opcode.PUSHDATA1, opcode.PUSHNULL) + crypto.ECDSAVerifyPrice
} else if n, pubs, ok := vm.ParseMultiSigContract(script); ok { } else if m, pubs, ok := vm.ParseMultiSigContract(script); ok {
m := len(pubs) n := len(pubs)
sizeInv := 66 * m sizeInv := 66 * m
size += io.GetVarSize(sizeInv) + sizeInv + io.GetVarSize(script) size += io.GetVarSize(sizeInv) + sizeInv + io.GetVarSize(script)
netFee += calculateMultisigFee(m) + calculateMultisigFee(n) netFee += calculateMultisigFee(m) + calculateMultisigFee(n)