Skip to content

Commit

Permalink
feat(nft): rpc return continue use OwnerPublicKey for exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
Houshoupei84 authored and RainFallsSilent committed Feb 24, 2023
1 parent c0399e1 commit 0163246
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 37 deletions.
1 change: 0 additions & 1 deletion core/transaction/cancelproducertransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (t *CancelProducerTransaction) HeightVersionCheck() error {
t.TxType().Name(), t.PayloadVersion()))
}
}

return nil
}

Expand Down
3 changes: 1 addition & 2 deletions core/transaction/registerproducertransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func (t *RegisterProducerTransaction) HeightVersionCheck() error {
t.TxType().Name(), t.PayloadVersion()))
}
}

return nil
}

Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions core/types/outputpayload/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions core/types/payload/crcproposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}

Expand Down
4 changes: 2 additions & 2 deletions core/types/payload/crcproposaltracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions core/types/payload/crcproposalwithdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
20 changes: 10 additions & 10 deletions servers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions servers/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 0163246

Please sign in to comment.