Код: Выделить всё
def generate_BTC_address(self, passphrase=""):
try:
# Generar la semilla usando la frase mnemotécnica y la passphrase
seed_generator = Bip39SeedGenerator(self.seed)
seed = seed_generator.Generate(passphrase)
print("1")
# Derivar las claves usando BIP-44 para Bitcoin
bip44_wallet = Bip44.FromSeed(seed, Bip44Coins.BITCOIN)
print("2")
account = bip44_wallet.Purpose().Coin().Account(0)
print("2.5")
# Derivar la cuenta 0, cambio 0 (dirección externa), índice 0
# Derivar el cambio 0 (dirección externa)
change = account.Change(0)
print("2.75 xd")
# Derivar la primera dirección (AddressIndex 0)
btc_account = change.AddressIndex(0)
print("3")
# Clave privada (en formato hexadecimal)
private_key = btc_account.PrivateKey().Raw().ToHex()
print("4")
# Dirección Bitcoin (clave pública en formato de dirección)
address = btc_account.PublicKey().ToAddress()
print(f"Semilla: {seed.hex()}")
print(f"Clave privada: {private_key}")
print(f"Dirección Bitcoin: {address}")
except Exception as e:
print(f"Error: {e}")
return None, None, False
return private_key, address, True
И я получаю следующее исключение: «Индекс изменения не является перечисляемым числом Bip44Changes». " конкретно в этой строке:
Код: Выделить всё
change = account.Change(0)
Подробнее здесь: https://stackoverflow.com/questions/792 ... tils-to-ge