// Parse constructs a new KP from the provided string, which should be either // an address, or a seed. If the provided input is a seed, the resulting KP // will have signing capabilities. func Parse(addressOrSeed string) (KP, error) { _, err := strkey.Decode(strkey.VersionByteAccountID, addressOrSeed) if err == nil { return &FromAddress{addressOrSeed}, nil } if err != strkey.ErrInvalidVersionByte { return nil, err } _, err = strkey.Decode(strkey.VersionByteSeed, addressOrSeed) if err == nil { return &Full{addressOrSeed}, nil } return nil, err }
// SetAddress modifies the receiver, setting it's value to the AccountId form // of the provided address. func (aid *AccountId) SetAddress(address string) error { if aid == nil { return nil } raw, err := strkey.Decode(strkey.VersionByteAccountID, address) if err != nil { return err } if len(raw) != 32 { return errors.New("invalid address") } var ui Uint256 copy(ui[:], raw) *aid, err = NewAccountId(CryptoKeyTypeKeyTypeEd25519, ui) return err }