def POST(self):
        data = json.loads(web.data())
        self.require(data, 'txhash', "Merkle requires txhash")
        self.require(data, 'blockhash', "Merkle requires blockhash")
        txhash = data.get('txhash')
        blockhash = data.get('blockhash')

        hash_decode = lambda x: x.decode('hex')[::-1]
        hash_encode = lambda x: x[::-1].encode('hex')
        Hash = lambda x: hashlib.sha256(hashlib.sha256(x).digest()).digest()

        blockchainstate = BlockchainState.from_url(None, testnet)
        b = blockchainstate.get_block(blockhash)
        tx_list = b.get('tx')
        tx_pos = tx_list.index(txhash)

        merkle = map(hash_decode, tx_list)
        target_hash = hash_decode(txhash)
        s = []
        while len(merkle) != 1:
            if 2 % len(merkle):
                merkle.append(merkle[-1])
            n = []
            while merkle:
                new_hash = Hash(merkle[0] + merkle[1])
                if merkle[0] == target_hash:
                    s.append(hash_encode(merkle[1]))
                    target_hash = new_hash
                elif merkle[1] == target_hash:
                    s.append(hash_encode(merkle[0]))
                    target_hash = new_hash
                n.append(new_hash)
                merkle = merkle[2:]
            merkle = n

        return json.dumps({"block_height": b.get('height'), "merkle": s, "pos": tx_pos})
dataset/ETHPy150Open chromaway/ngcccbase/chromanode.py/Merkle.POST/swapped operands of `%`