Exemplo n.º 1
0
def main(seed, network, children, pretty, random_seed=False):
    '''Where args is the seed to use.
    If none specified, reads from STDIN.

    pywallet-cli traffic happy world clog clump cattle great toy game absurd alarm auction

    cat myseeds.txt | pywallet-cli

    pywallet-cli --network=ETH --children=3 --no-pretty --random-seed
    '''
    # generate 12 word mnemonic seed
    if seed:
        seed = " ".join(seed)
    else:
        if random_seed:
            seed = wallet.generate_mnemonic()
        else:
            arr = []
            for words in sys.stdin:
                arr.extend(words.split())
                if len(arr) >= 12:
                    break
            seed = " ".join(arr)

    # create bitcoin wallet
    w = wallet.create_wallet(network=network, seed=seed, children=children)
    b2asc(w)

    indent = 4 if pretty else None
    print(json.dumps(w, sort_keys=True, indent=indent))
Exemplo n.º 2
0
 def generate(self):
     seed = wallet.generate_mnemonic()
     w = wallet.create_wallet(network="omni", seed=seed, children=1)
     wif = w.get('wif').decode("utf-8")
     address = w.get('address')
     seed = w.get('seed')
     return CryptoCoin(address, wif, seed)
Exemplo n.º 3
0
def create(password=None, coinType=None, network="btctest", number=1):
    '''create main wallet'''
    # generate 12 word mnemonic seed
    seed = wallet.generate_mnemonic()
    # create bitcoin wallet
    w = wallet.create_wallet(network=network, seed=seed, children=1)

    statement = "INSERT INTO account VALUES(?,?,?,?,?,?)"
    data = [(1, "main", w['address'], w['private_key'], coinType, seed)]
    conn.executemany(statement, data)
    conn.commit()

    WALLET_PUBKEY = w['xpublic_key']
    print(WALLET_PUBKEY)

    for index in range(number):
        print(index)
        child_id = wallet.generate_child_id()
        # generate address for specific user (id = 10)
        user_addr = wallet.create_address(network=network,
                                          xpub=WALLET_PUBKEY,
                                          child=child_id)

        statement = "INSERT INTO account VALUES(?,?,?,?,?,?)"
        data = [(index + 2, "child", user_addr['address'], None, coinType,
                 None)]
        conn.executemany(statement, data)
        conn.commit()

        print("User Address\n", user_addr)

        print("============================")
Exemplo n.º 4
0
async def wallet_creation(username):
    """
    To create a new wallet, the user must be signed in, which means the Client has the
    encryptionKey available in the browser’s process memory and a valid JWT.
    """
    mnemonic = wallet.generate_mnemonic()

    logger.debug(mnemonic)
    encryptedMnemonicPhrase = aes_encrypt_CBC(ENCRYPTION_KEY,
                                              mnemonic.encode("utf-8"))
    logger.debug(encryptedMnemonicPhrase)

    w = wallet.create_wallet(network="ETH", seed=mnemonic, children=1)
    pprint(w)

    data = {
        "username": username,
        'eth_address': w["address"],
        "encryptedMnemonicPhrase": encryptedMnemonicPhrase.hex()
    }

    pprint(data)
    async with aiohttp.ClientSession(
            headers={"Authorization": ID_TOKEN}) as session:

        async with session.post(URL_ETHEREUM_UPDATE_MNEMONIC_ADDRESS,
                                json=data) as response:
            result = await response.json()
            pprint(result)
    return
Exemplo n.º 5
0
def generate_new_tree(network):
    seed = wallet.generate_mnemonic()
    w = wallet.create_wallet(network=network, seed=seed, children=1)
    return {
        'mnemonic': seed,
        'xprivate_key': w['xprivate_key'],
        'xpublic_key': w['xpublic_key']
    }
Exemplo n.º 6
0
 def gen_addr(self):
     seed = wallet.generate_mnemonic()
     w = wallet.create_wallet(network="BTC", seed=seed, children=1)
     address = w["address"]
     priv_key = w["private_key"]
     newCryptoAddress = CryptoAddress(crypto_type='btc',
                                      crypto_address=address,
                                      crypto_priv_key=priv_key)
     newCryptoAddress.save()
     return address, priv_key
    def __init__(self, name, seed, children):
        if (seed == "0"):
            self.seed = wallet.generate_mnemonic()
        else:
            self.seed = seed

        self.name = name
        self.children = children
        self.wallet = wallet.create_wallet(network="ETH",
                                           seed=self.seed,
                                           children=self.children)
        self.wallet_data = dict(self.wallet)
