Skip to content

Commit

Permalink
add ltc_scrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
wakiyamap committed Oct 6, 2017
1 parent df4317e commit df4efa7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions contrib/build-wine/prepare-wine.sh
Expand Up @@ -6,6 +6,7 @@ NSIS_URL=http://prdownloads.sourceforge.net/nsis/nsis-3.02.1-setup.exe?download
VC2015_URL=https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe
WINETRICKS_MASTER_URL=https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
LYRA2RE_HASH_PYTHON_URL=https://github.com/metalicjames/lyra2re-hash-python/archive/master.zip
LTC_SCRYPT_PYTHON_URL=https://github.com/wakiyamap/ltc-scrypt/archive/master.zip
PYTHON_VERSION=3.6.2

## These settings probably don't need change
Expand Down Expand Up @@ -117,3 +118,4 @@ wine dlltool -dllname $WINEPREFIX/drive_c/python$PYTHON_VERSION/vcruntime140.dll
cp libvcruntime140.a $WINEPREFIX/drive_c/MinGW/lib/

$PYTHON -m pip install $LYRA2RE_HASH_PYTHON_URL
$PYTHON -m pip install $LTC_SCRYPT_PYTHON_URL
1 change: 1 addition & 0 deletions contrib/make_packages
Expand Up @@ -15,4 +15,5 @@ pip3 install dnspython -t ./packages
pip3 install jsonrpclib-pelix -t ./packages
pip3 install PySocks -t ./packages
pip3 install https://github.com/metalicjames/lyra2re-hash-python/archive/master.zip -t ./packages
pip3 install https://github.com/wakiyamap/ltc-scrypt/archive/master.zip -t ./packages

6 changes: 4 additions & 2 deletions lib/bitcoin.py
Expand Up @@ -138,9 +138,11 @@ def aes_decrypt_with_iv(key, iv, data):
if AES:
cipher = AES.new(key, AES.MODE_CBC, iv)
data = cipher.decrypt(data)
padlen = ord(data[-1])
#padlen = ord(data[-1])
padlen = data[-1]
for i in data[-padlen:]:
if ord(i) != padlen:
#if ord(i) != padlen:
if i != padlen:
raise InvalidPassword()
return data[0:-padlen]
else:
Expand Down
14 changes: 9 additions & 5 deletions lib/blockchain.py
Expand Up @@ -32,6 +32,11 @@
except ImportError as e:
exit("Please run 'sudo pip3 install https://github.com/metalicjames/lyra2re-hash-python/archive/master.zip'")

try:
import ltc_scrypt
except ImportError as e:
exit("Please run 'sudo pip3 install https://github.com/wakiyamap/ltc-scrypt/archive/master.zip'")

MAX_TARGET = 0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

def serialize_header(res):
Expand Down Expand Up @@ -149,18 +154,17 @@ def update_size(self):

def verify_header(self, header, prev_header, bits, target):
prev_hash = hash_header(prev_header)
_powhash = rev_hex(bh2u(lyra2re2_hash.getPoWHash(bfh(serialize_header(header)))))
height = header.get('block_height')
if height < 450000 :
_powhash = rev_hex(bh2u(ltc_scrypt.getPoWHash(bfh(serialize_header(header)))))
else:
_powhash = rev_hex(bh2u(lyra2re2_hash.getPoWHash(bfh(serialize_header(header)))))
if prev_hash != header.get('prev_block_hash'):
raise BaseException("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
if bitcoin.TESTNET:
return
#if height < 450000 and height >= 140000 and height % 50000 != 0 :
#return
if bits != header.get('bits'):
raise BaseException("bits mismatch: %s vs %s" % (bits, header.get('bits')))
if height < 450000 :
return
if int('0x' + _powhash, 16) > target:
raise BaseException("insufficient proof of work: %s vs target %s" % (int('0x' + _powhash, 16), target))

Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -42,6 +42,7 @@
'requests',
'qrcode',
'lyra2re2_hash',
'ltc_scrypt',
'protobuf',
'dnspython',
'jsonrpclib-pelix',
Expand Down

0 comments on commit df4efa7

Please sign in to comment.