github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/stellar/stellarsvc/service_devel.go (about) 1 // Copyright 2018 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 // 4 //go:build !production 5 // +build !production 6 7 package stellarsvc 8 9 import ( 10 "context" 11 "errors" 12 13 "github.com/keybase/client/go/libkb" 14 "github.com/keybase/client/go/protocol/stellar1" 15 "github.com/keybase/client/go/stellar/remote" 16 ) 17 18 func (s *Server) WalletDumpLocal(ctx context.Context) (dump stellar1.Bundle, err error) { 19 if s.G().Env.GetRunMode() != libkb.DevelRunMode { 20 return dump, errors.New("WalletDump only supported in devel run mode") 21 } 22 23 mctx, fin, err := s.Preamble(ctx, preambleArg{ 24 RPCName: "WalletDumpLocal", 25 Err: &err, 26 }) 27 defer fin() 28 if err != nil { 29 return dump, err 30 } 31 32 // verify passphrase 33 username := s.G().GetEnv().GetUsername().String() 34 35 arg := libkb.DefaultPassphrasePromptArg(mctx, username) 36 secretUI := s.uiSource.SecretUI(s.G(), 0) 37 res, err := secretUI.GetPassphrase(arg, nil) 38 if err != nil { 39 return dump, err 40 } 41 _, err = libkb.VerifyPassphraseForLoggedInUser(mctx, res.Passphrase) 42 if err != nil { 43 return dump, err 44 } 45 46 bundle, err := remote.FetchSecretlessBundle(mctx) 47 if err != nil { 48 return dump, err 49 } 50 newAccBundles := make(map[stellar1.AccountID]stellar1.AccountBundle) 51 for _, acct := range bundle.Accounts { 52 singleBundle, err := remote.FetchAccountBundle(mctx, acct.AccountID) 53 if err != nil { 54 // if we can't fetch the secret for this account, just continue on 55 continue 56 } 57 accBundle := singleBundle.AccountBundles[acct.AccountID] 58 newAccBundles[acct.AccountID] = accBundle 59 } 60 bundle.AccountBundles = newAccBundles 61 62 return *bundle, err 63 }