Beispiel #1
0
 def __init__(self, tx):
     self.tx_hash = tx.hash().hex()
     inputs = []
     for txin in tx.txs_in:
         inputs.append(TransactionUtils.getTxinPublicAddressByPre(txin))
     self.tx_inputs = inputs
     outputs = []
     for txout in tx.txs_out:
         if TransactionUtils.isCFTransationOut(txout):
             txout_type = '众筹交易'
         else:
             txout_type = '普通交易'
         outputs.append([
             txout.address(), txout.coin_value, txout_type,
             TransactionUtils.getTransactionAndOutTime(txout),
             txout.usedState
         ])
     self.tx_outputs = outputs
     self.time = time.ctime(TransactionUtils.getTransactionAndOutTime(tx))
     self.total_coin = tx.total_in()
     self.fee = tx.fee()
     if TransactionUtils.isCFTransation(tx):
         self.tx_type = '众筹交易'
         self.lock_time = time.ctime(tx.cf_header.end_time)
         self.pre_hash = tx.cf_header.pre_hash.hex()
     else:
         self.tx_type = '普通交易'
     self.get_detail(tx)
Beispiel #2
0
    def __init__(self, cfs):
        self.cfs = cfs
        if len(cfs) == 0:
            return
        src_cf = cfs[0]
        des_cf = cfs[-1]
        self.cf_id = src_cf.hash().hex()
        self.target_amount = src_cf.cf_header.target_amount
        self.start_time = time.ctime(
            TransactionUtils.getTransactionAndOutTime(src_cf))
        self.pubkey = src_cf.cf_header.pubkey
        self.end_time = time.ctime(src_cf.cf_header.end_time)
        self.lack_amount = des_cf.cf_header.lack_amount
        self.progress_rate = '%.2f %%' % (
            (des_cf.cf_header.target_amount - des_cf.cf_header.lack_amount) /
            des_cf.cf_header.target_amount * 100)

        if src_cf.cf_header.cert not in ('', None):
            cert_obj = SecretKeyUtils.stringToCert(src_cf.cf_header.cert)
            self.cert = Cert(cert_obj)
        else:
            self.cert = None
        '''众筹成功,众筹失败'''
        if des_cf.cf_header.lack_amount <= 0:
            self.status = '众筹成功'
        elif src_cf.cf_header.end_time > int(time.time()):
            self.status = '正在进行'
        else:
            self.status = '众筹失败'
Beispiel #3
0
 def get_details(self):
     src_cf = self.cfs[0]
     des_cf = self.cfs[-1]
     tmpPreCF = src_cf
     promoter = []
     for cf in self.cfs[1:]:
         promoter.append([
             cf.hash().hex(),
             time.ctime(TransactionUtils.getTransactionAndOutTime(cf)),
             cf.txs_out[0].address(),
             tmpPreCF.cf_header.lack_amount - cf.cf_header.lack_amount
         ])
         tmpPreCF = cf
     self.promoter = promoter
     self.process_date = [['day1', 20], ['day2', 30]]