tMerge branch 'master' of https://github.com/chris-belcher/electrum-personal-server - electrum-personal-server - Maximally lightweight electrum server for a single user HTML git clone https://git.parazyd.org/electrum-personal-server DIR Log DIR Files DIR Refs DIR README --- DIR commit b8aab06cf37cf2e2c0831d42c929135ce5a1f346 DIR parent cbd7953d8857566b756d0302bf423bd1b882f726 HTML Author: chris-belcher <chris-belcher@users.noreply.github.com> Date: Sun, 8 Apr 2018 16:42:43 +0100 Merge branch 'master' of https://github.com/chris-belcher/electrum-personal-server Diffstat: M bitcoin/deterministic.py | 2 +- M server.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) --- DIR diff --git a/bitcoin/deterministic.py b/bitcoin/deterministic.py t@@ -21,7 +21,7 @@ PUBLIC = [ b'\x04\x88\xb2\x1e', #mainnet p2pkh or p2sh xpub b'\x02\xaa\x7e\xd3', #mainnet p2wsh Zpub b'\x04\x35\x87\xcf', #testnet p2pkh or p2sh tpub b'\x04\x4a\x52\x62', #testnet p2wpkh-p2sh upub - b'\x02\x42\x85\xef', #testnet p2wsh-p2sh Upub + b'\x02\x42\x89\xef', #testnet p2wsh-p2sh Upub b'\x04\x5f\x1c\xf6', #testnet p2wpkh vpub b'\x02\x57\x54\x83' #testnet p2wsh Vpub ] DIR diff --git a/server.py b/server.py t@@ -166,8 +166,14 @@ def handle_query(sock, line, rpc, txmonitor): for i in range(count): header = rpc.call("getblockheader", [the_hash]) #add header hex to result + if "previousblockhash" in header: + prevblockhash = header["previousblockhash"] + else: + # this is the genesis block + # it does not have a previous block hash + prevblockhash = "00"*32 h1 = struct.pack("<i32s32sIII", header["version"], - binascii.unhexlify(header["previousblockhash"])[::-1], + binascii.unhexlify(prevblockhash)[::-1], binascii.unhexlify(header["merkleroot"])[::-1], header["time"], int(header["bits"], 16), header["nonce"]) result.extend(h1) t@@ -220,8 +226,14 @@ def handle_query(sock, line, rpc, txmonitor): def get_block_header(rpc, blockhash): rpc_head = rpc.call("getblockheader", [blockhash]) + if "previousblockhash" in rpc_head: + prevblockhash = rpc_head["previousblockhash"] + else: + # this is the genesis block + # it does not have a previous block hash + prevblockhash = "00"*32 header = {"block_height": rpc_head["height"], - "prev_block_hash": rpc_head["previousblockhash"], + "prev_block_hash": prevblockhash, "timestamp": rpc_head["time"], "merkle_root": rpc_head["merkleroot"], "version": rpc_head["version"],