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
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 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 generate_key(): # Generate key print('Generate key..') sm = StellarMnemonic() m = sm.generate() print('Create key pair..') kp = Keypair.deterministic(m) # Return return m, kp
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 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 create_wallet(): print('creating keys...') kp = Keypair.random() if CONF['network'] == 'PUBLIC': print_formatted_text( HTML( '<ansiyellow>WARNING YOU NEED TO FUND AND BACKUP YOUR PRIVATE KEY!</ansiyellow>' )) else: print('.. on testnet... hit f after this to fund') print( 'Public key this is where people send funds to. You need to fund with some lumens to get started\n' ) print_formatted_text( HTML('<ansired>' + kp.address().decode('ascii') + '</ansired>')) print('\nPrivate key please ensure you store securely\n') print_formatted_text( HTML('<ansiyellow>' + kp.seed().decode('ascii') + '</ansiyellow>')) from stellar_base.utils import StellarMnemonic sm = StellarMnemonic(CONF['language'].lower()) secret_phrase = sm.generate() print( '\n if you loose your key you can recreate it with this special passphrase:\n' ) print(secret_phrase) print('') print('> if you want to store this hit y') text = session.prompt(u'> y') if text.lower() == 'n': return # todoo update config if CONF['public_key'] != '': print('only one public key is currently supported') return CONF['public_key'] = kp.address().decode('ascii') CONF['private_key'] = kp.seed().decode('ascii') with open(PTC, 'w') as fp: fp.write(toml.dumps(CONF)) if CONF['network'] != 'TESTNET': print( 'configuration saved - please remember to fund by sending a couple of lumens' )
def __init__(self, secret=''): ''' Generates mnemonic_secret from stellar base, this has to be stored in the database to retrive seed in the future ''' self.stellar_url = 'https://friendbot.stellar.org' if not secret: self.mnemonic_secret = StellarMnemonic().generate() else: # TODO: check if secret is a valid mnemonic string self.mnemonic_secret = secret return
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)
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)