func CreateAccount(v *vault.Vault, addrStr, name, tokenStr string, kt bmcrypto.KeyType, redirStr string) {
	s := stepper.New()

	// Setup context for spinner
	spinnerCtx := spinnerContext{
		Args: args{
			Vault:        v,
			AddrStr:      addrStr,
			Name:         name,
			TokenStr:     tokenStr,
			KeyType:      kt,
			RedirAddrStr: redirStr,
		},
	}
	s.Ctx = context.WithValue(s.Ctx, internal.CtxSpinnerContext, &spinnerCtx)

	// Add all the steps from the account creation procedure

	s.AddStep(stepper.Step{
		Title:   fmt.Sprintf("Verifying if address %s%s%s is correct", stepper.AnsiFgYellow, addrStr, stepper.AnsiReset),
		RunFunc: verifyAddress,
	})

	s.AddStep(stepper.Step{
		Title:   "Checking if address is already known in the resolver service",
		RunFunc: checkAddressInResolver,
	})

	s.AddStep(stepper.Step{
		Title:   "Checking if address is a reserved name",
		RunFunc: checkReservedAddress,
	})

	s.AddStep(stepper.Step{
		Title:      "Checking if linked account exists",
		SkipIfFunc: func(s stepper.Stepper) bool { return getAccountContext(s).Args.RedirAddrStr == "" },
		RunFunc:    checkLinkedAddressInResolver,
	})

	s.AddStep(stepper.Step{
		Title:      "Checking if token is valid and extracting data",
		SkipIfFunc: func(s stepper.Stepper) bool { return getAccountContext(s).Args.TokenStr == "" },
		RunFunc:    checkToken,
	})

	s.AddStep(stepper.Step{
		Title:   "Checking if the account is already present in the vault",
		RunFunc: checkAccountInVault,
	})

	s.AddStep(stepper.Step{
		Title:          "Generating your initial keypair",
		DisplaySpinner: true,
		SkipIfFunc:     func(s stepper.Stepper) bool { return getAccountContext(s).AccountInfo != nil },
		RunFunc:        generateKeyPair,
	})

	s.AddStep(stepper.Step{
		Title:          fmt.Sprintf("Doing some work to let people know this is not a fake account, %sthis might take a while%s...", stepper.AnsiFgYellow, stepper.AnsiReset),
		DisplaySpinner: true,
		SkipIfFunc:     func(s stepper.Stepper) bool { return getAccountContext(s).AccountInfo != nil },
		RunFunc:        doProofOfWork,
	})

	s.AddStep(stepper.Step{
		Title:      "Placing your new account into the vault",
		SkipIfFunc: func(s stepper.Stepper) bool { return getAccountContext(s).AccountInfo != nil },
		RunFunc:    addAccountToVault,
	})

	s.AddStep(stepper.Step{
		Title:          "Checking domains for reservation proof",
		RunFunc:        checkReservedDomains,
		SkipIfFunc:     func(s stepper.Stepper) bool { return !getAccountContext(s).Reserved },
		DisplaySpinner: true,
	})

	s.AddStep(stepper.Step{
		Title:          "Sending your account to the server",
		DisplaySpinner: true,
		SkipIfFunc:     func(s stepper.Stepper) bool { return getAccountContext(s).Args.TokenStr == "" },
		RunFunc:        uploadAccountToServer,
	})

	s.AddStep(stepper.Step{
		Title:          "Making your account known to the outside world",
		DisplaySpinner: true,
		RunFunc:        uploadAccountToResolver,
	})

	// Run the stepper
	s.Run()
	if s.Status == stepper.FAILURE {
		fmt.Println("There was an error while creating the account.")
		os.Exit(1)
	}

	kp := getAccountContext(*s).KeyPair
	mnemonic := bminternal.WordWrap(bmcrypto.GetMnemonic(kp), 78)

	fmt.Println(internal.GenerateFromMnemonicTemplate(internal.AccountCreatedTemplate, mnemonic))
}
// CreateAccount creates a new account locally in the vault, stores it on the mail server and pushes the public key to the resolver
CreateAccount creates a new account locally in the vault, stores it on the mail server and pushes the public key to the resolver
// CreateAccount creates a new account locally in the vault stores it on the mail server and pushes the public key to the resolver
func CreateAccount(v *vault.Vault, addrStr, name, tokenStr string, kt bmcrypto.KeyType, redirStr string) {
	s := stepper.New()
	spinnerCtx := spinnerContext{
		Args: args{
			Vault:        v,
			AddrStr:      addrStr,
			Name:         name,
			TokenStr:     tokenStr,
			KeyType:      kt,
			RedirAddrStr: redirStr,
		},
	}
	s.Ctx = context.WithValue(s.Ctx, internal.CtxSpinnerContext, &spinnerCtx)
	s.AddStep(stepper.Step{
		Title:   fmt.Sprintf("Verifying if address %s%s%s is correct", stepper.AnsiFgYellow, addrStr, stepper.AnsiReset),
		RunFunc: verifyAddress,
	})
	s.AddStep(stepper.Step{
		Title:   "Checking if address is already known in the resolver service",
		RunFunc: checkAddressInResolver,
	})
	s.AddStep(stepper.Step{
		Title:   "Checking if address is a reserved name",
		RunFunc: checkReservedAddress,
	})
	s.AddStep(stepper.Step{
		Title:      "Checking if linked account exists",
		SkipIfFunc: func(s stepper.Stepper) bool { return getAccountContext(s).Args.RedirAddrStr == "" },
		RunFunc:    checkLinkedAddressInResolver,
	})
	s.AddStep(stepper.Step{
		Title:      "Checking if token is valid and extracting data",
		SkipIfFunc: func(s stepper.Stepper) bool { return getAccountContext(s).Args.TokenStr == "" },
		RunFunc:    checkToken,
	})
	s.AddStep(stepper.Step{
		Title:   "Checking if the account is already present in the vault",
		RunFunc: checkAccountInVault,
	})
	s.AddStep(stepper.Step{
		Title:          "Generating your initial keypair",
		DisplaySpinner: true,
		SkipIfFunc:     func(s stepper.Stepper) bool { return getAccountContext(s).AccountInfo != nil },
		RunFunc:        generateKeyPair,
	})
	s.AddStep(stepper.Step{
		Title:          fmt.Sprintf("Doing some work to let people know this is not a fake account, %sthis might take a while%s...", stepper.AnsiFgYellow, stepper.AnsiReset),
		DisplaySpinner: true,
		SkipIfFunc:     func(s stepper.Stepper) bool { return getAccountContext(s).AccountInfo != nil },
		RunFunc:        doProofOfWork,
	})
	s.AddStep(stepper.Step{
		Title:      "Placing your new account into the vault",
		SkipIfFunc: func(s stepper.Stepper) bool { return getAccountContext(s).AccountInfo != nil },
		RunFunc:    addAccountToVault,
	})
	s.AddStep(stepper.Step{
		Title:          "Checking domains for reservation proof",
		RunFunc:        checkReservedDomains,
		SkipIfFunc:     func(s stepper.Stepper) bool { return !getAccountContext(s).Reserved },
		DisplaySpinner: true,
	})
	s.AddStep(stepper.Step{
		Title:          "Sending your account to the server",
		DisplaySpinner: true,
		SkipIfFunc:     func(s stepper.Stepper) bool { return getAccountContext(s).Args.TokenStr == "" },
		RunFunc:        uploadAccountToServer,
	})
	s.AddStep(stepper.Step{
		Title:          "Making your account known to the outside world",
		DisplaySpinner: true,
		RunFunc:        uploadAccountToResolver,
	})
	s.Run()
	if s.Status == stepper.FAILURE {
		fmt.Println("There was an error while creating the account.")
		os.Exit(1)
	}
	kp := getAccountContext(*s).KeyPair
	mnemonic := bminternal.WordWrap(bmcrypto.GetMnemonic(kp), 78)
	fmt.Println(internal.GenerateFromMnemonicTemplate(internal.AccountCreatedTemplate, mnemonic))
}
func CreateAccount ( v * vault . Vault , addrStr , name , tokenStr string , kt bmcrypto . KeyType , redirStr string ) { s := stepper . New ( ) spinnerCtx := spinnerContext { Args : args { Vault : v , AddrStr : addrStr , Name : name , TokenStr : tokenStr , KeyType : kt , RedirAddrStr : redirStr , } , } s . Ctx = context . WithValue ( s . Ctx , internal . CtxSpinnerContext , & spinnerCtx ) s . AddStep ( stepper . Step { Title : fmt . Sprintf ( " " , stepper . AnsiFgYellow , addrStr , stepper . AnsiReset ) , RunFunc : verifyAddress , } ) s . AddStep ( stepper . Step { Title : " " , RunFunc : checkAddressInResolver , } ) s . AddStep ( stepper . Step { Title : " " , RunFunc : checkReservedAddress , } ) s . AddStep ( stepper . Step { Title : " " , SkipIfFunc : func ( s stepper . Stepper ) bool { return getAccountContext ( s ) . Args . RedirAddrStr == " " } , RunFunc : checkLinkedAddressInResolver , } ) s . AddStep ( stepper . Step { Title : " " , SkipIfFunc : func ( s stepper . Stepper ) bool { return getAccountContext ( s ) . Args . TokenStr == " " } , RunFunc : checkToken , } ) s . AddStep ( stepper . Step { Title : " " , RunFunc : checkAccountInVault , } ) s . AddStep ( stepper . Step { Title : " " , DisplaySpinner : true , SkipIfFunc : func ( s stepper . Stepper ) bool { return getAccountContext ( s ) . AccountInfo != nil } , RunFunc : generateKeyPair , } ) s . AddStep ( stepper . Step { Title : fmt . Sprintf ( " " , stepper . AnsiFgYellow , stepper . AnsiReset ) , DisplaySpinner : true , SkipIfFunc : func ( s stepper . Stepper ) bool { return getAccountContext ( s ) . AccountInfo != nil } , RunFunc : doProofOfWork , } ) s . AddStep ( stepper . Step { Title : " " , SkipIfFunc : func ( s stepper . Stepper ) bool { return getAccountContext ( s ) . AccountInfo != nil } , RunFunc : addAccountToVault , } ) s . AddStep ( stepper . Step { Title : " " , RunFunc : checkReservedDomains , SkipIfFunc : func ( s stepper . Stepper ) bool { return ! getAccountContext ( s ) . Reserved } , DisplaySpinner : true , } ) s . AddStep ( stepper . Step { Title : " " , DisplaySpinner : true , SkipIfFunc : func ( s stepper . Stepper ) bool { return getAccountContext ( s ) . Args . TokenStr == " " } , RunFunc : uploadAccountToServer , } ) s . AddStep ( stepper . Step { Title : " " , DisplaySpinner : true , RunFunc : uploadAccountToResolver , } ) s . Run ( ) if s . Status == stepper . FAILURE { fmt . Println ( " " ) os . Exit ( 1 ) } kp := getAccountContext ( * s ) . KeyPair mnemonic := bminternal . WordWrap ( bmcrypto . GetMnemonic ( kp ) , 78 ) fmt . Println ( internal . GenerateFromMnemonicTemplate ( internal . AccountCreatedTemplate , mnemonic ) ) }
CreateAccount creates a new account locally in the vault, stores it on the mail server and pushes the public key to the resolver
CreateAccount creates a new account locally in the vault stores it on the mail server and pushes the public key to the resolver
// Setup context for spinner // Add all the steps from the account creation procedure // Run the stepper