hashgraph / hedera-sdk-swift

Hedera™ SDK for Swift
Apache License 2.0
10 stars 9 forks source link

Getting AccountId from Mnemonic #328

Open cdigiacinto opened 4 months ago

cdigiacinto commented 4 months ago

In case I already have an account on Hedera and I have the mnemonic how I can get the accountId that is associated? (the account was created by using the ECDSA_SECP256K1 public key)

let mnemonic = try Mnemonic.fromString(seed)
let privateKey = try mnemonic.toPrivateKey()

privateKey is a Ed25519

I don't see any methods in the SDK to get the ecdsa publickey so I can then query for this publicKey. The aliasKey is not a reliable alternative because there is no record in the Hedera network of an account associated with a given aliasKey until an amount of Hbar is transferred to the account.

Thank you in advance for your assistance.

cdigiacinto commented 4 months ago

There will be no functionality like in the Hedera SDK js? In Hedera SDK js there is the function toStandardECDSAsecp256k1PrivateKey()

https://github.com/hashgraph/hedera-sdk-js/blob/0feddb25bc2f17399bf0ab346e0464b79f10d0fe/packages/cryptography/src/Mnemonic.js

RickyLB commented 4 months ago

@cdigiacinto Thank you for pointing this out. This functionality will be added to the SDK soon.