Wallet exposes its public key

This commit is contained in:
Mark Spanbroek 2021-04-06 13:49:06 +02:00
parent fbb95c42d9
commit 6d75ca5948
2 changed files with 6 additions and 1 deletions

View File

@ -25,8 +25,11 @@ type
func init*(_: type Wallet, key: PrivateKey): Wallet =
result.key = key
func publicKey*(wallet: Wallet): PublicKey =
wallet.key.toPublicKey
func address*(wallet: Wallet): EthAddress =
wallet.key.toPublicKey.toAddress
wallet.publicKey.toAddress
func destination*(wallet: Wallet): Destination =
wallet.address.toDestination

View File

@ -5,7 +5,9 @@ suite "wallet":
test "wallet is created from private key":
let key = PrivateKey.random()
let wallet = Wallet.init(key)
check wallet.publicKey == key.toPublicKey
check wallet.address == key.toPublicKey.toAddress
check wallet.destination == key.toPublicKey.toAddress.toDestination
suite "wallet: opening ledger channel":