Compare commits

..

No commits in common. "4704375a4ca035b30304b0df4186e5aa383db876" and "1fa611a342de3585213f725e465d6acef8b935a7" have entirely different histories.

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-
pywversion="2.2"
pywversion="2.1.7"
never_update=False
#
@ -19,10 +19,7 @@ missing_dep = []
try:
from bsddb.db import *
except:
try:
from bsddb3.db import *
except:
missing_dep.append('bsddb')
missing_dep.append('bsddb')
import os, sys, time, re
pyw_filename = os.path.basename(__file__)
@ -79,7 +76,7 @@ private_hex_keys = []
passphrase = ""
global_merging_message = ["",""]
balance_site = 'https://blockchain.info/q/addressbalance/'
balance_site = 'http://jackjack.alwaysdata.net/balance/index.php?address'
aversions = {};
for i in range(256):
aversions[i] = "version %d" % i;
@ -742,7 +739,7 @@ class Crypter_pycrypto( object ):
self.chIV = iv[0:16]
def Encrypt(self, data):
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).encrypt(append_PKCS7_padding(data))
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).encrypt(data)[0:32]
def Decrypt(self, data):
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
@ -824,7 +821,7 @@ class Crypter_pure(object):
self.chIV = [ord(i) for i in iv]
def Encrypt(self, data):
mode, size, cypher = self.m.encrypt(append_PKCS7_padding(data), self.cbc, self.chKey, self.sz, self.chIV)
mode, size, cypher = self.m.encrypt(data, self.cbc, self.chKey, self.sz, self.chIV)
return ''.join(map(chr, cypher))
def Decrypt(self, data):
@ -2108,7 +2105,7 @@ def parse_wallet(db, item_callback):
d['comment'] = vds.read_string()
elif type == "bestblock":
d['nVersion'] = vds.read_int32()
#d.update(parse_BlockLocator(vds))
d.update(parse_BlockLocator(vds))
elif type == "ckey":
d['public_key'] = kds.read_bytes(kds.read_compact_size())
d['encrypted_private_key'] = vds.read_bytes(vds.read_compact_size())
@ -2246,10 +2243,10 @@ def merge_wallets(wadir, wa, wbdir, wb, wrdir, wr, passphrase_a, passphrase_b, p
if len(passphrase_r)>0:
NPP_salt=os.urandom(8)
NPP_salt=random_string(16).decode('hex')
NPP_rounds=int(50000+random.random()*20000)
NPP_method=0
NPP_MK=os.urandom(32)
NPP_MK=random_string(64).decode('hex')
crypter.SetKeyFromPassphrase(passphrase_r, NPP_salt, NPP_rounds, NPP_method)
NPP_EMK = crypter.Encrypt(NPP_MK)
@ -2472,7 +2469,7 @@ def read_wallet(json_db, db_env, walletfile, print_wallet, print_wallet_transact
addr = public_key_to_bc_address(d['public_key'])
compressed = d['public_key'][0] != '\04'
sec = SecretToASecret(PrivKeyToSecret(d['private_key']), compressed)
hexsec = ASecretToSecret(sec)[:32].encode('hex')
hexsec = ASecretToSecret(sec).encode('hex')[:32]
private_keys.append(sec)
addr_to_keys[addr]=[hexsec, d['public_key'].encode('hex')]
json_db['keys'].append({'addr' : addr, 'sec' : sec, 'hexsec' : hexsec, 'secret' : hexsec, 'pubkey':d['public_key'].encode('hex'), 'compressed':compressed, 'private':d['private_key'].encode('hex')})
@ -2499,7 +2496,7 @@ def read_wallet(json_db, db_env, walletfile, print_wallet, print_wallet_transact
json_db['acentry'] = (d['account'], d['nCreditDebit'], d['otherAccount'], time.ctime(d['nTime']), d['n'], d['comment'])
elif type == "bestblock":
print("ignored") #json_db['bestblock'] = d['hashes'][0][::-1].encode('hex_codec')
json_db['bestblock'] = d['hashes'][0][::-1].encode('hex_codec')
elif type == "ckey":
crypted=True
@ -2684,8 +2681,14 @@ def importprivkey(db, sec, label, reserve, keyishex, verbose=True, addrv=addrtyp
return True
def balance(site, address):
page=urllib.urlopen("%s%s" % (site, address))
return page.read()
page=urllib.urlopen("%s=%s" % (site, address))
json_acc = json.loads(page.read().split("<end>")[0])
if json_acc['0'] == 0:
return "Invalid address"
elif json_acc['0'] == 2:
return "Never used"
else:
return json_acc['balance']
def read_jsonfile(filename):
filin = open(filename, 'r')
@ -4880,10 +4883,10 @@ if __name__ == '__main__':
if passphraseRecov!="I don't want to put a password on the recovered wallet and I know what can be the consequences.":
db = open_wallet(db_env, recov_wallet_name, True)
NPP_salt=os.urandom(8)
NPP_salt=random_string(16).decode('hex')
NPP_rounds=int(50000+random.random()*20000)
NPP_method=0
NPP_MK=os.urandom(32)
NPP_MK=random_string(64).decode('hex')
crypter.SetKeyFromPassphrase(passphraseRecov, NPP_salt, NPP_rounds, NPP_method)
NPP_EMK = crypter.Encrypt(NPP_MK)
update_wallet(db, 'mkey', {
@ -4980,6 +4983,10 @@ if __name__ == '__main__':
parser.print_help()
exit(0)
if options.testnet:
db_dir += "/testnet"
addrtype = 111
if options.namecoin or options.otherversion is not None:
if options.datadir is None and options.keyinfo is None:
print("You must provide your wallet directory")
@ -4997,10 +5004,6 @@ if __name__ == '__main__':
db_dir = determine_db_dir()
if options.testnet:
db_dir += "/testnet3"
addrtype = 111
db_env = create_env(db_dir)
if options.multidelete is not None:
@ -5041,3 +5044,8 @@ if __name__ == '__main__':
print "Bad private key"
db.close()