moopless / stratum-mining-litecoin

This fork is no longer maintained. Please use https://github.com/ahmedbodi/stratum-mining
Other
38 stars 35 forks source link

strTxComment #61

Open kczuse opened 10 years ago

kczuse commented 10 years ago

About FLO, CMC, NEC, etc. 500 error, view their source code and found that they added a parameter (strTxComment), how to deal with this? https://github.com/pascalguru/florincoin/blob/master/src/main.h#L420 https://github.com/cosmoscoin/cosmoscoin/blob/master/src/main.h#L458

kczuse commented 10 years ago

I try to modify halfnode.py, but still wrong, please help me

class CTransaction(object):
def __init__(self):
    self.nVersion = 1
    self.vin = []
    self.vout = []
    self.nLockTime = 0
    self.strTxComment = "botpool"
    self.sha256 = None
def deserialize(self, f):
    self.nVersion = struct.unpack("<i", f.read(4))[0]
    self.vin = deser_vector(f, CTxIn)
    self.vout = deser_vector(f, CTxOut)
    self.nLockTime = struct.unpack("<I", f.read(4))[0]
    self.strTxComment = deser_string(f.read(8))[0]
    self.sha256 = None
def serialize(self):
    r = ""
    r += struct.pack("<i", self.nVersion)
    r += ser_vector(self.vin)
    r += ser_vector(self.vout)
    r += struct.pack("<I", self.nLockTime)
    r += ser_string(self.strTxComment)
    log.info("serialize OK: %s" % self.strTxComment)
    return r

def calc_sha256(self):
    if self.sha256 is None:
        self.sha256 = uint256_from_str(SHA256.new(SHA256.new(self.serialize()).digest()).digest())
    return self.sha256

def is_valid(self):
    self.calc_sha256()
    for tout in self.vout:
        if tout.nValue < 0 or tout.nValue > 21000000L * 100000000L:
            return False
    return True
def __repr__(self):
    return "CTransaction(nVersion=%i vin=%s vout=%s nLockTime=%i strTxComment=%s)" % (self.nVersion, repr(self.vin), repr(self.vout), self.nLockTime, self.strTxComment)
ahmedbodi commented 10 years ago

added support in https://github.com/ahmedbodi/stratum-mining