Closed Jinxiansen closed 4 years ago
Hi there, mnemonic seed support hasn't been implemented yet (see #17)
@randomshinichi How long does it take to support this?
We need to support ae account
in our Golang project, but we have not found a valid solution to create ae account with mnemonics.
😣
@randomshinichi let's prioritise #17
@Jinxiansen hi there, I looked into it today. I should have the feature in 5-7 working days. Please hold tight until then :)
@randomshinichi Good, thank you very much! 🍺🍺🍺
@randomshinichi @noandrea Hello, how long does it take for the mnemonic to create a wallet? It’s Friday tomorrow! 🥰
@Jinxiansen I can now parse a mnemonic. The problem is getting to an equivalent address from that, which means HD wallet support. So far I have AEX-10 (HD Wallet support) working as a proof of concept, but it needs to be properly implemented with unittests etc.
@randomshinichi alright, thank you very much! How long does it take?
@Jinxiansen I'll make another branch so you can follow the progress there. It will be released as part of 7.0.0 on Friday.
@randomshinichi Ok, that's great ! Thank you very much !🥰
@Jinxiansen The branch is feature/hdwallet.
Okay!thanks!😀😀
------------------ Original ------------------ From: Allen Wang notifications@github.com Date: Wed,Nov 6,2019 1:37 AM To: aeternity/aepp-sdk-go aepp-sdk-go@noreply.github.com Cc: 晋先森 hi@jinxiansen.com, Mention mention@noreply.github.com Subject: Re: [aeternity/aepp-sdk-go] How to create ae acount using 12 mnemonics ? (#131)
@Jinxiansen The branch is feature/hdwallet.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@Jinxiansen It's basically done at this point, but the interface may not be the most convenient for you right now. So I want to ask - how would you typically use the hd wallet functionality? Would you need create many subaccounts at once, or keep the master account in memory, or do you just need it to get a particular subaccount and nothing else?
@randomshinichi
Hello! Our project is an application that collects multiple blockchain currencies. A mnemonic is used to generate the private key and address corresponding to multiple currencies. At the time of payment, the transaction is signed according to the private key obtained by the user password.
So we need to create the private key and address of the AE
coin through the mnemonic.
@randomshinichi Hello, how is the progress now?
@Jinxiansen I am making a release today. Just realized it probably isn't good to make a new release on a Friday ;)
@randomshinichi
Hey, look forward to your release! This has been waiting for half a month! A little anxious..🍺🍺🍺
@randomshinichi
Thanks for your help, I used the code of the hdwallet
branch to basically implement the process of importing the wallet via the mnemonic/private key, as well as the method of trading the signature.
thank you very much!
Import wallet
func (c *ae) GetWalletAccount() *WalletAccount {
mnemonic := c.GetKey().Mnemonic
seedBytes, err := account.ParseMnemonic(mnemonic)
if err != nil {
return &WalletAccount{Res: 0, ErrMsg: err.Error()}
}
path := "m/44'/457'/0'/0'/0'"
key, err := account.DerivePathFromSeed(seedBytes, path)
if err != nil {
return &WalletAccount{Res: 0, ErrMsg: err.Error()}
}
acc, err := account.BIP32KeyToAeKey(key)
if err != nil {
return &WalletAccount{Res: 0, ErrMsg: err.Error()}
}
privStr := acc.SigningKeyToHexString()
return &WalletAccount{
Res: 1,
PrivateKey: privStr,
Address: acc.Address,
PublicKey: acc.Address,
}
}
Sign
func (c *ae) SignRawTransaction(signIn *SignInput) (*SignResult, error) {
var params AEPPParams
err := json.Unmarshal(signIn.Params, ¶ms)
if err != nil {
fmt.Println("Parse Error: ", err)
return nil, err
}
tx := transactions.NewSpendTx(signIn.SrcAddr,
signIn.DestAddr,
big.NewInt(signIn.Amount),
big.NewInt(signIn.Fee),
[]byte(signIn.Memo),
uint64(params.TTL),
uint64(params.TTL))
txJSON, err := tx.JSON()
fmt.Println("AE JSON: ", txJSON)
gotTx, err := transactions.SerializeTx(tx)
if err != nil {
fmt.Println("Error: ", err)
return nil, err
}
return &SignResult{Res: 1, RawTX: gotTx}, nil
}
As implemented in v7 release (feature/hdwallet will be deleted soon)
To make things foolproof, DerivePathFromSeed does not let you specify the full path. m/44'/457'/0'
/0'/0'
key, err := account.DerivePathFromSeed(seedBytes, 0, 0)
Also you may find this function in package transactions
useful:
signedTx, hash, signature, err := transactions.SignHashTx(signingAccount, tx, networkID)
oh! I am looking forward to the release of the new version. I will modify it then.
I only found the account created by the private key or keystore in
aepp sdk go
, but I didn't find the way to pass the mnemonic. How do I create an ae account with 12 mnemonics? 🤫