问题:solana-keygen new生成的地址与用其助记词导入钱包后的地址不一致
答案:将输入BIP39 Passphrase这一步省了,也就是直接回车,啥也不输入。
原理:输入Passphrase会再进行一次加密运算(私钥,公钥都会影响),但钱包里是 仅且只能 用助记词按着衍生路径推导出的。所以会不一致。
这样不输入的,按助记词导入钱包就会和本地生成的地址一致。
常用命令:
~/Doc/solana/zhuhai/hello_world on master ?12 solana-keygen new --help ok at 10:03:05
solana-keygen-new
Generate new keypair file from a random seed phrase and optional BIP39 passphraseUSAGE:solana-keygen new [OPTIONS]OPTIONS:-C, --config <FILEPATH>Configuration file to use [default: /Users/hanpeng/.config/solana/cli/config.yml]--derivation-path [<DERIVATION_PATH>...]Derivation path. All indexes will be promoted to hardened. If arg is not presented thenderivation path will not be used. If arg is presented with empty DERIVATION_PATH valuethen m/44'/501'/0'/0' will be used.-f, --forceOverwrite the output file if it exists-h, --helpPrint help information--language <LANGUAGE>Specify the mnemonic language that will be present in the generated seed phrase[default: english] [possible values: english, chinese-simplified, chinese-traditional,japanese, spanish, korean, french, italian]--no-bip39-passphraseDo not prompt for a BIP39 passphrase--no-outfileOnly print a seed phrase and pubkey. Do not output a keypair file-o, --outfile <FILEPATH>Path to generated file-s, --silentDo not display seed phrase. Useful when piping output to other programs that prompt foruser input, like gpg--word-count <NUMBER>Specify the number of words that will be present in the generated seed phrase [default:12] [possible values: 12, 15, 18, 21, 24]solana-keygen new --derivation-path m/44'/501'/0'/0' --force
solana address
solana-keygen pubkey
solana balance
需要注意如果不加这个参数(显示声明使用衍生路径)
–derivation-path
那么生成的地址也会和钱包导入的对不上。
所以
1:生成的时候用:
solana-keygen new --derivation-path m/44'/501'/0'/0' --force 或者
solana-keygen new --derivation-path --force 都可以
2: 直接回车 不要输入Passphrase
参考:
https://docs.solanalabs.com/cli/wallets/paper
https://www.learnblockchain.cn/article/7425
https://learnblockchain.cn/question/2683