diff --git a/core/transaction/cancelproducertransaction.go b/core/transaction/cancelproducertransaction.go index fe7ccc0bc..b9e079394 100644 --- a/core/transaction/cancelproducertransaction.go +++ b/core/transaction/cancelproducertransaction.go @@ -46,7 +46,6 @@ func (t *CancelProducerTransaction) HeightVersionCheck() error { t.TxType().Name(), t.PayloadVersion())) } } - return nil } diff --git a/core/transaction/registerproducertransaction.go b/core/transaction/registerproducertransaction.go index ac65cc56c..59857b73c 100644 --- a/core/transaction/registerproducertransaction.go +++ b/core/transaction/registerproducertransaction.go @@ -35,7 +35,6 @@ func (t *RegisterProducerTransaction) HeightVersionCheck() error { t.TxType().Name(), t.PayloadVersion())) } } - return nil } @@ -207,7 +206,7 @@ func (t *RegisterProducerTransaction) SpecialContextCheck() (elaerr.ELAError, bo return elaerr.Simple(elaerr.ErrTxPayload, errors.New("there must be only one deposit address in outputs")), true } - } else { //if t.PayloadVersion() == payload.ProducerInfoDposV2Version || t.PayloadVersion() == payload.ProducerInfoSchnorrVersion + } else { if t.parameters.BlockHeight+t.parameters.Config.DPoSConfiguration.DPoSV2DepositCoinMinLockTime >= info.StakeUntil { return elaerr.Simple(elaerr.ErrTxPayload, errors.New("v2 producer StakeUntil less than DPoSV2DepositCoinMinLockTime")), true } diff --git a/core/types/outputpayload/mapping.go b/core/types/outputpayload/mapping.go index 6a1aee1e1..b0aa2eb3a 100644 --- a/core/types/outputpayload/mapping.go +++ b/core/types/outputpayload/mapping.go @@ -8,10 +8,10 @@ package outputpayload import ( "bytes" "errors" - "github.com/elastos/Elastos.ELA/core/contract/program" "io" "github.com/elastos/Elastos.ELA/common" + "github.com/elastos/Elastos.ELA/core/contract/program" "github.com/elastos/Elastos.ELA/crypto" ) @@ -92,7 +92,6 @@ func (m *Mapping) GetVersion() byte { } func (m *Mapping) Validate() error { - //todo if len(m.OwnerKey) == crypto.NegativeBigLength { pubKey, err := crypto.DecodePoint(m.OwnerKey) if err != nil { diff --git a/core/types/payload/crcproposal.go b/core/types/payload/crcproposal.go index ae9332ac9..b8a184313 100644 --- a/core/types/payload/crcproposal.go +++ b/core/types/payload/crcproposal.go @@ -882,7 +882,7 @@ func (p *CRCProposal) DeserializeUnsignedUpgradeCode(r io.Reader, version byte) if p.CategoryData, err = common.ReadVarString(r); err != nil { return errors.New("[CRCProposal], Category data deserialize failed") } - if p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner"); err != nil { + if p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner"); err != nil { return errors.New("failed to deserialize OwnerKey") } if err = p.DraftHash.Deserialize(r); err != nil { @@ -904,7 +904,7 @@ func (p *CRCProposal) DeserializeUnSignedNormalOrELIP(r io.Reader, version byte) return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -943,7 +943,7 @@ func (p *CRCProposal) DeserializeUnSignedChangeProposalOwner(r io.Reader, versio if p.CategoryData, err = common.ReadVarString(r); err != nil { return errors.New("[CRCProposal], Category data deserialize failed") } - if p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner"); err != nil { + if p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner"); err != nil { return errors.New("failed to deserialize OwnerKey") } if err = p.DraftHash.Deserialize(r); err != nil { @@ -961,7 +961,7 @@ func (p *CRCProposal) DeserializeUnSignedChangeProposalOwner(r io.Reader, versio if err = p.NewRecipient.Deserialize(r); err != nil { return errors.New("failed to deserialize Recipient") } - if p.NewOwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner"); err != nil { + if p.NewOwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner"); err != nil { return errors.New("failed to deserialize NewOwnerKey") } return nil @@ -975,7 +975,7 @@ func (p *CRCProposal) DeserializeUnsignedRegisterSideChain(r io.Reader, version return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1006,7 +1006,7 @@ func (p *CRCProposal) DeserializeUnSignedCloseProposal(r io.Reader, version byte return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1035,7 +1035,7 @@ func (p *CRCProposal) DeserializeUnSignedChangeCustomIDFee(r io.Reader, version return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1065,7 +1065,7 @@ func (p *CRCProposal) DeserializeUnSignedReceivedCustomID(r io.Reader, version b return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1109,7 +1109,7 @@ func (p *CRCProposal) DeserializeUnSignedReservedCustomID(r io.Reader, version b return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1148,7 +1148,7 @@ func (p *CRCProposal) DeserializeUnSignedChangeSecretaryGeneral(r io.Reader, ver return errors.New("[CRCProposal], Category data deserialize failed") } - p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1572,7 +1572,7 @@ func (p *CRCProposalInfo) Deserialize(r io.Reader, version byte) error { return errors.New("failed to deserialize CategoryData") } - p.OwnerPublicKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + p.OwnerPublicKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return errors.New("failed to deserialize OwnerKey") } @@ -1644,7 +1644,7 @@ func (p *CRCProposalInfo) Deserialize(r io.Reader, version byte) error { return errors.New("failed to deserialize Recipient") } - if p.NewOwnerPublicKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner"); err != nil { + if p.NewOwnerPublicKey, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "owner"); err != nil { return errors.New("failed to deserialize NewOwnerKey") } diff --git a/core/types/payload/crcproposaltracking.go b/core/types/payload/crcproposaltracking.go index 5948718c1..51a147bc9 100644 --- a/core/types/payload/crcproposaltracking.go +++ b/core/types/payload/crcproposaltracking.go @@ -206,12 +206,12 @@ func (p *CRCProposalTracking) DeserializeUnSigned(r io.Reader, version byte) err if p.Stage, err = common.ReadUint8(r); err != nil { return errors.New("failed to deserialize Stage") } - if p.OwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, + if p.OwnerKey, err = common.ReadVarBytes(r, crypto.PublicKeyScriptLength, "owner pubkey"); err != nil { return errors.New("failed to deserialize OwnerKey") } - if p.NewOwnerKey, err = common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, + if p.NewOwnerKey, err = common.ReadVarBytes(r, crypto.PublicKeyScriptLength, "new owner pubkey"); err != nil { return errors.New("failed to deserialize NewOwnerKey") } diff --git a/core/types/payload/crcproposalwithdraw.go b/core/types/payload/crcproposalwithdraw.go index 3a496cde8..bdc81a9da 100644 --- a/core/types/payload/crcproposalwithdraw.go +++ b/core/types/payload/crcproposalwithdraw.go @@ -85,7 +85,7 @@ func (p *CRCProposalWithdraw) Deserialize(r io.Reader, version byte) error { if err != nil { return err } - p.Signature, err = common.ReadVarBytes(r, crypto.MaxSignatureScriptLength, "sign") + p.Signature, err = common.ReadVarBytes(r, crypto.NegativeBigLength, "sign") if err != nil { return errors.New("[CRCProposalWithdraw], Signature deserialize failed") } @@ -99,7 +99,7 @@ func (p *CRCProposalWithdraw) DeserializeUnsigned(r io.Reader, if err = p.ProposalHash.Deserialize(r); err != nil { return err } - ownerPublicKey, err := common.ReadVarBytes(r, crypto.MaxMultiSignCodeLength, "owner") + ownerPublicKey, err := common.ReadVarBytes(r, crypto.NegativeBigLength, "owner") if err != nil { return err } diff --git a/crypto/crypto.go b/crypto/crypto.go index 042e993a7..37521e0d6 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -12,12 +12,12 @@ import ( "crypto/sha256" "errors" "fmt" - "github.com/elastos/Elastos.ELA/core/contract/program" "io" "math/big" "sort" "github.com/elastos/Elastos.ELA/common" + "github.com/elastos/Elastos.ELA/core/contract/program" "github.com/elastos/Elastos.ELA/crypto/ecies" ) diff --git a/servers/common.go b/servers/common.go index 398194617..effc30dad 100644 --- a/servers/common.go +++ b/servers/common.go @@ -213,19 +213,19 @@ type SchnorrWithdrawFromSideChainInfo struct { } type ProducerInfo struct { - OwnerKey string `json:"ownerkey"` - NodePublicKey string `json:"nodepublickey"` - NickName string `json:"nickname"` - Url string `json:"url"` - Location uint64 `json:"location"` - NetAddress string `json:"netaddress"` - StakeUntil uint32 `json:"stakeuntil"` - Signature string `json:"signature"` + OwnerPublicKey string `json:"ownerpublickey"` + NodePublicKey string `json:"nodepublickey"` + NickName string `json:"nickname"` + Url string `json:"url"` + Location uint64 `json:"location"` + NetAddress string `json:"netaddress"` + StakeUntil uint32 `json:"stakeuntil"` + Signature string `json:"signature"` } type CancelProducerInfo struct { - OwnerKey string `json:"ownerkey"` - Signature string `json:"signature"` + OwnerPublicKey string `json:"ownerpublickey"` + Signature string `json:"signature"` } type InactiveArbitratorsInfo struct { diff --git a/servers/interfaces.go b/servers/interfaces.go index b9497c538..d725e5e7c 100644 --- a/servers/interfaces.go +++ b/servers/interfaces.go @@ -571,7 +571,7 @@ func GetProducerInfo(params Params) map[string]interface{} { } producerInfo := RPCProducerInfo{ - OwnerKey: hex.EncodeToString(p.Info().OwnerKey), + OwnerPublicKey: hex.EncodeToString(p.Info().OwnerKey), NodePublicKey: hex.EncodeToString(p.Info().NodePublicKey), Nickname: p.Info().NickName, Url: p.Info().Url, @@ -2026,7 +2026,7 @@ func GetExistSideChainReturnDepositTransactions(param Params) map[string]interfa // single producer info type RPCProducerInfo struct { - OwnerKey string `json:"ownerkey"` + OwnerPublicKey string `json:"ownerpublickey"` NodePublicKey string `json:"nodepublickey"` Nickname string `json:"nickname"` Url string `json:"url"` @@ -2339,7 +2339,7 @@ func ListProducers(param Params) map[string]interface{} { totalVotes += p.Votes() totalDPoSV2Votes += common.Fixed64(p.GetTotalDPoSV2VoteRights()) producerInfo := RPCProducerInfo{ - OwnerKey: hex.EncodeToString(p.Info().OwnerKey), + OwnerPublicKey: hex.EncodeToString(p.Info().OwnerKey), NodePublicKey: hex.EncodeToString(p.Info().NodePublicKey), Nickname: p.Info().NickName, Url: p.Info().Url, @@ -3186,7 +3186,7 @@ func getPayloadInfo(p interfaces.Payload, payloadVersion byte) PayloadInfo { case *payload.Record: case *payload.ProducerInfo: obj := new(ProducerInfo) - obj.OwnerKey = common.BytesToHexString(object.OwnerKey) + obj.OwnerPublicKey = common.BytesToHexString(object.OwnerKey) obj.NodePublicKey = common.BytesToHexString(object.NodePublicKey) obj.NickName = object.NickName obj.Url = object.Url @@ -3197,7 +3197,7 @@ func getPayloadInfo(p interfaces.Payload, payloadVersion byte) PayloadInfo { return obj case *payload.ProcessProducer: obj := new(CancelProducerInfo) - obj.OwnerKey = common.BytesToHexString(object.OwnerKey) + obj.OwnerPublicKey = common.BytesToHexString(object.OwnerKey) obj.Signature = common.BytesToHexString(object.Signature) return obj case *payload.InactiveArbitrators: