Skip to content

Commit

Permalink
refactor: Add renamed randomSeedPhrase method
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Oct 11, 2024
1 parent bbe6c9a commit 64be49f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ This likely was a misunderstood and unused feature.

- `AddressHashMode`: The `Serialize` prefixes were removed for brevity.
- `makeRandomPrivKey` was renamed to `randomPrivateKey` and now returns a compressed private key.
- `generateSecretKey` was renamed to `randomSeedPhrase`.

## Stacks.js (<=4.x.x) → (5.x.x)

Expand Down
21 changes: 16 additions & 5 deletions packages/wallet-sdk/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,24 @@ import { bytesToHex } from '@stacks/common';

export type AllowedKeyEntropyBits = 128 | 256;

export const generateSecretKey = (entropy: AllowedKeyEntropyBits = 256) => {
const secretKey = generateMnemonic(wordlist, entropy);
return secretKey;
};
/**
* Generate a random 12 or 24 word mnemonic phrase.
*
* @example
* ```ts
* const phrase = randomSeedPhrase();
* // "warrior volume sport ... figure cake since"
* ```
*/
export function randomSeedPhrase(entropy: AllowedKeyEntropyBits = 256): string {
return generateMnemonic(wordlist, entropy);
}

/** @deprecated Use {@link randomSeedPhrase} instead */
export const generateSecretKey = randomSeedPhrase;

/**
* Generate a new [[Wallet]].
* Generate a new {@link Wallet}.
* @param secretKey A 12 or 24 word mnemonic phrase. Must be a valid bip39 mnemonic.
* @param password A password used to encrypt the wallet
*/
Expand Down

0 comments on commit 64be49f

Please sign in to comment.