コード例 #1
0
ファイル: trustedcoin.py プロジェクト: waterem/electrum
 def get_xkeys(self, seed, passphrase, derivation):
     from electrum.mnemonic import Mnemonic
     from electrum.keystore import bip32_root, bip32_private_derivation
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, 'standard')
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
コード例 #2
0
ファイル: trustedcoin.py プロジェクト: zhiyuan2007/electrum
 def get_xkeys(self, seed, t, passphrase, derivation):
     assert is_any_2fa_seed_type(t)
     xtype = 'standard' if t == '2fa' else 'p2wsh'
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, xtype)
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
コード例 #3
0
ファイル: trustedcoin.py プロジェクト: romanz/electrum
 def get_xkeys(self, seed, passphrase, derivation):
     from electrum.mnemonic import Mnemonic
     from electrum.keystore import bip32_root, bip32_private_derivation
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, 'standard')
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
コード例 #4
0
ファイル: trustedcoin.py プロジェクト: oliv3eira/electrum
 def get_xkeys(self, seed, t, passphrase, derivation):
     assert is_any_2fa_seed_type(t)
     xtype = 'standard' if t == '2fa' else 'p2wsh'
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     rootnode = BIP32Node.from_rootseed(bip32_seed, xtype=xtype)
     child_node = rootnode.subkey_at_private_derivation(derivation)
     return child_node.to_xprv(), child_node.to_xpub()
コード例 #5
0
ファイル: trustedcoin.py プロジェクト: vialectrum/vialectrum
 def get_xkeys(self, seed, t, passphrase, derivation):
     assert is_any_2fa_seed_type(t)
     xtype = 'standard' if t == '2fa' else 'p2wsh'
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, xtype)
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
コード例 #6
0
ファイル: trustedcoin.py プロジェクト: faircoin/electrumfair
 def get_xkeys(self, seed, t, passphrase, derivation):
     assert is_any_2fa_seed_type(t)
     xtype = 'standard' if t == '2fa' else 'p2wsh'
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     rootnode = BIP32Node.from_rootseed(bip32_seed, xtype=xtype)
     child_node = rootnode.subkey_at_private_derivation(derivation)
     return child_node.to_xprv(), child_node.to_xpub()
コード例 #7
0
def mk_electrum(file, mnemo, isBip39=False):
    if isBip39:
        bip39 = Bip39("english")
        seed = bip39.to_seed(mnemo)
        path = ACCT84
        type = "bip39"
        mnemo = None
    else:
        seed = Bip32.mnemonic_to_seed(mnemo, None)
        type = "segwit"
        path = "0H"

    net = btcnet("", "", "", **HW84)
    key = net.keys.bip32_seed(seed)
    xprv = key.subkey_for_path(path).hwif(as_private=True)
    xpub = key.subkey_for_path(path).hwif(as_private=False)

    wallet = mk_wallet(xprv, xpub, type=type, seed=mnemo)
    with open(file, "w+") as w:
        dump(wallet, w, indent=4)
コード例 #8
0
def from_seed(seed, passphrase, is_p2sh=False):
    t = seed_type(seed)
    if t == 'old':
        keystore = Old_KeyStore({})
        keystore.add_seed(seed)
    elif t in ['standard', 'segwit']:
        keystore = BIP32_KeyStore({})
        keystore.add_seed(seed)
        keystore.passphrase = passphrase
        bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
        if t == 'standard':
            der = "m/"
            xtype = 'standard'
        else:
            der = "m/1'/" if is_p2sh else "m/0'/"
            xtype = 'p2wsh' if is_p2sh else 'p2wpkh'
        keystore.add_xprv_from_seed(bip32_seed, xtype, der)
    else:
        raise BitcoinException('Unexpected seed type {}'.format(repr(t)))
    return keystore
コード例 #9
0
ファイル: trustedcoin.py プロジェクト: phamels/electrum-nix
 def get_xkeys(self, seed, passphrase, derivation):
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, 'standard')
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
コード例 #10
0
ファイル: trustedcoin.py プロジェクト: chrisrico/electrum
 def get_xkeys(self, seed, passphrase, derivation):
     bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
     xprv, xpub = bip32_root(bip32_seed, 'standard')
     xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
     return xprv, xpub
コード例 #11
0
#!./venv/bin/python

from electrum import util
from electrum.mnemonic import Mnemonic

import sys

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")
    sys.exit(1)

words = lines[0]
print(util.bh2u(Mnemonic.mnemonic_to_seed(words, passw)))