txno["data"] = b2a_hex(txn.data).decode("ascii") tl.append(txno) rv["transactions"] = tl now = int(time()) rv["time"] = now # FIXME: ensure mintime is always >= real mintime, both here and in share acceptance rv["mintime"] = now - 180 rv["curtime"] = now rv["maxtime"] = now + 120 rv["bits"] = b2a_hex(bits[::-1]).decode("ascii") rv["target"] = "%064x" % (target,) t = deepcopy(merkleTree.data[0]) t.setCoinbase(cb) t.assemble() txno = {} txno["data"] = b2a_hex(t.data).decode("ascii") rv["coinbasetxn"] = txno return rv def doJSON_submitblock(self, data, params=_NoParams): data = bytes.fromhex(data) share = {"data": data[:80], "blkdata": data[80:], "username": self.Username, "remoteHost": self.remoteHost} try: self.server.receiveShare(share) except RejectedShare as rej: return str(rej) return None JSONRPCHandler._register(_getblocktemplate)
if midstate and 'midstate' not in self.extensions and 'midstate' not in self.quirks: h = midstate.SHA256(hdr)[:8] rv['midstate'] = b2a_hex(pack('<LLLLLLLL', *h)).decode('ascii') ShareTargetHex = '%064x' % (target, ) ShareTargetHexLE = b2a_hex( bytes.fromhex(ShareTargetHex)[::-1]).decode('ascii') rv['target'] = ShareTargetHexLE self._JSONHeaders['X-Roll-NTime'] = 'expire=120' return rv def doJSON_submitwork(self, datax): data = swap32(bytes.fromhex(datax))[:80] share = { 'data': data, '_origdata': datax, 'username': self.Username, 'remoteHost': self.remoteHost, } try: self.server.receiveShare(share) except RejectedShare as rej: self._JSONHeaders['X-Reject-Reason'] = str(rej) return False return True JSONRPCHandler._register(_getwork)
if midstate and 'midstate' not in self.extensions and 'midstate' not in self.quirks: h = midstate.SHA256(hdr)[:8] rv['midstate'] = b2a_hex(pack('<LLLLLLLL', *h)).decode('ascii') ShareTargetHex = '%064x' % (target,) ShareTargetHexLE = b2a_hex(bytes.fromhex(ShareTargetHex)[::-1]).decode('ascii') rv['target'] = ShareTargetHexLE self._JSONHeaders['X-Roll-NTime'] = 'expire=%d' % (self.server.StaleWorkTimeout,) return rv def doJSON_submitwork(self, datax): data = swap32(bytes.fromhex(datax))[:80] share = { 'data': data, '_origdata' : datax, 'username': self.Username, 'remoteHost': self.remoteHost, 'userAgent': self.UA, 'submitProtocol': 'getwork', } try: self.server.receiveShare(share) except RejectedShare as rej: self._JSONHeaders['X-Reject-Reason'] = str(rej) return False return True JSONRPCHandler._register(_getwork)
rv['bits'] = b2a_hex(bits[::-1]).decode('ascii') rv['target'] = '%064x' % (target, ) t = deepcopy(merkleTree.data[0]) t.setCoinbase(cb) t.assemble() rv['coinbasetxn'] = b2a_hex(t.data).decode('ascii') return rv def doJSON_submitblock(self, data, params=_NoParams): data = bytes.fromhex(data) share = { 'data': data[:80], 'blkdata': data[80:], 'username': self.Username, 'remoteHost': self.remoteHost, 'userAgent': self.UA, 'submitProtocol': 'GMP', } try: self.server.receiveShare(share) except RejectedShare as rej: if 'SBB' in self.quirks: return False return str(rej) if 'SBB' in self.quirks: return True return None JSONRPCHandler._register(_getmemorypool)
# Eloipool - Python Bitcoin pool server # Copyright (C) 2011-2012 Luke Dashjr <*****@*****.**> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from jsonrpcserver import JSONRPCHandler class _setworkaux: def doJSON_setworkaux(self, k, hexv = None): if self.Username != self.server.SecretUser: self.doAuthenticate() return None if hexv: self.server.aux[k] = bytes.fromhex(hexv) else: del self.server.aux[k] return True JSONRPCHandler._register(_setworkaux)
t.assemble() txno = {} txno['data'] = b2a_hex(t.data).decode('ascii') rv['coinbasetxn'] = txno rv['version'] = merkleTree.MP['version'] rv['rules'] = merkleTree.MP['rules'] rv['vbavailable'] = merkleTree.MP['_filtered_vbavailable'] rv['vbrequired'] = rv['version'] & 0x1fffffff return rv def doJSON_submitblock(self, data, params=_NoParams): data = bytes.fromhex(data) share = { 'data': data[:80], 'blkdata': data[80:], 'username': self.Username, 'remoteHost': self.remoteHost, 'userAgent': self.UA, 'submitProtocol': 'GBT', } try: self.server.receiveShare(share) except RejectedShare as rej: return str(rej) return None JSONRPCHandler._register(_getblocktemplate)
class _setlog: def doJSON_setlog(self, time, coinid, remotehost, username, rejectReason, solved, solution_safe, difficulty): # def doJSON_setlog(self, time, coinid, remotehost): # print("LOG HERE") if self.Username != self.server.SecretUser: self.doAuthenticate() # print("LOG NOT HERE") return None # print("LOG HERE 2") # print(solved) share = { 'username_safe': username, 'coinid': coinid, 'remoteHost': remotehost, 'time': time, 'rejectReason': rejectReason, 'upstreamResult': solved, 'solution_safe': solution_safe, 'difficulty': difficulty } for i in self.server.loggers: i.logShare(share) return True JSONRPCHandler._register(_setlog) #print("LOG REGISTERED")
# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from jsonrpcserver import JSONRPCHandler class _setworkaux: def doJSON_setworkaux(self, k, hexv=None): if self.Username != self.server.SecretUser: self.doAuthenticate() return None if hexv: self.server.aux[k] = bytes.fromhex(hexv) else: del self.server.aux[k] return True JSONRPCHandler._register(_setworkaux)