MCPcopy Create free account
hub / github.com/DNAProject/DNA / initAccount

Function initAccount

main.go:225–250  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

223}
224
225func initAccount(ctx *cli.Context) (*account.Account, error) {
226 if !config.DefConfig.Consensus.EnableConsensus {
227 return nil, nil
228 }
229 walletFile := ctx.GlobalString(utils.GetFlagName(utils.WalletFileFlag))
230 if walletFile == "" {
231 return nil, fmt.Errorf("Please config wallet file using --wallet flag")
232 }
233 if !common.FileExisted(walletFile) {
234 return nil, fmt.Errorf("Cannot find wallet file: %s. Please create a wallet first", walletFile)
235 }
236
237 acc, err := cmdcom.GetAccount(ctx)
238 if err != nil {
239 return nil, fmt.Errorf("get account error: %s", err)
240 }
241 log.Infof("Using account: %s", acc.Address.ToBase58())
242
243 if config.DefConfig.Genesis.ConsensusType == config.CONSENSUS_TYPE_SOLO {
244 curPk := hex.EncodeToString(keypair.SerializePublicKey(acc.PublicKey))
245 config.DefConfig.Genesis.SOLO.Bookkeepers = []string{curPk}
246 }
247
248 log.Infof("Account init success")
249 return acc, nil
250}
251
252func initLedger(ctx *cli.Context, stateHashHeight uint32) (*ledger.Ledger, error) {
253 events.Init() //Init event hub

Callers 1

startDNAFunction · 0.85

Calls 5

GetFlagNameFunction · 0.92
ErrorfMethod · 0.80
GetAccountMethod · 0.80
InfofMethod · 0.80
ToBase58Method · 0.80

Tested by

no test coverage detected