Example #1
0
func (command UpdateCommand) Run() string {
	oldNetworkSeed := command.Input.GetOldNetworkSeedFromConsole()
	oldNetworkSeedRaw, err := crypto.Base58Decode(oldNetworkSeed, oldNetworkAlphabet)
	if err != nil {
		return "Your old network account secret seed is incorrect."
	}
	var rawSeed [32]byte
	copy(rawSeed[:], oldNetworkSeedRaw[1:len(oldNetworkSeedRaw)-2]) // Payload

	kp, err := keypair.FromRawSeed(rawSeed)
	if err != nil {
		return "Error generating signing keys from your secret seed"
	}

	fmt.Println("The stellar network uses a new format for public and secret keys.")
	fmt.Println("The new format for the seed you pasted above is:")
	fmt.Println("")
	fmt.Printf("Public Key: %s\n", kp.Address())
	fmt.Printf("Secret Key: %s\n", kp.(*keypair.Full).Seed())
	fmt.Println("")

	oldNetworkAddress := kp.Address()
	newNetworkAddress := command.Input.GetNewNetworkAddressFromConsole()
	messageData := api.MessageData{NewAddress: newNetworkAddress}
	confirmed := command.Input.GetConfirmationFromConsole(oldNetworkAddress, messageData.NewAddress)
	if !confirmed {
		return "Exiting..."
	}

	response, err := command.ApiObject.SendUpgradeRequest(messageData, kp)
	if err != nil {
		return "Error building or sending request to upgrade API."
	}

	if response.Status == "success" {
		return fmt.Sprintf("%s Your XLM should arrive soon.", Green("Success!"))
	} else {
		return fmt.Sprintf("%s"+response.Message, Red("Error: "))
	}
}
Example #2
0
	"github.com/rubblelabs/ripple/crypto"
	"github.com/spf13/cobra"
	"github.com/stellar/stellar-upgrade/api"
)

var status = &cobra.Command{
	Use:   "status [address]",
	Short: "Displays your account upgrade status",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			fmt.Println("[address] parameter is required.")
			return
		}
		address := args[0]
		_, err := crypto.Base58Decode(address, oldNetworkAlphabet)
		if err != nil {
			fmt.Println("Your old network account address is incorrect.")
			return
		}

		response, err := api.Api{}.SendStatusRequest(address)
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("Address: " + response.OldAddress)
		fmt.Print("Claimed: ")
		if response.Claimed {
			fmt.Printf("%s\n", Green("Yes"))
		} else {