github.com/elastos/Elastos.ELA.SideChain.ETH@v0.2.2/dpos/account.go (about)

     1  // Copyright (c) 2017-2019 The Elastos Foundation
     2  // Use of this source code is governed by an MIT
     3  // license that can be found in the LICENSE file.
     4  //
     5  
     6  package dpos
     7  
     8  import (
     9  	"github.com/elastos/Elastos.ELA.SideChain.ESC/chainbridge-core/crypto"
    10  	"github.com/elastos/Elastos.ELA.SideChain.ESC/chainbridge-core/crypto/secp256k1"
    11  	"github.com/elastos/Elastos.ELA/account"
    12  	daccount "github.com/elastos/Elastos.ELA/dpos/account"
    13  )
    14  
    15  func GetDposAccount(keystorePath string, password []byte) (daccount.Account, error) {
    16  	client, err := account.Open(keystorePath, password)
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  	return daccount.New(client.GetMainAccount()), nil
    21  }
    22  
    23  func GetBridgeAccount(keystorePath string, password []byte) (crypto.Keypair, error) {
    24  	client, err := account.Open(keystorePath, password)
    25  	if err != nil {
    26  		return nil, err
    27  	}
    28  	return secp256k1.NewKeypairFromPrivateKey(client.GetMainAccount().PrivateKey)
    29  }