Fix header length check for 192_7 and update bubbles network upgrade branch
This commit is contained in:
parent
ab2ba94bbe
commit
d874102488
|
@ -29,7 +29,9 @@ from . import constants
|
|||
from .bitcoin import *
|
||||
|
||||
HDR_LEN = 1487
|
||||
HDR_EH_192_7_LEN = 543
|
||||
CHUNK_LEN = 100
|
||||
BUBBLES_ACTIVATION_HEIGHT = 585318
|
||||
|
||||
MAX_TARGET = 0x0007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
POW_AVERAGING_WINDOW = 17
|
||||
|
@ -65,7 +67,7 @@ def serialize_header(res):
|
|||
def deserialize_header(s, height):
|
||||
if not s:
|
||||
raise Exception('Invalid header: {}'.format(s))
|
||||
if len(s) != HDR_LEN:
|
||||
if len(s) != HDR_LEN and len(s) != HDR_EH_192_7_LEN:
|
||||
raise Exception('Invalid header length: {}'.format(len(s)))
|
||||
hex_to_int = lambda s: int('0x' + bh2u(s[::-1]), 16)
|
||||
h = {}
|
||||
|
@ -77,7 +79,10 @@ def deserialize_header(s, height):
|
|||
h['bits'] = hex_to_int(s[104:108])
|
||||
h['nonce'] = hash_encode(s[108:140])
|
||||
h['sol_size'] = hash_encode(s[140:143])
|
||||
h['solution'] = hash_encode(s[143:1487])
|
||||
if height < BUBBLES_ACTIVATION_HEIGHT:
|
||||
h['solution'] = hash_encode(s[143:HDR_LEN])
|
||||
else:
|
||||
h['solution'] = hash_encode(s[143:HDR_EH_192_7_LEN])
|
||||
h['block_height'] = height
|
||||
return h
|
||||
|
||||
|
@ -275,7 +280,7 @@ class Blockchain(util.PrintError):
|
|||
delta = header.get('block_height') - self.checkpoint
|
||||
data = bfh(serialize_header(header))
|
||||
assert delta == self.size()
|
||||
assert len(data) == HDR_LEN
|
||||
assert len(data) == HDR_LEN or len(data) == HDR_EH_192_7_LEN
|
||||
self.write(data, delta*HDR_LEN)
|
||||
self.swap_with_parent()
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import socks
|
|||
from . import util
|
||||
from . import bitcoin
|
||||
from .bitcoin import *
|
||||
from .blockchain import HDR_LEN, CHUNK_LEN
|
||||
from .blockchain import HDR_LEN, HDR_EH_192_7_LEN, CHUNK_LEN
|
||||
from . import constants
|
||||
from .interface import Connection, Interface
|
||||
from . import blockchain
|
||||
|
@ -831,7 +831,7 @@ class Network(util.DaemonThread):
|
|||
self.connection_down(interface.server)
|
||||
return
|
||||
|
||||
if len(hex_header) != HDR_LEN*2:
|
||||
if len(hex_header) != HDR_LEN*2 and len(hex_header) != HDR_EH_192_7_LEN:
|
||||
interface.print_error('wrong header length', interface.request)
|
||||
self.connection_down(interface.server)
|
||||
return
|
||||
|
@ -1013,7 +1013,7 @@ class Network(util.DaemonThread):
|
|||
if not height or not hex_header:
|
||||
return
|
||||
|
||||
if len(hex_header) != HDR_LEN*2:
|
||||
if len(hex_header) != HDR_LEN*2 and len(hex_header) != HDR_EH_192_7_LEN*2:
|
||||
interface.print_error('wrong header length', interface.request)
|
||||
self.connection_down(interface.server)
|
||||
return
|
||||
|
|
|
@ -46,6 +46,7 @@ OVERWINTERED_VERSION_GROUP_ID = 0x03C48270
|
|||
OVERWINTER_BRANCH_ID = 0x5BA81B19
|
||||
SAPLING_VERSION_GROUP_ID = 0x892F2085
|
||||
SAPLING_BRANCH_ID = 0x76B809BB
|
||||
BUBBLES_BRANCH_ID = 0x821A451C
|
||||
|
||||
|
||||
class TransactionVersionError(Exception):
|
||||
|
@ -993,7 +994,7 @@ class Transaction:
|
|||
# add signature
|
||||
if self.overwintered:
|
||||
data = bfh(self.serialize_preimage(i))
|
||||
person = b'ZcashSigHash' + SAPLING_BRANCH_ID.to_bytes(4, 'little')
|
||||
person = b'ZcashSigHash' + BUBBLES_BRANCH_ID.to_bytes(4, 'little')
|
||||
pre_hash = blake2b(data, digest_size=32, person=person).digest()
|
||||
else:
|
||||
pre_hash = Hash(bfh(self.serialize_preimage(i)))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ELECTRUM_VERSION = 'v3.2.1a' # version of the client package
|
||||
ELECTRUM_VERSION = 'v3.2.2' # version of the client package
|
||||
PROTOCOL_VERSION = '1.2' # protocol version requested
|
||||
|
||||
# The hash of the mnemonic seed must begin with this
|
||||
|
|
Loading…
Reference in New Issue