func VerifyAddressType(address string) (string, bool) { var resp string = "Not a Valid Factoid Address" var pass bool = false if strings.HasPrefix(address, "FA") { if factoid.ValidateFUserStr(address) { resp = "Factoid - Public" pass = true } } else if strings.HasPrefix(address, "EC") { if factoid.ValidateECUserStr(address) { resp = "Entry Credit - Public" pass = true } } else if strings.HasPrefix(address, "Fs") { if factoid.ValidateFPrivateUserStr(address) { resp = "Factoid - Private" pass = true } } else if strings.HasPrefix(address, "Es") { if factoid.ValidateECPrivateUserStr(address) { resp = "Entry Credit - Private" pass = true } } // Add Netki resolution here //else if (checkNetki) { // if (factoid.ValidateECPrivateUserStr(address)) { // resp = "{\"AddressType\":\"Factoid - Public\", \"TypeCode\":4 ,\"Success\":true}" // } //} return resp, pass }
// ImportKey <name> <private key> func (ImportKey) Execute(state IState, args []string) error { if len(args) != 3 { return fmt.Errorf("Invalid Parameters") } name := args[1] adr := args[2] if err := ValidName(name); err != nil { return err } a := state.GetFS().GetDB().GetRaw([]byte(fct.W_NAME), []byte(name)) if a != nil { return fmt.Errorf("That address name is in use. Specify a different name.") } fa := fct.ValidateFPrivateUserStr(adr) ec := fct.ValidateECPrivateUserStr(adr) b, err := hex.DecodeString(adr) if err == nil && len(b) != 32 { err = fmt.Errorf("wrong length") } if fa || ec || err == nil { var privateKey []byte if err != nil { privateKey = fct.ConvertUserStrToAddress(adr) } else { privateKey = b } var fixed [64]byte copy(fixed[:], privateKey) publicKey := ed25519.GetPublicKey(&fixed) adrtype := "ec" if fa { adrtype = "fct" } _, err := state.GetFS().GetWallet().AddKeyPair(adrtype, []byte(name), publicKey[:], privateKey, false) if err != nil { return err } return nil } return fmt.Errorf("Not a valid Private Key; Check that your key is typed correctly") }