feat: `AccountInfo` extended with `privateKey` property
This commit is contained in:
parent
c1c7d2dbf6
commit
006d0ba847
|
@ -28,12 +28,14 @@ func NewAccount(privateKey *ecdsa.PrivateKey, extKey *extkeys.ExtendedKey) Accou
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Account) ToAccountInfo() AccountInfo {
|
func (a *Account) ToAccountInfo() AccountInfo {
|
||||||
|
privateKeyHex := types.EncodeHex(crypto.FromECDSA(a.privateKey))
|
||||||
publicKeyHex := types.EncodeHex(crypto.FromECDSAPub(&a.privateKey.PublicKey))
|
publicKeyHex := types.EncodeHex(crypto.FromECDSAPub(&a.privateKey.PublicKey))
|
||||||
addressHex := crypto.PubkeyToAddress(a.privateKey.PublicKey).Hex()
|
addressHex := crypto.PubkeyToAddress(a.privateKey.PublicKey).Hex()
|
||||||
|
|
||||||
return AccountInfo{
|
return AccountInfo{
|
||||||
PublicKey: publicKeyHex,
|
PrivateKey: privateKeyHex,
|
||||||
Address: addressHex,
|
PublicKey: publicKeyHex,
|
||||||
|
Address: addressHex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +60,9 @@ func (a *Account) ToGeneratedAccountInfo(id string, mnemonic string) GeneratedAc
|
||||||
|
|
||||||
// AccountInfo contains a PublicKey and an Address of an account.
|
// AccountInfo contains a PublicKey and an Address of an account.
|
||||||
type AccountInfo struct {
|
type AccountInfo struct {
|
||||||
PublicKey string `json:"publicKey"`
|
PrivateKey string `json:"privateKey"`
|
||||||
Address string `json:"address"`
|
PublicKey string `json:"publicKey"`
|
||||||
|
Address string `json:"address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// IdentifiedAccountInfo contains AccountInfo and the ID of an account.
|
// IdentifiedAccountInfo contains AccountInfo and the ID of an account.
|
||||||
|
|
Loading…
Reference in New Issue