kevinheavey / solders

A high-performance Python toolkit for Solana, written in Rust
https://kevinheavey.github.io/solders/
Apache License 2.0
232 stars 26 forks source link

can't import using secret key ? #73

Closed TIM88-DOT closed 8 months ago

TIM88-DOT commented 10 months ago

I'm not sure if i'm doing this correctly but when I try to import the secret key from an existing keypair it doesn't work for me, though I tried converting it to base58 it still doesn't work. Any help is appreciated !

this is how I generated the keypair and the secret key : mnemo = Mnemonic("english") seed = mnemo.to_seed(mnemonic) keypair = Keypair.from_seed(seed[:32]) secret_key = Keypair.secret()

when I try to import :

private_key_base58 = base58.b58encode(secret_key).decode('utf-8')

keypair = Keypair.from_base58_string(private_key_base58)

^^^ this throws the error : pyo3_runtime.PanicException: called Result::unwrap() on an Err value: signature::Error { source: Some(Keypair must be 64 bytes in length) }

kevinheavey commented 10 months ago

Does it work if you replace private_key_base58 = base58.b58encode(secret_key).decode('utf-8') with private_key_base58 = str(keypair)?