def create_wallet(seed=None, children=1):
    if seed is None:
        seed = generate_mnemonic()

    net = get_network()
    wallet = {
        "coin": net.COIN,
        "seed": seed,
        "private_key": "",
        "public_key": "",
        "xprivate_key": "",
        "xpublic_key": "",
        "address": "",
        "wif": "",
        "children": []
    }

    my_wallet = DucatusWallet.from_master_secret(network='ducatus', seed=seed)

    print(my_wallet.__dict__)

    # account level
    wallet["private_key"] = my_wallet.private_key.get_key().decode()
    wallet["public_key"] = my_wallet.public_key.get_key().decode()
    wallet["xprivate_key"] = my_wallet.serialize_b58(private=True)
    wallet["xpublic_key"] = my_wallet.serialize_b58(private=False)
    wallet["address"] = my_wallet.to_address()
    wallet["wif"] = my_wallet.export_to_wif()

    prime_child_wallet = my_wallet.get_child(0, is_prime=True)
    wallet["xpublic_key_prime"] = prime_child_wallet.serialize_b58(
        private=False)

    # prime children
    for child in range(children):
        child_wallet = my_wallet.get_child(child,
                                           is_prime=False,
                                           as_private=False)
        wallet["children"].append({
            "xpublic_key":
            child_wallet.serialize_b58(private=False),
            "address":
            child_wallet.to_address(),
            "path":
            "m/" + str(child),
            "bip32_path":
            net.BIP32_PATH + str(child_wallet.child_number),
        })

    print(wallet)

    return wallet
Exemplo n.º 9
0
    def __init__(self):
        from pywallet import wallet as w

        self.coin = ''
        self.private_key = ''
        self.public_key = ''
        self.address = ''

        self.seed = w.generate_mnemonic()
        self.wallet = w.create_wallet(network='BTC',
                                      seed=self.seed,
                                      children=0)
        self.parse_response()
Exemplo n.º 10
0
def create_wallet():

    seed = wallet.generate_mnemonic()
    w = wallet.create_wallet(network="BTC", seed=seed, children=1)
    w["coin"] = "UCW"
    w["balance"] = 0
    try:
        w["wif"] = w["wif"].decode("utf-8")
    except:
        del (w["wif"])
        pass

    #Add Wallet to DB as well

    return w
Exemplo n.º 11
0
def createBtcWallet():
    seed = wallet.generate_mnemonic()
    tempWallet = wallet.create_wallet(network="BTC", seed=seed, children=1)
    now = datetime.datetime.now()
    #this creates the logfile which stores the seed and public key incase of exchange faliure
    file = open("BTClog.txt", "a")
    file.write(now.strftime("%Y-%m-%d %H:%M:%S Generated Seed: "))
    file.write(seed)
    file.write("\n")
    file.write("Refund Public Key: ")
    #this line writes the actual public address
    file.write(tempWallet['address'])
    file.write("\n")
    file.close()
    return (tempWallet['address'])
Exemplo n.º 12
0
def generate_ethereum_wallet(query_params={}):
    if blockchain_validator.generate_litecoin_wallet(query_params):
        if query_params != {}:
            mnemonic = query_params['mnemonic']
        else:
            mnemonic = wallet.generate_mnemonic(strength=256)

        if Bip39MnemonicValidator(mnemonic).Validate():
            w = wallet.create_wallet(network="ETH", seed=mnemonic, children=1)
            return {
                "xpriv": w['xprivate_key'].decode("utf-8"),
                "xpub": w['xpublic_key'].decode("utf-8"),
                "mnemonic": mnemonic
            }
        else:
            return 'Mnemonic is not valid!'
Exemplo n.º 13
0
def create_adminwallet(request):
    ctx = {}
    if request.method == 'POST':
        seed = wallet.generate_mnemonic()
        w = wallet.create_wallet(network='ETH', seed=seed)
        coin = 'ETH'
        xpub = w['xpublic_key']
        xpriv = w['xprivate_key']
        address = w['address']
        admin_wallet = Admin_wallet.objects.create(seed=seed,
                                                   coin=coin,
                                                   xpub=xpub,
                                                   xpriv=xpriv,
                                                   address=address)
        ctx = {'admin_wallet': admin_wallet}

    return render(request, 'create_adminwallet.html', ctx)
Exemplo n.º 14
0
def generate_bitcoin_wallet(query_params={}):
    if blockchain_validator.generate_litecoin_wallet(query_params):
        if query_params != {}:
            mnemonic = query_params['mnemonic']
        else:
            mnemonic = wallet.generate_mnemonic(strength=256)

        if Bip39MnemonicValidator(mnemonic).Validate():
            seed_bytes = Bip39SeedGenerator(mnemonic).Generate()
            bip32_ctx = Bip32.FromSeedAndPath(seed_bytes, "m/44'/0'/0'/0")
            return {
                "xpriv": bip32_ctx.PrivateKey().ToExtended(),
                "xpub": bip32_ctx.PublicKey().ToExtended(),
                "mnemonic": mnemonic
            }
        else:
            return 'Mnemonic is not valid!'
Exemplo n.º 15
0
from pywallet import wallet

seed = wallet.generate_mnemonic()

w = wallet.create_wallet(network="BTC", seed=seed, children=1)

print(w)
Exemplo n.º 16
0
 def createSeed():
     return wallet.generate_mnemonic()
     
Exemplo n.º 17
0
def gen_wallet():
    seed = wallet.generate_mnemonic()
    w = wallet.create_wallet(network="BTC", seed=seed, children=1)
    return jsonify(w), 200