diff --git a/conf/config_sample.py b/conf/config_sample.py index a4633cb..91f6cb6 100644 --- a/conf/config_sample.py +++ b/conf/config_sample.py @@ -20,8 +20,12 @@ COINDAEMON_TRUSTED_PASSWORD = 'somepassword' # This currently only works with POW SHA256 and Scrypt Coins # The available options are scrypt and sha256d. # If the option does not meet either of these criteria stratum defaults to scrypt +# Until AutoReward Selecting Code has been implemented the below options are used to select the type of coin +# For Reward type there is POW and POS. please ensure you choose the currect type. +# For SHA256 PoS Coins which support TX Messages please enter yes in the TX selection COINDAEMON_ALGO = 'scrypt' - +COINDAEMON_Reward = 'POW' +COINDAEMON_SHA256_TX = 'no' # ******************** BASIC SETTINGS *************** # Backup Coin Daemon address's (consider having at least 1 backup) # You can have up to 99 diff --git a/lib/coinbasetx.py b/lib/coinbasetx.py index e2d5743..3387260 100644 --- a/lib/coinbasetx.py +++ b/lib/coinbasetx.py @@ -42,6 +42,53 @@ if settings.COINDAEMON_Reward == 'POW': # 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) + def set_extranonce(self, extranonce): + if len(extranonce) != self.extranonce_size: + raise Exception("Incorrect extranonce size") + + (part1, part2) = self.vin[0]._scriptSig_template + self.vin[0].scriptSig = part1 + extranonce + part2 +elif settings.COINDAEMON_Reward == 'POS' and settings.COINDAEMON_SHA256_TX == 'yes': + class CoinbaseTransaction(halfnode.CTransaction): + '''Construct special transaction used for coinbase tx. + It also implements quick serialization using pre-cached + scriptSig template.''' + + extranonce_type = '>Q' + extranonce_placeholder = struct.pack(extranonce_type, int('f000000ff111111f', 16)) + extranonce_size = struct.calcsize(extranonce_type) + + def __init__(self, timestamper, coinbaser, value, flags, height, data, ntime): + super(CoinbaseTransaction, self).__init__() + + #self.extranonce = 0 + + if len(self.extranonce_placeholder) != self.extranonce_size: + raise Exception("Extranonce placeholder don't match expected length!") + + tx_in = halfnode.CTxIn() + tx_in.prevout.hash = 0L + tx_in.prevout.n = 2**32-1 + tx_in._scriptSig_template = ( + util.ser_number(height) + binascii.unhexlify(flags) + util.ser_number(int(timestamper.time())) + \ + chr(self.extranonce_size), + util.ser_string(coinbaser.get_coinbase_data() + data) + ) + + tx_in.scriptSig = tx_in._scriptSig_template[0] + self.extranonce_placeholder + tx_in._scriptSig_template[1] + + tx_out = halfnode.CTxOut() + tx_out.nValue = value + tx_out.scriptPubKey = coinbaser.get_script_pubkey() + + self.nTime = ntime + self.strTxComment = "Mined By AhmedBodi's CryptoExpert Pools" + self.vin.append(tx_in) + 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) + def set_extranonce(self, extranonce): if len(extranonce) != self.extranonce_size: raise Exception("Incorrect extranonce size") diff --git a/lib/config_default.py b/lib/config_default.py index 5f96e58..3693932 100755 --- a/lib/config_default.py +++ b/lib/config_default.py @@ -111,11 +111,17 @@ COINDAEMON_TRUSTED_PORT = 8332 # RPC port COINDAEMON_TRUSTED_USER = 'stratum' COINDAEMON_TRUSTED_PASSWORD = '***somepassword***' + # Coin Algorithm is the option used to determine the algortithm used by stratum # This currently only works with POW SHA256 and Scrypt Coins # The available options are scrypt and sha256d. -# If the option does not meet either of these criteria stratum defaults to scrypt +# If the option does not meet either of these criteria stratum defaults to scry$ +# Until AutoReward Selecting Code has been implemented the below options are us$ +# For Reward type there is POW and POS. please ensure you choose the currect ty$ +# For SHA256 PoS Coins which support TX Messages please enter yes in the TX sel$ COINDAEMON_ALGO = 'scrypt' +COINDAEMON_Reward = 'POW' +COINDAEMON_SHA256_TX = 'yes' # ******************** OTHER CORE SETTINGS ********************* # Use "echo -n '' | sha256sum | cut -f1 -d' ' " diff --git a/lib/halfnode.py b/lib/halfnode.py index b03a6f5..491b1cc 100644 --- a/lib/halfnode.py +++ b/lib/halfnode.py @@ -144,6 +144,14 @@ class CTransaction(object): self.vout = [] self.nLockTime = 0 self.sha256 = None + elif settings.COINDAEMON_Reward == 'POS' and settings.COINDAEMON_SHA256_TX == 'yes': + self.nVersion = 1 + self.nTime = 0 + self.vin = [] + self.vout = [] + self.nLockTime = 0 + self.sha256 = None + self.strTxComment = "" else: self.nVersion = 1 self.nTime = 0 @@ -158,7 +166,15 @@ class CTransaction(object): self.vout = deser_vector(f, CTxOut) self.nLockTime = struct.unpack("