diff --git a/lib/block_template.py b/lib/block_template.py index 4e00675..9a55f50 100644 --- a/lib/block_template.py +++ b/lib/block_template.py @@ -5,6 +5,8 @@ import struct import util import merkletree import halfnode +from coinbasetx import CoinbaseTransactionPOW +from coinbasetx import CoinbaseTransactionPOS from coinbasetx import CoinbaseTransaction import lib.logger log = lib.logger.get_logger('block_template') @@ -55,10 +57,10 @@ class BlockTemplate(halfnode.CBlock): txhashes = [None] + [ util.ser_uint256(int(t['hash'], 16)) for t in data['transactions'] ] mt = merkletree.MerkleTree(txhashes) if settings.COINDAEMON_Reward == 'POW': - coinbase = self.coinbase_transaction_class(self.timestamper, self.coinbaser, data['coinbasevalue'], data['coinbaseaux']['flags'], data['height'], + coinbase = CoinbaseTransactionPOW(self.timestamper, self.coinbaser, data['coinbasevalue'], data['coinbaseaux']['flags'], data['height'], settings.COINBASE_EXTRAS) else: - coinbase = self.coinbase_transaction_class(self.timestamper, self.coinbaser, data['coinbasevalue'], data['coinbaseaux']['flags'], data['height'], + coinbase = CoinbaseTransactionPOS(self.timestamper, self.coinbaser, data['coinbasevalue'], data['coinbaseaux']['flags'], data['height'], settings.COINBASE_EXTRAS, data['curtime']) self.height = data['height'] diff --git a/lib/coinbasetx.py b/lib/coinbasetx.py index 4f3c187..04cee23 100644 --- a/lib/coinbasetx.py +++ b/lib/coinbasetx.py @@ -6,8 +6,8 @@ import settings import lib.logger log = lib.logger.get_logger('coinbasetx') -if settings.COINDAEMON_Reward == 'POW': - class CoinbaseTransaction(halfnode.CTransaction): +#if settings.COINDAEMON_Reward == 'POW': + class CoinbaseTransactionPOW(halfnode.CTransaction): '''Construct special transaction used for coinbase tx. It also implements quick serialization using pre-cached scriptSig template.''' @@ -17,7 +17,7 @@ if settings.COINDAEMON_Reward == 'POW': extranonce_size = struct.calcsize(extranonce_type) def __init__(self, timestamper, coinbaser, value, flags, height, data): - super(CoinbaseTransaction, self).__init__() + super(CoinbaseTransactionPOW, self).__init__() log.debug("Got to CoinBaseTX") #self.extranonce = 0 @@ -45,7 +45,7 @@ if settings.COINDAEMON_Reward == 'POW': self.vout.append(tx_out) # Two parts of serialized coinbase, just put part1 + extranonce + part2 to have final serialized tx - self._serialized = super(CoinbaseTransaction, self).serialize().split(self.extranonce_placeholder) + self._serialized = super(CoinbaseTransactionPOW, self).serialize().split(self.extranonce_placeholder) def set_extranonce(self, extranonce): if len(extranonce) != self.extranonce_size: @@ -53,8 +53,8 @@ if settings.COINDAEMON_Reward == 'POW': (part1, part2) = self.vin[0]._scriptSig_template self.vin[0].scriptSig = part1 + extranonce + part2 -elif settings.COINDAEMON_Reward == 'POS': - class CoinbaseTransaction(halfnode.CTransaction): +#elif settings.COINDAEMON_Reward == 'POS': + class CoinbaseTransactionPOS(halfnode.CTransaction): '''Construct special transaction used for coinbase tx. It also implements quick serialization using pre-cached scriptSig template.''' @@ -64,7 +64,7 @@ elif settings.COINDAEMON_Reward == 'POS': extranonce_size = struct.calcsize(extranonce_type) def __init__(self, timestamper, coinbaser, value, flags, height, data, ntime): - super(CoinbaseTransaction, self).__init__() + super(CoinbaseTransactionPOS, self).__init__() log.debug("Got to CoinBaseTX") #self.extranonce = 0 @@ -93,7 +93,7 @@ elif settings.COINDAEMON_Reward == 'POS': self.vout.append(tx_out) # Two parts of serialized coinbase, just put part1 + extranonce + part2 to have final serialized tx - self._serialized = super(CoinbaseTransaction, self).serialize().split(self.extranonce_placeholder) + self._serialized = super(CoinbaseTransactionPOS, self).serialize().split(self.extranonce_placeholder) def set_extranonce(self, extranonce): if len(extranonce) != self.extranonce_size: @@ -101,7 +101,7 @@ elif settings.COINDAEMON_Reward == 'POS': (part1, part2) = self.vin[0]._scriptSig_template self.vin[0].scriptSig = part1 + extranonce + part2 -else: +#else: class CoinbaseTransaction(halfnode.CTransaction): '''Construct special transaction used for coinbase tx. It also implements quick serialization using pre-cached diff --git a/lib/halfnode.py b/lib/halfnode.py index 2642be1..9975e34 100644 --- a/lib/halfnode.py +++ b/lib/halfnode.py @@ -21,27 +21,27 @@ log = lib.logger.get_logger('halfnode') log.debug("Got to Halfnode") if settings.COINDAEMON_ALGO == 'scrypt': - log.debug("########################################### Loading LTC Scrypt #########################################################") - import ltc_scrypt + log.debug("########################################### Loading LTC Scrypt #########################################################") + import ltc_scrypt elif settings.COINDAEMON_ALGO == 'quark': - log.debug("########################################### Loading Quark Support #########################################################") - import quark_hash + log.debug("########################################### Loading Quark Support #########################################################") + import quark_hash else: - log.debug("########################################### Loading SHA256 Support ######################################################") + log.debug("########################################### Loading SHA256 Support ######################################################") -if settings.COINDAEMON_Reward == 'POS': - log.debug("########################################### Loading POS Support #########################################################") - pass -else: - log.debug("########################################### Loading POW Support ######################################################") - pass +#if settings.COINDAEMON_Reward == 'POS': +# log.debug("########################################### Loading POS Support #########################################################") +# pass +#else: +# log.debug("########################################### Loading POW Support ######################################################") +# pass if settings.COINDAEMON_TX == 'yes': - log.debug("########################################### Loading SHA256 Transaction Message Support #########################################################") - pass + log.debug("########################################### Loading SHA256 Transaction Message Support #########################################################") + pass else: - log.debug("########################################### NOT Loading SHA256 Transaction Message Support ######################################################") - pass + log.debug("########################################### NOT Loading SHA256 Transaction Message Support ######################################################") + pass MY_VERSION = 31402 diff --git a/mining/__init__.py b/mining/__init__.py index 110af1b..7a9da20 100644 --- a/mining/__init__.py +++ b/mining/__init__.py @@ -46,15 +46,15 @@ def setup(on_startup): if result['version'] >= 1: result = (yield bitcoin_rpc.getinfo()) if isinstance(result,dict): - if 'stake' in result and settings.COINDAEMON_Reward == 'POS': - log.info("CoinD looks to be a POS Coin, Config for POS looks correct") + if 'stake' in result: # and settings.COINDAEMON_Reward == 'POS': + settings.COINDAEMON_Reward = 'POS' break - elif 'stake' not in result and settings.COINDAEMON_Reward == 'POW': - log.info("CoinD looks to be a POW Coin, Config looks to be correct") + elif 'stake' not in result: # and settings.COINDAEMON_Reward == 'POW': + settings.COINDAEMON_Reward = 'POW' break - else: - log.error("Wrong Algo Selected, Switch to appropriate POS/POW in config.py!") - reactor.stop() +# else: +# log.error("Wrong Algo Selected, Switch to appropriate POS/POW in config.py!") +# reactor.stop() else: log.error("Block Version mismatch: %s" % result['version'])