Update wallet scripts: rename hdwallet_t.py to pyhdwallet.py and modify recovery script
This commit is contained in:
@@ -491,21 +491,30 @@ def cmd_recover(args):
|
||||
|
||||
def cmd_test(args):
|
||||
with NetworkGuard("test"):
|
||||
require_for_offline(["ethereum"])
|
||||
from bip_utils import Bip39SeedGenerator, Bip39MnemonicValidator
|
||||
require_for_offline(["ethereum", "solana"])
|
||||
|
||||
from bip_utils import Bip39SeedGenerator
|
||||
|
||||
print("🧪 Running tests...")
|
||||
|
||||
# --- Existing vector (yours) ---
|
||||
mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
|
||||
passphrase = "crypto"
|
||||
expected_seed_hex = "92c58d3f4fe52f0111d314f3fa8f10ba498751c37e7c36475c2a5b60145b29708576e11bf6c5c46efac1add0cc26e07c69eb65476742082f9c6460f132181cfe"
|
||||
|
||||
if not Bip39MnemonicValidator().IsValid(mnemonic):
|
||||
raise RuntimeError("Test mnemonic failed validation")
|
||||
|
||||
passphrase = "" # empty
|
||||
seed_bytes = Bip39SeedGenerator(mnemonic).Generate(passphrase)
|
||||
if seed_bytes.hex() != expected_seed_hex:
|
||||
raise RuntimeError("Seed mismatch")
|
||||
|
||||
print("✅ Test passed")
|
||||
# --- NEW: Solana path->address test ---
|
||||
expected_addr = "HAgk14JpMQLgt6rVgv7cBQFJWFto5Dqxi472uT3DKpqk"
|
||||
path = "m/44'/501'/0'/0'"
|
||||
|
||||
seed32 = slip10_ed25519_seed32_from_path(seed_bytes, path) # or slip10_ed25519_seed32_by_path(...)
|
||||
got_addr = sol_pubkey_b58_from_seed32(seed32)
|
||||
|
||||
if got_addr != expected_addr:
|
||||
raise RuntimeError(f"Solana address mismatch for {path}: got {got_addr}, expected {expected_addr}")
|
||||
|
||||
print(f"✅ Solana OK: {path} => {got_addr}")
|
||||
print("✅ All tests passed")
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user