Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate XRP Wallet address using 12 seed phrase #631

Closed
minhanh1234 opened this issue Aug 11, 2023 · 4 comments
Closed

Generate XRP Wallet address using 12 seed phrase #631

minhanh1234 opened this issue Aug 11, 2023 · 4 comments

Comments

@minhanh1234
Copy link

Does anyone have a python code to generate a XRP wallet address using the a 12 seed phrase?

@JST5000
Copy link
Contributor

JST5000 commented Aug 11, 2023

My guess is that the 12 seed phrase is a bip39 mnemonic. Unfortunately xrpl-py doesn't currently have support for that, but I believe you can get there by combining other libraries that can decode bip39 values and xrpl-py.

In order to get an account, if you can create a Wallet in xrpl-py, you'll be able to access the account address for it. Account addresses on the XRPL are derived from the public key corresponding to an account's original public/private key.

Here's the steps to turn a bip39 mnemonic into a Wallet in xrpl.js:
In xrpl.js, these are the steps used to do that:
https://github.com/XRPLF/xrpl.js/blob/bedb1f0f319d364909258d4c48455bded5bf73b8/packages/xrpl/src/Wallet/index.ts#L241-L256

From a quick google, this library seems to handle decoding bip39 mnemonics: https://pypi.org/project/bip39/

Keep in mind that XRPL uses two kinds of encodings for seeds. XRPL seeds usually start with s if encoded with secp256k1 (ex. ss1x3KLrSvfg7irFc1D929WXZ7z9H), and sEd if encoded with ED25519 (ex. sEd7N8SGDaUreeXw3FkRi3Q1okpXATq). If you follow a similar flow to the xrpl.js logic and end up with a different account than you expected, try explicitly setting the algorithm in the options to the other type of encoding. Older seeds tend to use secp256k1 while more recently generated seeds have started defaulting to ED25519 since it's a bit more efficient.

Another path if the above doens't work is to get the public / private keys, and use those to generate an xrpl-py Wallet from it's constructor. I'm not sure exactly how to do that from bip39 mnemonic unfortunately, but it's an alternative.

@JST5000
Copy link
Contributor

JST5000 commented Aug 11, 2023

If you do write that logic, it'd be great to open a PR to the library so we can share it more broadly! Happy to try to answer any questions you have to the best of my ability.

@JST5000
Copy link
Contributor

JST5000 commented Aug 15, 2023

Closing for now, feel free to re-open if needed.

@JST5000 JST5000 closed this as completed Aug 15, 2023
@JST5000
Copy link
Contributor

JST5000 commented Aug 15, 2023

@ckniffen Happened to find a better answer to your question @minhanh1234! - This response by @LimpidCrypto seems to be a way you can resolve your problem I believe: #419 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants