talonlab / python-hdwallet

Python-based library for the implementation of a Hierarchical Deterministic (HD) Wallet generator supporting more than 200 cryptocurrencies.
https://hdwallet.readthedocs.io
MIT License
482 stars 151 forks source link

generate Ripple (XRP wallet address) #89

Closed minhanh1234 closed 3 days ago

minhanh1234 commented 1 year ago

how can i use your script to generate Ripple (XRP wallet address) base of 12 seed phrase word?

Ripple | XRP | Yes | No | No | 144 | m/44'/144'/0'/0/0

hellsontime commented 1 year ago

prolly like this:

from hdwallet import BIP44HDWallet
from hdwallet.cryptocurrencies import RippleMainnet
from hdwallet.derivations import BIP44Derivation
from hdwallet.symbols import XRP

from .BaseGeneratorService import BaseGeneratorService

class XRPGeneratorService(BaseGeneratorService):
    def __init__(self, mnemonic, language):
        super().__init__(XRP, mnemonic, language)

    def generate(self, derivation_id: int = 0):
        bip44_hdwallet: BIP44HDWallet = BIP44HDWallet(cryptocurrency=RippleMainnet)
        bip44_hdwallet.from_mnemonic(
            mnemonic=self.mnemonic, language=self.language, passphrase=self.passphrase
        )
        bip44_hdwallet.clean_derivation()

        bip44_derivation: BIP44Derivation = BIP44Derivation(
            cryptocurrency=RippleMainnet, account=0, change=False, address=derivation_id
        )
        bip44_hdwallet.from_path(path=bip44_derivation)

        return bip44_hdwallet