예제 #1
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)
예제 #2
0
    def _do_test_bip32(self, seed, sequence):
        xprv, xpub = bip32_root(bfh(seed), 'standard')
        self.assertEqual("m/", sequence[0:2])
        path = 'm'
        sequence = sequence[2:]
        for n in sequence.split('/'):
            child_path = path + '/' + n
            if n[-1] != "'":
                xpub2 = bip32_public_derivation(xpub, path, child_path)
            xprv, xpub = bip32_private_derivation(xprv, path, child_path)
            if n[-1] != "'":
                self.assertEqual(xpub, xpub2)
            path = child_path

        return xpub, xprv
예제 #3
0
    def create_cold_seed(self, wallet):
        from electrum.bitcoin import mnemonic_to_seed, bip32_root
        msg = _('You are about to generate the cold storage seed of your wallet.') + '\n' \
              + _('For safety, you should do this on an offline computer.')
        icon = QPixmap( ':icons/cold_seed.png').scaledToWidth(56)
        if not self.question(msg, icon):
            return

        cold_seed = wallet.make_seed()
        if not self.show_seed(cold_seed, 'cold'):
            return
        if not self.verify_seed(cold_seed, 'cold'):
            return

        hex_seed = mnemonic_to_seed(cold_seed,'').encode('hex')
        xpriv, xpub = bip32_root(hex_seed)
        wallet.add_master_public_key('cold/', xpub)

        msg = _('Your master public key was saved in your wallet file.') + '\n'\
              + _('Your cold seed must be stored on paper; it is not in the wallet file.')+ '\n\n' \
              + _('This program is about to close itself.') + '\n'\
              + _('You will need to reopen your wallet on an online computer, in order to complete the creation of your wallet')
        self.show_message(msg)
예제 #4
0
#!./venv/bin/python

from electrum import util, bitcoin

import sys

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

if len(lines) != 1:
    print("wrong input")
    sys.exit(1)

seed = util.bfh(lines[0])
xprv, _xpub = bitcoin.bip32_root(seed, "standard")
print(xprv)
예제 #5
0
                          dest="derivation_path",
                          default=default_derivation_path)
output_group.add_argument("-p",
                          "--xprv",
                          help="Generate xprv (default is xpub)",
                          action="store_true",
                          dest="output_xprv")

args = parser.parse_args()

master_key = args.master_key
if args.gen_master:
    key_type = args.gen_master if args.gen_master != "p2pkh" else "standard"
    entropy = ecdsa.util.randrange(pow(2, entropy_size * 8))
    entropy_in_bytes = entropy.to_bytes(entropy_size, sys.byteorder)
    xprv, xpub = bitcoin.bip32_root(entropy_in_bytes, key_type)
    master_key = xprv
elif args.master_key == "-":
    master_key = sys.stdin.readline().strip()

derivation_path = args.derivation_path if args.derivation_path != "m" else "m/"
if bitcoin.is_bip32_derivation(derivation_path):
    try:
        xprv, xpub = bitcoin.bip32_private_derivation(master_key, "m/",
                                                      derivation_path)
        sys.stderr.write("Derivation Path: {}\n".format(derivation_path))
        if args.output_xprv:
            print(xprv)
        else:
            print(xpub)
    except BaseException: