mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-10-14 00:59:21 +00:00
move liquid key validation to function
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
053f38cf0d
commit
d54a5dc8c4
@ -15,12 +15,8 @@ import (
|
||||
func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMachine) (*types.MsgAttestMachineResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
xpubKeyLiquid, err := hdkeychain.NewKeyFromString(msg.Machine.IssuerLiquid)
|
||||
if err != nil {
|
||||
return nil, errors.New("invalid liquid key")
|
||||
}
|
||||
isValidLiquidKey := xpubKeyLiquid.IsForNet(&chaincfg.MainNetParams)
|
||||
if !isValidLiquidKey {
|
||||
isValidIssuerLiquid := validateIssuerLiquid(msg.Machine.IssuerLiquid)
|
||||
if !isValidIssuerLiquid {
|
||||
return nil, errors.New("invalid liquid key")
|
||||
}
|
||||
|
||||
@ -33,3 +29,12 @@ func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMach
|
||||
|
||||
return &types.MsgAttestMachineResponse{}, nil
|
||||
}
|
||||
|
||||
func validateIssuerLiquid(issuerLiquid string) bool {
|
||||
xpubKeyLiquid, err := hdkeychain.NewKeyFromString(issuerLiquid)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
isValidLiquidKey := xpubKeyLiquid.IsForNet(&chaincfg.MainNetParams)
|
||||
return isValidLiquidKey
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user