meherett / python-hdwallet

Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies.
https://hdwallet.readthedocs.io
MIT License
453 stars 150 forks source link

generate Ripple (XRP wallet address) #89

Open minhanh1234 opened 1 year 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