Compare commits
11 Commits
1fa611a342
...
4704375a4c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4704375a4c | ||
|
|
b52c955f8c | ||
|
|
7c847c18fa | ||
|
|
069ef00443 | ||
|
|
d44ac69b3e | ||
|
|
1cc3ae55cc | ||
|
|
5bf4b712f6 | ||
|
|
35d837efd9 | ||
|
|
7b3d93ca62 | ||
|
|
880662a31c | ||
|
|
cb6c3b4f0e |
50
pywallet.py
50
pywallet.py
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
pywversion="2.1.7"
|
||||
pywversion="2.2"
|
||||
never_update=False
|
||||
|
||||
#
|
||||
@ -19,7 +19,10 @@ missing_dep = []
|
||||
try:
|
||||
from bsddb.db import *
|
||||
except:
|
||||
missing_dep.append('bsddb')
|
||||
try:
|
||||
from bsddb3.db import *
|
||||
except:
|
||||
missing_dep.append('bsddb')
|
||||
|
||||
import os, sys, time, re
|
||||
pyw_filename = os.path.basename(__file__)
|
||||
@ -76,7 +79,7 @@ private_hex_keys = []
|
||||
passphrase = ""
|
||||
global_merging_message = ["",""]
|
||||
|
||||
balance_site = 'http://jackjack.alwaysdata.net/balance/index.php?address'
|
||||
balance_site = 'https://blockchain.info/q/addressbalance/'
|
||||
aversions = {};
|
||||
for i in range(256):
|
||||
aversions[i] = "version %d" % i;
|
||||
@ -739,7 +742,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(data)[0:32]
|
||||
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).encrypt(append_PKCS7_padding(data))
|
||||
|
||||
def Decrypt(self, data):
|
||||
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
|
||||
@ -821,7 +824,7 @@ class Crypter_pure(object):
|
||||
self.chIV = [ord(i) for i in iv]
|
||||
|
||||
def Encrypt(self, data):
|
||||
mode, size, cypher = self.m.encrypt(data, self.cbc, self.chKey, self.sz, self.chIV)
|
||||
mode, size, cypher = self.m.encrypt(append_PKCS7_padding(data), self.cbc, self.chKey, self.sz, self.chIV)
|
||||
return ''.join(map(chr, cypher))
|
||||
|
||||
def Decrypt(self, data):
|
||||
@ -2105,7 +2108,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())
|
||||
@ -2243,10 +2246,10 @@ def merge_wallets(wadir, wa, wbdir, wb, wrdir, wr, passphrase_a, passphrase_b, p
|
||||
|
||||
|
||||
if len(passphrase_r)>0:
|
||||
NPP_salt=random_string(16).decode('hex')
|
||||
NPP_salt=os.urandom(8)
|
||||
NPP_rounds=int(50000+random.random()*20000)
|
||||
NPP_method=0
|
||||
NPP_MK=random_string(64).decode('hex')
|
||||
NPP_MK=os.urandom(32)
|
||||
|
||||
crypter.SetKeyFromPassphrase(passphrase_r, NPP_salt, NPP_rounds, NPP_method)
|
||||
NPP_EMK = crypter.Encrypt(NPP_MK)
|
||||
@ -2469,7 +2472,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).encode('hex')[:32]
|
||||
hexsec = ASecretToSecret(sec)[:32].encode('hex')
|
||||
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')})
|
||||
@ -2496,7 +2499,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":
|
||||
json_db['bestblock'] = d['hashes'][0][::-1].encode('hex_codec')
|
||||
print("ignored") #json_db['bestblock'] = d['hashes'][0][::-1].encode('hex_codec')
|
||||
|
||||
elif type == "ckey":
|
||||
crypted=True
|
||||
@ -2681,14 +2684,8 @@ def importprivkey(db, sec, label, reserve, keyishex, verbose=True, addrv=addrtyp
|
||||
return True
|
||||
|
||||
def balance(site, address):
|
||||
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']
|
||||
page=urllib.urlopen("%s%s" % (site, address))
|
||||
return page.read()
|
||||
|
||||
def read_jsonfile(filename):
|
||||
filin = open(filename, 'r')
|
||||
@ -4883,10 +4880,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=random_string(16).decode('hex')
|
||||
NPP_salt=os.urandom(8)
|
||||
NPP_rounds=int(50000+random.random()*20000)
|
||||
NPP_method=0
|
||||
NPP_MK=random_string(64).decode('hex')
|
||||
NPP_MK=os.urandom(32)
|
||||
crypter.SetKeyFromPassphrase(passphraseRecov, NPP_salt, NPP_rounds, NPP_method)
|
||||
NPP_EMK = crypter.Encrypt(NPP_MK)
|
||||
update_wallet(db, 'mkey', {
|
||||
@ -4983,10 +4980,6 @@ 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")
|
||||
@ -5004,6 +4997,10 @@ 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:
|
||||
@ -5044,8 +5041,3 @@ if __name__ == '__main__':
|
||||
print "Bad private key"
|
||||
|
||||
db.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user