Merge pull request #142 from bb-2/platform_nil_shortids

Check for nil shortIDs in platformvm service requests
This commit is contained in:
Stephen Buttolph 2020-05-11 15:15:50 -04:00 committed by GitHub
commit 39cb2c1eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -35,6 +35,8 @@ var (
errGetStakeSource = errors.New("couldn't get account specified in 'stakeSource'")
errNoBlockchainWithAlias = errors.New("there is no blockchain with the specified alias")
errDSCantValidate = errors.New("new blockchain can't be validated by default Subnet")
errNilSigner = errors.New("nil ShortID 'signer' is not valid")
errNilTo = errors.New("nil ShortID 'to' is not valid")
)
// Service defines the API calls that can be made to the platform chain
@ -690,9 +692,8 @@ type SignResponse struct {
func (service *Service) Sign(_ *http.Request, args *SignArgs, reply *SignResponse) error {
service.vm.Ctx.Log.Debug("sign called")
switch {
case args.Signer.Equals(ids.ShortEmpty):
return fmt.Errorf("signer not specified")
if args.Signer.IsZero() {
return errNilSigner
}
// Get the key of the Signer
@ -904,6 +905,8 @@ func (service *Service) ImportAVA(_ *http.Request, args *ImportAVAArgs, response
service.vm.Ctx.Log.Debug("platform.ImportAVA called")
switch {
case args.To.IsZero():
return errNilTo
case args.PayerNonce == 0:
return fmt.Errorf("sender's next nonce not specified")
}