Open akhilparakka opened 1 year ago
StellarHDWallet.generateMnemonic()
will generate new random bytes for a new mnemonic everytime. it will ignore the privateKey
that your passing.
because the interface is:
static generateMnemonic({
entropyBits = ENTROPY_BITS,
language = "english",
rngFn = undefined
} = {}) {
so maybe what you want is a wallet for the private key above? if so look at sorry it's Keypair.fromSecret() in stellar-base ...Wallet
in the stellar-sdk package
`const StellarHDWallet = require("stellar-hd-wallet"); const { Keypair } = require("stellar-sdk");
function privateKeyToMnemonic(privateKey) { const mnemonic = StellarHDWallet.generateMnemonic(privateKey); return mnemonic; }
const privateKey = "SBT4B2Y4VN33OCHVPRSD6JXXNPZ2UDXQFLRS7B5C4MLRMLOTEZS4UDY5"; console.log("Private key before: ", privateKey);
const mneumonic = privateKeyToMnemonic(privateKey); console.log("Mneumonic is ", mneumonic);
const wallet = StellarHDWallet.fromMnemonic(mneumonic); console.log(wallet.getSecret(0)); ` The key keeps changing
Private key before: SBT4B2Y4VN33OCHVPRSD6JXXNPZ2UDXQFLRS7B5C4MLRMLOTEZS4UDY5 Mneumonic is decline come potato citizen visual awkward owner illness pigeon save apple snake ordinary salmon twenty uphold toss must put primary oak hollow people ivory SBCNTVPPHD2GDWQTKA7CNCMLI53QDZK7JWKHTDZGTVCV4OIHTSGR5GQI
Private key before: SBT4B2Y4VN33OCHVPRSD6JXXNPZ2UDXQFLRS7B5C4MLRMLOTEZS4UDY5 Mneumonic is dance scatter cry recycle rookie day wage culture fly expect wolf mirror market approve soon before test sleep heavy connect unknown lawsuit lake idle SDZGV6NYGR7BNCWMJV2EUPXSGGGUEZ3C47Y2RPCFF7J7RHC6XZIUEVPU