Exemple #1
0
 def test_is_xprv(self):
     for xprv_details in self.xprv_xpub:
         xprv = xprv_details['xprv']
         self.assertTrue(is_xprv(xprv))
     self.assertFalse(is_xprv('xprv1nval1d'))
     self.assertFalse(
         is_xprv(
             'xprv661MyMwAqRbcFWohJWt7PHsFEJfZAvw9ZxwQoDa4SoMgsDDM1T7WK3u9E4edkC4ugRnZ8E4xDZRpk8Rnts3Nbt97dPwT52WRONGBADWRONG'
         ))
Exemple #2
0
 def set_enabled():
     from electrum.bip32 import is_xprv
     wizard.next_button.setEnabled(is_xprv(clean_text(text)))
Exemple #3
0
 def test_is_xprv(self):
     for xprv_details in self.xprv_xpub:
         xprv = xprv_details['xprv']
         self.assertTrue(is_xprv(xprv))
     self.assertFalse(is_xprv('xprv1nval1d'))
     self.assertFalse(is_xprv('xprv661MyMwAqRbcFWohJWt7PHsFEJfZAvw9ZxwQoDa4SoMgsDDM1T7WK3u9E4edkC4ugRnZ8E4xDZRpk8Rnts3Nbt97dPwT52WRONGBADWRONG'))
Exemple #4
0
 def set_enabled():
     from electrum.bip32 import is_xprv
     wizard.next_button.setEnabled(is_xprv(clean_text(text)))
Exemple #5
0
    entropy = ecdsa.util.randrange( pow( 2, entropy_size * 8 ) )
    entropy_in_bytes = entropy.to_bytes( entropy_size , sys.byteorder )
    xprv,xpub = bip32.bip32_root( entropy_in_bytes, key_type )
    master_key = xprv
elif args.master_key == "-":
    master_key = sys.stdin.readline().strip()

if args.convert:
    if args.gen_master:
        sys.exit( "Convert option cannot be used with generate master option" )
    else:
        convert_type = args.convert if args.convert !="p2pkh" else "standard"
        if bip32.is_xpub(master_key):
            xtype, depth, fingerprint, child_number, c, K_or_k = bip32.deserialize_xpub( master_key )
            master_key = bip32.serialize_xpub( convert_type, c,  K_or_k, depth, fingerprint, child_number )
        elif bip32.is_xprv(master_key):
            xtype, depth, fingerprint, child_number, c, K_or_k = bip32.deserialize_xprv( master_key )
            master_key = bip32.serialize_xprv( convert_type, c,  K_or_k, depth, fingerprint, child_number )
        else:
            sys.exit( "Master key is not a valid extended key" )

derivation_path = args.derivation_path if args.derivation_path != "m" else "m/"
if bip32.is_bip32_derivation( derivation_path ):
	if bip32.is_xpub(master_key):
		if args.output_xprv:
				sys.exit( "Cannot derive extended private key from extended public key\n" )
		if derivation_path == "m/":
			print( master_key )
		else:
			try:
				xpub = bip32.bip32_public_derivation( master_key, "m/", derivation_path )