def create_multiple_keypair(): print("Create multiple keypair") sm = StellarMnemonic() secret_phrase = sm.generate() kp0 = Keypair.deterministic(secret_phrase, index=0) kp1 = Keypair.deterministic(secret_phrase, index=1) kp2 = Keypair.deterministic(secret_phrase, index=2) for keypair in (kp0, kp1, kp2): print("Public key / Account address:\n", keypair.address().decode()) print("Seed / Your secret to keep it on local:\n", keypair.seed().decode())
def test_sep0005(self): for data in self.case_data: for i in range(len(data['accounts'])): kp = Keypair.deterministic(mnemonic=data['mnemonic'], passphrase=data['passphrase'], index=i) assert data['accounts'][i] == (kp.address().decode(), kp.seed().decode())
def create_keypair_determinist_english(): print("Create keypair determinist english") mnemonic = ('illness spike retreat truth genius clock brain pass ' 'fit cave bargain toe') keypair = Keypair.deterministic(mnemonic) print("Public key / Account address:\n", keypair.address().decode()) print("Seed / Your secret to keep it on local:\n", keypair.seed().decode())
async def setUpAsync(self): sm = StellarMnemonic("english") secret_phrase = sm.generate() kp = Keypair.deterministic(secret_phrase, lang='english') self.wallet_address = 'GB6PGEFJSXPRUNYAJXH4OZNIZNCEXC6B2JMV5RUGWJECWVWNCJTMGJB4' self.transaction_source_address = 'GDSB3JZDYKLYKWZ6NXDPPGPCYJ32ISMTZ2LVF5PYQGY4B4FGNIU2M5BJ' self.target_address = kp.address().decode() self.amount_xlm = 600 self.host = settings['HOST']
def genMnemonicKeyPair(mnemonicLang='english'): """生成stellar账户,字典返回""" sm = StellarMnemonic(mnemonicLang) mnemonic = sm.generate() keypair = Keypair.deterministic(mnemonic, lang=mnemonicLang) mnemonic_keyPair = dict(mnemonic=str(mnemonic), account=keypair.address(), seed=keypair.seed()) return mnemonic_keyPair
def XLMaddrgen(coin, userid): sm = StellarMnemonic("english") m = sm.generate() kp = Keypair.deterministic(m, lang='english', index=userid) addr = kp.address().decode() seed = kp.seed().decode() print(addr) print(seed) return addr,seed
def mnemonic_keypair(mnemonicLang='english'): """生成stellar账户,字典返回""" sm = StellarMnemonic(mnemonicLang) mnemonic = sm.generate() keypair = Keypair.deterministic(mnemonic, lang=mnemonicLang) return dict( mnemonic=str(mnemonic), # 助记词 account=keypair.address(), # stellar公钥 seed=keypair.seed()) # stellar秘钥
def test_sep0005(self): # https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md mnemonic = 'illness spike retreat truth genius clock brain pass fit cave bargain toe' seed = Keypair.deterministic(mnemonic).seed().decode() seed_expect = 'SBGWSG6BTNCKCOB3DIFBGCVMUPQFYPA2G4O34RMTB343OYPXU5DJDVMN' self.assertEqual(seed, seed_expect) address = Keypair.deterministic(mnemonic, index=6).address().decode() address_expect = 'GBY27SJVFEWR3DUACNBSMJB6T4ZPR4C7ZXSTHT6GMZUDL23LAM5S2PQX' self.assertEqual(address, address_expect) mnemonic = 'cable spray genius state float twenty onion head street palace net private method loan turn phrase state blanket interest dry amazing dress blast tube' seed = Keypair.deterministic(mnemonic, passphrase='p4ssphr4se').seed().decode() seed_expect = 'SAFWTGXVS7ELMNCXELFWCFZOPMHUZ5LXNBGUVRCY3FHLFPXK4QPXYP2X' self.assertEqual(seed, seed_expect) address = Keypair.deterministic(mnemonic, passphrase='p4ssphr4se', index=9).address().decode() address_expect = 'GBOSMFQYKWFDHJWCMCZSMGUMWCZOM4KFMXXS64INDHVCJ2A2JAABCYRR' self.assertEqual(address, address_expect) mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about' seed = Keypair.deterministic(mnemonic).seed().decode() seed_expect = 'SBUV3MRWKNS6AYKZ6E6MOUVF2OYMON3MIUASWL3JLY5E3ISDJFELYBRZ' self.assertEqual(seed, seed_expect) address = Keypair.deterministic(mnemonic, index=8).address().decode() address_expect = 'GABTYCZJMCP55SS6I46SR76IHETZDLG4L37MLZRZKQDGBLS5RMP65TSX' self.assertEqual(address, address_expect)
def setUpClass(cls): cls.mnemonic = ('illness spike retreat truth genius clock brain pass ' 'fit cave bargain toe') cls.keypair0 = Keypair.deterministic(cls.mnemonic) cls.sign_data = "hello".encode() cls.signature = b"\xa3[\xd8Z\xa3\x8a\xb3h'\xdf0\x0e\xf3\xff\x19C\xdf\xc6\xfb\xfb\xe4\xd9\x8c\x9f\x99\xbdU\x11\xf6.\xb1`\x815\xe9\xcd\x81\x006\xe0&\xb3 \x98\xe4w\xe0\x15`\x92s\xd3;h\xc1\x10P&\xec\xbf=\x17\xc5\x07"
def setUpClass(cls): cls.mnemonic = ('illness spike retreat truth genius clock brain pass ' 'fit cave bargain toe') cls.key_pair0 = Keypair.deterministic(cls.mnemonic)
from stellar_base.utils import StellarMnemonic from stellar_base.keypair import Keypair sm = StellarMnemonic() m = sm.generate() print m kp = Keypair.deterministic(m) publickey = kp.address().decode() seed = kp.seed().decode() print publickey print seed
import requests from stellar_base.builder import Builder from stellar_base.address import Address from stellar_base.utils import StellarMnemonic from stellar_base.keypair import Keypair #secret is the phrase so user does not has to enter both #public and private key sm = StellarMnemonic("english") secret = sm.generate() kp = Keypair.deterministic(secret, lang="english", index=1) publickey = kp.address().decode() seed = kp.seed().decode() url = 'https://friendbot.stellar.org' r = requests.get(url, params={'addr': publickey}) print(publickey, seed)
def _generate_keypair(self): if self.mnemonic_secret: kp = Keypair.deterministic(self.mnemonic_secret) return kp
from stellar_base.keypair import Keypair from stellar_base.utils import StellarMnemonic from stellar_base.address import Address import requests for i in range(1, 5): sm = StellarMnemonic() secret_phrase = sm.generate() kp = Keypair.deterministic(secret_phrase) publickey = kp.address().decode() seed = kp.seed().decode() url = 'https://friendbot.stellar.org' r = requests.get(url, params={'addr': publickey}) print('Account Created ') print('Public Key', publickey) print('Seed', seed)