return [
["mining.notify", "ae6812eb4cd7735a302a8a9dd95cf71f"], # subscription details
"", # extranonce1
- 4, # extranonce2_size
+ self.wb.COINBASE_NONCE_LENGTH, # extranonce2_size
]
def rpc_authorize(self, username, password):
print >>sys.stderr, '''Couldn't link returned work's job id with its handler. This should only happen if this process was recently restarted!'''
return False
x, got_response = self.handler_map[job_id]
- coinb_nonce = pack.IntType(32).unpack(extranonce2.decode('hex'))
- new_packed_gentx = x['coinb1'] + pack.IntType(32).pack(coinb_nonce) + x['coinb2']
+ coinb_nonce = extranonce2.decode('hex')
+ assert len(coinb_nonce) == self.wb.COINBASE_NONCE_LENGTH
+ new_packed_gentx = x['coinb1'] + coinb_nonce + x['coinb2']
header = dict(
version=x['version'],
previous_block=x['previous_block'],
if header['merkle_root'] not in self.merkle_root_to_handler:
print >>sys.stderr, '''Couldn't link returned work's merkle root with its handler. This should only happen if this process was recently restarted!'''
defer.returnValue(False)
- defer.returnValue(self.merkle_root_to_handler[header['merkle_root']](header, request.getUser() if request.getUser() is not None else '', 0))
+ defer.returnValue(self.merkle_root_to_handler[header['merkle_root']](header, request.getUser() if request.getUser() is not None else '', '\0'*self.worker_bridge.COINBASE_NONCE_LENGTH))
if p2pool.DEBUG:
id = random.randrange(1000, 10000)
res = getwork.BlockAttempt(
version=x['version'],
previous_block=x['previous_block'],
- merkle_root=bitcoin_data.check_merkle_link(bitcoin_data.hash256(x['coinb1'] + pack.IntType(32).pack(0) + x['coinb2']), x['merkle_link']),
+ merkle_root=bitcoin_data.check_merkle_link(bitcoin_data.hash256(x['coinb1'] + '\0'*self.worker_bridge.COINBASE_NONCE_LENGTH + x['coinb2']), x['merkle_link']),
timestamp=x['timestamp'],
bits=x['bits'],
share_target=x['share_target'],
import p2pool, p2pool.data as p2pool_data
class WorkerBridge(worker_interface.WorkerBridge):
+ COINBASE_NONCE_LENGTH = 4
+
def __init__(self, node, my_pubkey_hash, donation_percentage, merged_urls, worker_fee):
worker_interface.WorkerBridge.__init__(self)
self.recent_shares_ts_work = []
received_header_hashes = set()
- def got_response(header, user, last_txout_nonce):
- new_packed_gentx = packed_gentx[:-4-4] + pack.IntType(32).pack(last_txout_nonce) + packed_gentx[-4:] if last_txout_nonce != 0 else packed_gentx
- new_gentx = bitcoin_data.tx_type.unpack(new_packed_gentx) if last_txout_nonce != 0 else gentx
+ def got_response(header, user, coinbase_nonce):
+ assert len(coinbase_nonce) == self.COINBASE_NONCE_LENGTH == 4
+ new_packed_gentx = packed_gentx[:-4-4] + coinbase_nonce + packed_gentx[-4:] if coinbase_nonce != '\0'*self.COINBASE_NONCE_LENGTH else packed_gentx
+ new_gentx = bitcoin_data.tx_type.unpack(new_packed_gentx) if coinbase_nonce != '\0'*self.COINBASE_NONCE_LENGTH else gentx
header_hash = bitcoin_data.hash256(bitcoin_data.block_header_type.pack(header))
pow_hash = self.node.net.PARENT.POW_FUNC(bitcoin_data.block_header_type.pack(header))
log.err(None, 'Error while processing merged mining POW:')
if pow_hash <= share_info['bits'].target and header_hash not in received_header_hashes:
- share = get_share(header, last_txout_nonce)
+ share = get_share(header, pack.IntType(32).unpack(coinbase_nonce))
print 'GOT SHARE! %s %s prev %s age %.2fs%s' % (
user,