Example #1
0
def main():
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('--check', action='store_true', default=False)
    args = arg_parser.parse_args()

    lines = [x.strip() for x in sys.stdin.readlines()]

    words = ""
    passw = ""
    if len(lines) == 2:
        passw = lines[1]
    if not (len(lines) in [1, 2]):
        print("wrong input", file=sys.stderr)
        sys.exit(1)

    words = lines[0]

    if (args.check):
        (checksum_ok, wordlist_ok) = keystore.bip39_is_checksum_valid(words)
        if not wordlist_ok:
            print("Unkown words!", file=sys.stderr)
            sys.exit(1)
        if not checksum_ok:
            print("Checksum NOT OK!", file=sys.stderr)
            sys.exit(1)

    print(util.bh2u(keystore.bip39_to_seed(words, passw)))
Example #2
0
def checkPassphrase(line):
    passw = ""

    seed = util.bh2u(keystore.bip39_to_seed(line, passw))
    seed = util.bfh(seed)
    xprv, _xpub = bitcoin.bip32_root(seed, "standard")
    xprv, _xpub = bitcoin.bip32_private_derivation(xprv, "", "49'")
    xprv, _xpub = bitcoin.bip32_private_derivation(xprv, "", "0'")
    xprv, _xpub = bitcoin.bip32_private_derivation(xprv, "", "0'")
    xprv, _xpub = bitcoin.bip32_private_derivation(xprv, "", "0")
    for i in range(MAX_ADDR_IDX):
        deriveAddresses(line, xprv, i)
Example #3
0
    def create_storage(self, js_data, single_password_enabled,
                       single_password):
        self._logger.info('Creating wallet from wizard data')
        data = js_data.toVariant()
        self._logger.debug(str(data))

        if single_password_enabled and single_password:
            data['encrypt'] = True
            data['password'] = single_password

        try:
            path = os.path.join(
                os.path.dirname(self.daemon.config.get_wallet_path()),
                data['wallet_name'])
            if os.path.exists(path):
                raise Exception('file already exists at path')
            storage = WalletStorage(path)

            if data['seed_type'] in ['old', 'standard',
                                     'segwit']:  #2fa, 2fa-segwit
                self._logger.debug('creating keystore from electrum seed')
                k = keystore.from_seed(data['seed'], data['seed_extra_words'],
                                       data['wallet_type'] == 'multisig')
            elif data['seed_type'] == 'bip39':
                self._logger.debug('creating keystore from bip39 seed')
                root_seed = keystore.bip39_to_seed(data['seed'],
                                                   data['seed_extra_words'])
                derivation = normalize_bip32_derivation(
                    data['derivation_path'])
                script = data['script_type'] if data[
                    'script_type'] != 'p2pkh' else 'standard'
                k = keystore.from_bip43_rootseed(root_seed,
                                                 derivation,
                                                 xtype=script)
            else:
                raise Exception('unsupported/unknown seed_type %s' %
                                data['seed_type'])

            if data['encrypt']:
                if k.may_have_password():
                    k.update_password(None, data['password'])
                storage.set_password(
                    data['password'],
                    enc_version=StorageEncryptionVersion.USER_PASSWORD)

            db = WalletDB('', manual_upgrades=False)
            db.set_keystore_encryption(
                bool(data['password']) and data['encrypt'])

            db.put('wallet_type', data['wallet_type'])
            db.put('seed_type', data['seed_type'])
            db.put('keystore', k.dump())
            if k.can_have_deterministic_lightning_xprv():
                db.put(
                    'lightning_xprv',
                    k.get_lightning_xprv(
                        data['password'] if data['encrypt'] else None))

            db.load_plugins()
            db.write(storage)

            # minimally populate self after create
            self._password = data['password']
            self.path = path

            self.createSuccess.emit()
        except Exception as e:
            self._logger.error(str(e))
            self.createError.emit(str(e))
 def get_account_xpub(account_path):
     root_seed = bip39_to_seed(mnemonic, passphrase)
     root_node = BIP32Node.from_rootseed(root_seed, xtype="standard")
     account_node = root_node.subkey_at_private_derivation(account_path)
     account_xpub = account_node.to_xpub()
     return account_xpub
Example #5
0
import argparse
import sys

arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--no-check', action='store_true', default=False)
args = arg_parser.parse_args()

lines = [x.strip() for x in sys.stdin.readlines()]

words = ""
passw = ""
if len(lines) == 2:
    passw = lines[1]
if not (len(lines) in [1, 2]):
    print("wrong input", file=sys.stderr)
    sys.exit(1)

words = lines[0]

if not args.no_check:
    (checksum_ok, wordlist_ok) = keystore.bip39_is_checksum_valid(words)
    if not wordlist_ok:
        print("Unknown words!", file=sys.stderr)
        sys.exit(1)
    if not checksum_ok:
        print("Checksum NOT OK!", file=sys.stderr)
        sys.exit(1)

print(keystore.bip39_to_seed(words, passw).hex())