Skip to content

Commit

Permalink
Merge pull request #146 from CityOfZion/CU-86a6hw98x
Browse files Browse the repository at this point in the history
CU-86a6hw98x-BS Lib - Use the fromMnemonic by Ethers.js (Utils)
  • Loading branch information
thiagocbalducci authored Feb 4, 2025
2 parents d0aff2e + ff9ac31 commit 58ae1d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-ethereum",
"comment": "Change the Wallet to HDNode",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-ethereum"
}
8 changes: 5 additions & 3 deletions packages/bs-ethereum/src/BSEthereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ export class BSEthereum<BSName extends string = string>

generateAccountFromMnemonic(mnemonic: string[] | string, index: number): Account<BSName> {
const bip44Path = this.bip44DerivationPath.replace('?', index.toString())
const wallet = ethers.Wallet.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic, bip44Path)
const hd = ethers.utils.HDNode.fromMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic).derivePath(
bip44Path
)

return {
address: wallet.address,
key: wallet.privateKey,
address: hd.address,
key: hd.privateKey,
type: 'privateKey',
bip44Path,
blockchain: this.name,
Expand Down

0 comments on commit 58ae1d4

Please sign in to comment.