Ejemplo n.º 1
0
    def genContractWallet(self, nickname=None):
        path = os.path.join(self.topDir, 'wallets')
        if not os.path.isdir(path):
            os.mkdir(path)
        if nickname:
            for i, c in enumerate(self.contracts):
                if c["nickname"] == nickname:
                    print_msg("{} contract exists.".format(nickname))
                    return self.getContractWallet(i), c
        #print(type(self.contracts))
        #this next loop generates a wallet name that isn't in use yet.
        if self.contracts == []:
            walletFile = os.path.join(self.topDir, 'wallets',
                                      'contract0.wallet')
        else:
            walletNames = []
            for c in self.contracts:
                #print(c)
                walletNames.append(c['walletFile'])
            for i in range(len(walletNames) + 1):
                walletFile = os.path.join(self.topDir, 'wallets',
                                          'contract' + str(i) + '.wallet')
                if walletFile not in walletNames:
                    break
        storage = WalletStorage(walletFile)
        seed_type = 'standard'
        seed = Mnemonic('en').make_seed(seed_type)
        k = keystore.from_seed(seed, '', False)
        storage.put('keystore', k.dump())
        storage.put('wallet_type', 'standard')
        wallet = Wallet(storage)
        wallet.set_schnorr_enabled(False)
        wallet.update_password(None, '', True)
        wallet.synchronize()
        print_msg("Your wallet generation seed is:\n\"%s\"" % seed)
        print_msg(
            "Please keep it in a safe place; if you lose it, you will not be able to restore your wallet."
        )

        wallet.storage.write()
        print_msg("Wallet saved in '%s'" % wallet.storage.path)

        my_addr = wallet.get_unused_address()
        my_addr_index = wallet.receiving_addresses.index(my_addr)
        #my_addr_index is always going to be 0 if the wallet is unused, so maybe previous line unnecessary
        my_pubkey = wallet.derive_pubkeys(False, my_addr_index)
        my_x_pubkey = self.get_x_pubkey(my_addr_index, wallet)
        self.contracts.append({
            'walletFile': wallet.storage.path,
            "my_addr": my_addr.to_ui_string(),
            "my_pubkey": my_pubkey,
            "my_x_pubkey": my_x_pubkey,
            "nickname": nickname,
            "label": ""
        })
        #print(self.contracts)
        self.updateContracts()
        self.multiWallets.append(None)
        return wallet, self.contracts[-1]
Ejemplo n.º 2
0
 def __init__(self, wizard, **kwargs):
     super(RestoreSeedDialog, self).__init__(wizard, **kwargs)
     self._test = kwargs['test']
     from electroncash.mnemonic import Mnemonic
     from electroncash.old_mnemonic import words as old_wordlist
     self.words = set(Mnemonic('en').wordlist).union(set(old_wordlist))
     self.ids.text_input_seed.text = test_seed if is_test else ''
     self.message = _('Please type your seed phrase using the virtual keyboard.')
     self.title = _('Enter Seed')
     self.ext = False
Ejemplo n.º 3
0
 def derive_bip39_seed(self, seed, passphrase):
     self.bip32_seed = Mnemonic('en').mnemonic_to_seed(seed, passphrase)
Ejemplo n.º 4
0
 def create_seed(self, wizard):
     wizard.seed_type = 'standard'
     wizard.opt_bip39 = False
     seed = Mnemonic('en').make_seed(wizard.seed_type)
     f = lambda x: self.request_passphrase(wizard, seed, x)
     wizard.show_seed_dialog(run_next=f, seed_text=seed)
Ejemplo n.º 5
0
 def create_seed(self, wizard):
     seed = Mnemonic('en').make_seed()
     f = lambda x: self.request_passphrase(wizard, seed, x)
     wizard.show_seed_dialog(run_next=f, seed_text=seed)