Skip to content

Commit

Permalink
block wallet creation and ops on disclaimer, remove background autowa…
Browse files Browse the repository at this point in the history
…llet (#14313)
  • Loading branch information
mlsteele committed Oct 18, 2018
1 parent 5491e3e commit 36e9062
Show file tree
Hide file tree
Showing 44 changed files with 353 additions and 302 deletions.
11 changes: 6 additions & 5 deletions go/client/cmd_wallet.go
Expand Up @@ -10,17 +10,18 @@ func newCmdWallet(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Comman
subcommands := []cli.Command{
newCmdWalletBalances(cl, g),
newCmdWalletCancel(cl, g),
newCmdWalletExport(cl, g),
newCmdWalletCancelRequest(cl, g),
newCmdWalletDetail(cl, g),
newCmdWalletExport(cl, g),
newCmdWalletGetStarted(cl, g),
newCmdWalletHistory(cl, g),
newCmdWalletImport(cl, g),
newCmdWalletLookup(cl, g),
newCmdWalletRename(cl, g),
newCmdWalletRequest(cl, g),
newCmdWalletSend(cl, g),
newCmdWalletSetCurrency(cl, g),
newCmdWalletSetPrimary(cl, g),
newCmdWalletRequest(cl, g),
newCmdWalletCancelRequest(cl, g),
newCmdWalletLookup(cl, g),
newCmdWalletRename(cl, g),
}
subcommands = append(subcommands, getBuildSpecificWalletCommands(cl, g)...)
return cli.Command{
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_balances.go
Expand Up @@ -121,7 +121,8 @@ func (c *cmdWalletBalances) runForUser(cli stellar1.LocalClient) error {
return nil
}

func (c *cmdWalletBalances) Run() error {
func (c *cmdWalletBalances) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_wallet_cancel.go
Expand Up @@ -45,6 +45,7 @@ func (c *cmdWalletCancel) ParseArgv(ctx *cli.Context) (err error) {
}

func (c *cmdWalletCancel) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_cancel_request.go
Expand Up @@ -38,7 +38,8 @@ func (c *CmdWalletCancelRequest) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *CmdWalletCancelRequest) Run() error {
func (c *CmdWalletCancelRequest) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_wallet_detail.go
Expand Up @@ -44,6 +44,7 @@ func (c *cmdWalletDetail) ParseArgv(ctx *cli.Context) (err error) {
}

func (c *cmdWalletDetail) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_dump.go
Expand Up @@ -32,7 +32,8 @@ func (c *cmdWalletDump) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *cmdWalletDump) Run() error {
func (c *cmdWalletDump) Run() (err error) {
defer transformStellarCLIError(&err)
protocols := []rpc.Protocol{
NewSecretUIProtocol(c.G()),
}
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_wallet_export.go
Expand Up @@ -47,6 +47,7 @@ func (c *cmdWalletExport) ParseArgv(ctx *cli.Context) (err error) {
}

func (c *cmdWalletExport) Run() (err error) {
defer transformStellarCLIError(&err)
protocols := []rpc.Protocol{
NewSecretUIProtocol(c.G()),
}
Expand Down
125 changes: 125 additions & 0 deletions go/client/cmd_wallet_get_started.go
@@ -0,0 +1,125 @@
package client

import (
"fmt"
"strings"

"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
"golang.org/x/net/context"
)

type cmdWalletGetStarted struct {
libkb.Contextified
accepted bool
}

func newCmdWalletGetStarted(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
cmd := &cmdWalletGetStarted{
Contextified: libkb.NewContextified(g),
}
return cli.Command{
Name: "get-started",
Usage: "Learn about and get started with Stellar",
ArgumentHelp: "[i agree]",
Action: func(c *cli.Context) {
cl.ChooseCommand(cmd, "get-started", c)
},
}
}

func (c *cmdWalletGetStarted) ParseArgv(ctx *cli.Context) error {
switch len(ctx.Args()) {
case 0:
return nil
case 2:
got := fmt.Sprintf("%s %s", ctx.Args()[0], ctx.Args()[1])
if strings.ToLower(got) != "i agree" {
return fmt.Errorf("unexpected arguments: %v", got)
}
c.accepted = true
return nil
default:
return fmt.Errorf("unexpected arguments")
}
}

func (c *cmdWalletGetStarted) Run() (err error) {
if !c.accepted {
err = c.show()
if err != nil {
return err
}
}
if c.accepted {
return c.accept()
}
return fmt.Errorf("Disclaimer not accepted")
}

func (c *cmdWalletGetStarted) show() (err error) {
ui := c.G().UI.GetTerminalUI()
ui.PrintfUnescaped(disclaimerText)
c.accepted, err = c.G().UI.GetTerminalUI().PromptYesNo(PromptDescriptorStellarDisclaimer, ColorString(c.G(), "yellow", "Ok, I agree"), libkb.PromptDefaultYes)
return err
}

func (c *cmdWalletGetStarted) accept() error {
cli, err := GetWalletClient(c.G())
if err != nil {
return err
}

err = cli.AcceptDisclaimerLocal(context.TODO(), 0)
if err != nil {
return err
}
ui := c.G().UI.GetTerminalUI()
ui.PrintfUnescaped("\nYou now have a Stellar wallet!\n")
ui.PrintfUnescaped("Try it out in the app or:\n$ keybase wallet list\n")

return nil
}

func (c *cmdWalletGetStarted) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
KbKeyring: true,
}
}

const disclaimerText = `Keybase supports Stellar wallets!
You can now send or request Stellar Lumens to any Keybase user on Earth. Transactions settle in seconds, and cost a fraction of a penny.
When sending and receiving Lumens, we automatically do the conversion in your favorite currency. We went ahead and set it to USD.
Almost ready. It's important you read this.
We believe Keybase can help make cryptocurrency usable for 2 reasons:
- We can make your Stellar private key sync with encryption across your devices, without exposing it to our servers. Cool!
- We can help you send and receive crypto just by knowing usernames. You can say goodbye to ugly "addresses" you have to pass around insecurely.
And we believe Stellar is in a unique position to solve payments because:
- It's ultra fast and ultra cheap
- It natively understands currencies and tokens
- The network itself has a decentralized exchange built into it
- It doesn't burn more electricity than small nations
But there are a few things you must agree to understand before using Stellar on Keybase:
1. IT'S BRAND NEW AND YOU ARE AMONG ITS FIRST TESTERS. Seriously, don't race off and buy more cryptocurrency than you're willing to lose. And don't manage tokens in Keybase that you're not willing to lose. We could have an exploitable bug in an early release. You're using this app at your own risk. Keybase will not reimburse for any lost cryptocurrency due to user error or Keybase error of any kind.
2. BY DESIGN, WE CAN'T RECOVER YOUR PRIVATE KEY. We don't actually hold your funds, we simply help you encrypt your keys. If you lose all your Keybase installs and paper keys, and if you haven't backed up your Stellar private key, you'll lose your Stellar account. Knowing your Keybase password is not enough info. Similarly, knowing your PGP private key isn't enough info. You must have access to a Keybase install (logged in as you) or Keybase paper key to recover your Stellar private key.
3. CRYPTOCURRENCY ISN'T REALLY ANONYMOUS. When you sign your first or "default" Stellar address into your signature chain on Keybase, you are announcing it publicly as a known address for you. Assume that all your transactions from that account are public. You can have as many Stellar accounts as you like in Keybase, but whenever you make one your default, that one is then announced as yours. Consider that data permanent.
4. DON'T "RESET" YOUR KEYBASE ACCOUNT. If you reset your Keybase account, that will let you recover your Keybase username, by killing all your keys. You'll lose your Stellar account in Keybase. So don't do a Keybase account reset unless you've backed up your Stellar private key(s).
5. AVOID SOCIAL ATTACKS. People may beg of thee for thine cryptocurrency. Pay attention to usernames, not photos and full names. Follow people on Keybase, so they turn green, which is a cryptographically signed action. And don't ever install software that other people send you, even if you trust those people. That software may be some kind of social worm. Keybase cannot be responsible for lost tokens due to bugs, hacks, or social attacks. Or anything else for that matter.
6. FINALLY HAVE FUN WHILE YOU CAN. Something is coming.
`
1 change: 1 addition & 0 deletions go/client/cmd_wallet_history.go
Expand Up @@ -61,6 +61,7 @@ func (c *cmdWalletHistory) ParseArgv(ctx *cli.Context) (err error) {
}

func (c *cmdWalletHistory) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_wallet_import.go
Expand Up @@ -49,6 +49,7 @@ func (c *cmdWalletImport) ParseArgv(ctx *cli.Context) (err error) {
}

func (c *cmdWalletImport) Run() (err error) {
defer transformStellarCLIError(&err)
ctx := context.TODO()
secKey, accountID, err := c.promptSecretKey()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_wallet_init.go
Expand Up @@ -38,6 +38,7 @@ func (v *cmdWalletInit) ParseArgv(ctx *cli.Context) (err error) {
}

func (v *cmdWalletInit) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(v.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_lookup.go
Expand Up @@ -37,7 +37,8 @@ func (c *CmdWalletLookup) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *CmdWalletLookup) Run() error {
func (c *CmdWalletLookup) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go/client/cmd_wallet_rename.go
Expand Up @@ -47,6 +47,7 @@ func (c *cmdWalletRename) ParseArgv(ctx *cli.Context) (err error) {
}

func (c *cmdWalletRename) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_request.go
Expand Up @@ -62,7 +62,8 @@ func (c *CmdWalletRequest) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *CmdWalletRequest) Run() error {
func (c *CmdWalletRequest) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_send.go
Expand Up @@ -77,7 +77,8 @@ func (c *CmdWalletSend) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *CmdWalletSend) Run() error {
func (c *CmdWalletSend) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_set_currency.go
Expand Up @@ -55,7 +55,8 @@ func (c *cmdWalletSetCurrency) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *cmdWalletSetCurrency) Run() error {
func (c *cmdWalletSetCurrency) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_set_primary.go
Expand Up @@ -37,7 +37,8 @@ func (c *cmdWalletSetPrimary) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *cmdWalletSetPrimary) Run() error {
func (c *cmdWalletSetPrimary) Run() (err error) {
defer transformStellarCLIError(&err)
cli, err := GetWalletClient(c.G())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion go/client/cmd_wallet_setmobileonly.go
Expand Up @@ -39,7 +39,8 @@ func (c *cmdWalletSetMobileOnly) ParseArgv(ctx *cli.Context) error {
return nil
}

func (c *cmdWalletSetMobileOnly) Run() error {
func (c *cmdWalletSetMobileOnly) Run() (err error) {
defer transformStellarCLIError(&err)
accountID, err := libkb.ParseStellarAccountID(c.accountID)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go/client/prompts.go
Expand Up @@ -66,6 +66,7 @@ const (
PromptDescriptorChatSetConvMinWriterRole
PromptDescriptorChangeLockdownMode
PromptDescriptorImportStellarAccountName
PromptDescriptorStellarDisclaimer
)

const (
Expand Down
16 changes: 16 additions & 0 deletions go/client/stellar_common.go
Expand Up @@ -112,3 +112,19 @@ func printPaymentFilterNote(note string) string {
func cicmp(a, b string) bool {
return strings.ToLower(a) == strings.ToLower(b)
}

func transformStellarCLIError(err *error) {
if err == nil {
return
}
switch e := (*err).(type) {
case libkb.AppStatusError:
if e.Code == libkb.SCStellarNeedDisclaimer {
*err = libkb.NewAppStatusError(&libkb.AppStatus{
Code: e.Code,
Name: e.Name,
Desc: "Stellar disclaimer not yet accepted. Run 'keybase wallet get-started'",
})
}
}
}
5 changes: 0 additions & 5 deletions go/engine/puk_upgrade.go
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"

"github.com/keybase/client/go/libkb"
context "golang.org/x/net/context"
)

// PerUserKeyUpgrade is an engine.
Expand Down Expand Up @@ -98,9 +97,5 @@ func (e *PerUserKeyUpgrade) inner(m libkb.MetaContext) error {
err = RunEngine2(m, eng)
e.DidNewKey = eng.DidNewKey

if eng.DidNewKey {
m.G().GetStellar().CreateWalletSoft(context.Background())
}

return err
}

0 comments on commit 36e9062

Please sign in to comment.