def claim_gas(cls, address, height, claims, db): details = cls.compute_gas(height, claims, db) if D(details['available']): tx = '0200' + cls.get_length_for_tx(details['claims']) for c in details['claims']: tx += big_or_little(c[0]) prevIndex = cls.get_length_for_tx(int(c[1]) * [0]) if len(prevIndex) < 4: prevIndex += '00' tx += prevIndex tx += '000001e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c60' tx += Fixed8(details['available']).getData() tx += cls.address_to_scripthash(address) return tx, cls.compute_txid(tx) return False, 'No Gas'
def getData(self): hex_str = hex(int(self.f*D('100000000')))[2:] if len(hex_str)%2: hex_str = '0' + hex_str return big_or_little(hex_str)
def getData(self): hex_str = hex(int(self.f * D('100000000')))[2:] if len(hex_str) % 2: hex_str = '0' + hex_str return big_or_little(hex_str)
def get_length_for_tx(ins): assert len(ins) < 65536, 'Too much items' aoLenHex = hex(len(ins))[2:] aoLenHex = '0' + aoLenHex if len(aoLenHex) % 2 else aoLenHex return big_or_little(aoLenHex)
def compute_txid(tran): '''计算txid''' return big_or_little( binascii.hexlify(bin_dbl_sha256(binascii.unhexlify(tran))))
def serialize(self, writer): # Serialize writer.writeBytes(big_or_little(self.prevHash)) writer.writeUInt16(self.prevIndex)
def serialize(self, writer): # Serialize writer.writeBytes(big_or_little(self.AssetId)) writer.writeFixed8(self.Value) writer.writeBytes(self.ScriptHash)
def getData(self): return big_or_little(hex(self.base + int(self.f / 0.00000001))[-17:-1])