Beispiel #1
0
def main():
    parser = OptionParser()
    parser.add_option("--testnet", help="generate testnet addresses", dest="testnet", action="store_true", default=False)
    parser.add_option("--wif", help="specify a WIF address on the command line instead of generating it", dest="wif", action="store_true", default=False)
    (options, args) = parser.parse_args()
    if options.testnet:
        pywallet.addrtype = 111
    if options.wif:
        sec_mini = None
        sec_raw = pywallet.DecodeBase58Check(args[0])[1:]
    elif args:
        sec_mini = args[0]
        if not valid_mini(sec_mini):
            print >>sys.stderr, "not a valid mini key"
            sys.exit(1)
        sec_raw = SHA256.new(sec_mini).digest()
    else:
        sec_mini = generate_mini_private_key()
        sec_raw = SHA256.new(sec_mini).digest()
    sec_hex = sec_raw.encode('hex').upper()
    sec_wallet = pywallet.EncodeBase58Check("\x80" + sec_raw)   # wallet import format
    pkey = pywallet.regenerate_key(pywallet.SecretToASecret(sec_raw))
    assert sec_raw == pywallet.GetSecret(pkey)
    priv_key = pywallet.GetPrivKey(pkey)
    pub_key = pywallet.GetPubKey(pkey)
    pub_addr = pywallet.public_key_to_bc_address(pub_key)
    print "Address:        %s" % (pub_addr,)
    print "Privkey:        %s" % (sec_wallet,)
    print "Privkey (hex):  %s" % (sec_hex,)
    print "Privkey (mini): %s" % (sec_mini,)
Beispiel #2
0
def get_keys(sec):
  '''
  returns: address, private key, hex private key
  '''
  from pywallet import EC_KEY, str_to_long, GetSecret, GetPubKey, SecretToASecret
  pkey = EC_KEY(str_to_long(sec.decode('hex')))
  secret = GetSecret(pkey)
  public_key = GetPubKey(pkey)
  addr = pywallet.public_key_to_bc_address(public_key)
  return addr, SecretToASecret(secret), secret.encode('hex')
Beispiel #3
0
def get_keys(sec):
    '''
  returns: address, private key, hex private key
  '''
    from pywallet import EC_KEY, str_to_long, GetSecret, GetPubKey, SecretToASecret
    pkey = EC_KEY(str_to_long(sec.decode('hex')))
    secret = GetSecret(pkey)
    public_key = GetPubKey(pkey)
    addr = pywallet.public_key_to_bc_address(public_key)
    return addr, SecretToASecret(secret), secret.encode('hex')