├── README.md ├── config.py ├── main.py └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | # 环境安装 2 | 3 | ## 安装Anaconda 4 | 5 | 1. **下载Anaconda安装包:** 6 | - 访问[Anaconda官网](https://www.anaconda.com/download)下载适用于Mac的Anaconda安装器。 7 | 2. **安装Anaconda:** 8 | - 打开下载的安装包并遵循安装向导的指示完成安装。默认情况下,Anaconda会安装在你的用户目录下。 9 | 3. **验证安装:** 10 | - 打开终端(Terminal),输入`conda list`。如果Anaconda已正确安装,此命令将列出已安装的包。 11 | 12 | ## 配置VS Code以使用Anaconda 13 | 14 | 1. **安装Python扩展:** 15 | - 打开VS Code,转到扩展视图(点击侧边栏的方块图标或使用快捷键`Cmd+Shift+X`)。 16 | - 搜索“Python”,然后安装由Microsoft发布的Python扩展。 17 | 2. **配置Python解释器:** 18 | - 打开VS Code中的一个Python文件或创建一个新的Python文件。 19 | - 点击状态栏底部的Python解释器版本,或通过命令面板(`Cmd+Shift+P`,然后输入`Python: Select Interpreter`)选择解释器。 20 | 21 | ## 安装依赖 22 | 23 | 1. 打开项目代码后,在终端输入` pip install -r requirements.txt` 安装所需的依赖。 24 | 25 | 26 | 27 | # 程序配置 28 | 29 | 打开` config.py` 文件,mnemoic = 助记词, create_amount = 需要创建的钱包数量 30 | 31 | 32 | 33 | # 程序运行 34 | 35 | 1. 在vs code中打开`main.py` 文件,右键-> 运行Python -> 在终端中运行Python文件 36 | 2. 创建的钱包保存在 `data/output`目录下。 37 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | mnemonic = '' 2 | create_amount = 10 -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from bip_utils import Bip39SeedGenerator, Bip44Coins, Bip44, base58, Bip44Changes 2 | import pandas as pd 3 | # 导入配置文件中的参数 4 | import config 5 | 6 | class BlockChainAccount(): 7 | 8 | def __init__(self, mnemonic, coin_type=Bip44Coins.ETHEREUM, password='', num=1) -> None: 9 | 10 | self.mnemonic = mnemonic.strip() 11 | self.coin_type = coin_type 12 | self.password = password # if have password 13 | self.num = num 14 | 15 | def get_address_pk(self): 16 | wallets = [] 17 | for i in range(self.num): 18 | 19 | seed_bytes = Bip39SeedGenerator(self.mnemonic).Generate(self.password) 20 | # if self.coin_type != Bip44Coins.SOLANA: 21 | # bip44_mst_ctx = Bip44.FromSeed(seed_bytes, self.coin_type).DeriveDefaultPath() 22 | # return bip44_mst_ctx.PublicKey().ToAddress(), bip44_mst_ctx.PrivateKey().Raw().ToHex() 23 | # else: 24 | bip44_mst_ctx = Bip44.FromSeed(seed_bytes, self.coin_type) 25 | bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(i) 26 | bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT) # if you use "Solflare", remove this line and make a simple code modify and test 27 | priv_key_bytes = bip44_chg_ctx.PrivateKey().Raw().ToBytes() 28 | public_key_bytes = bip44_chg_ctx.PublicKey().RawCompressed().ToBytes()[1:] 29 | key_pair = priv_key_bytes+public_key_bytes 30 | wallet_info = {'Wallet': f'Wallet-{i+1}', 'Address': bip44_chg_ctx.PublicKey().ToAddress(), 'PriveteKey': base58.Base58Encoder.Encode(key_pair)} 31 | wallets.append(wallet_info) 32 | df = pd.DataFrame(wallets) 33 | df.to_csv('./data/output/solana_wallets.csv', index=False) 34 | 35 | 36 | 37 | coin_types = { 38 | # Bip44Coins.ETHEREUM: 'ethereum(evm)', 39 | Bip44Coins.SOLANA: 'solana', 40 | # Bip44Coins.TERRA: 'luna', 41 | # Bip44Coins.DASH: 'dash', 42 | # ..... 43 | # also support other chain, such as file coin, eth classic, doge, dash, luna .... 44 | # example change coin_type as Bip44Coins.EOS, Bip44Coins.TERRA ..... 45 | } 46 | for coin_type in coin_types.keys(): 47 | chain_name = coin_types[coin_type] 48 | bca = BlockChainAccount(mnemonic=config.mnemonic, coin_type=coin_type, num=config.create_amount) 49 | bca.get_address_pk() 50 | 51 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | asn1crypto==1.5.1 2 | bip-utils==2.9.1 3 | cbor2==5.6.1 4 | cffi==1.16.0 5 | coincurve==18.0.0 6 | crcmod==1.7 7 | ecdsa==0.18.0 8 | ed25519-blake2b==1.4.1 9 | numpy==1.26.4 10 | pandas==2.2.1 11 | py-sr25519-bindings==0.2.0 12 | pycparser==2.21 13 | pycryptodome==3.20.0 14 | PyNaCl==1.5.0 15 | python-dateutil==2.8.2 16 | pytz==2024.1 17 | six==1.16.0 18 | tzdata==2024.1 19 | --------------------------------------------------------------------------------