Esempio n. 1
0
async def parse_sent_tx(sent_txs_table, sent_txs, pubkey, ud_value, uids):
    """
    Extract recipients’ pubkeys from outputs
    Get identities from pubkeys
    Convert time into human format
    Store "Total" and total amounts according to the number of outputs
    If not output back return:
    Assign amounts, amounts_ud, identities, and comment
    """
    pubkeys = list()
    for sent_tx in sent_txs:
        outputs = tx_amount(sent_tx, pubkey, sent_func)[1]
        for output in outputs:
            if output_available(output.condition, ne, pubkey):
                pubkeys.append(output.condition.left.pubkey)

    identities = await identities_from_pubkeys(pubkeys, uids)
    for sent_tx in sent_txs:
        tx_list = list()
        tx_list.append(convert_time(sent_tx.time, "all"))

        total_amount, outputs = tx_amount(sent_tx, pubkey, sent_func)
        if len(outputs) > 1:
            tx_list.append("Total")
            amounts = str(total_amount / 100)
            amounts_ud = str(round(total_amount / ud_value, 2))
        else:
            tx_list.append(str())
            amounts = str()
            amounts_ud = str()

        for i, output in enumerate(outputs):
            if output_available(output.condition, ne, pubkey):
                amounts += prefix(None, outputs, i) + str(
                    neg(amount_in_current_base(output)) / 100
                )
                amounts_ud += prefix(None, outputs, i) + str(
                    round(neg(amount_in_current_base(output)) / ud_value, 2)
                )
                tx_list[1] += prefix(tx_list[1], outputs, 0) + assign_idty_from_pubkey(
                    output.condition.left.pubkey, identities
                )
        tx_list.append(amounts)
        tx_list.append(amounts_ud)
        tx_list.append(sent_tx.comment)
        sent_txs_table.append(tx_list)
Esempio n. 2
0
File: tx.py Progetto: duniter/silkaj
async def get_list_input_for_transaction(pubkey, TXamount):
    listinput, amount = await money.get_sources(pubkey)

    # generate final list source
    listinputfinal = []
    totalAmountInput = 0
    intermediatetransaction = False
    for input in listinput:
        listinputfinal.append(input)
        totalAmountInput += money.amount_in_current_base(input)
        TXamount -= money.amount_in_current_base(input)
        # if more than 40 sources, it's an intermediate transaction
        if len(listinputfinal) >= SOURCES_PER_TX:
            intermediatetransaction = True
            break
        if TXamount <= 0:
            break
    if TXamount > 0 and not intermediatetransaction:
        message_exit("Error: you don't have enough money")
    return listinputfinal, totalAmountInput, intermediatetransaction
Esempio n. 3
0
 def listinput_UD(listinput, amount, pubkey, max_ud, total):
     while max_ud > 0 and total > 0:
         listinput.append(
             InputSource(
                 amount=mock_ud_value,
                 base=0,
                 source="D",
                 origin_id=pubkey,
                 index=max_ud,
             ))
         amount += amount_in_current_base(listinput[-1])
         max_ud -= 1
         total -= 1
Esempio n. 4
0
 def listinput_TX(listinput, amount, max_tx, total):
     orig_max = max_tx + 1
     while max_tx > 0 and total > 0:
         listinput.append(
             InputSource(
                 amount=(orig_max - max_tx) * 100,
                 base=0,
                 source="T",
                 origin_id=
                 "1F3059ABF35D78DFB5AFFB3DEAB4F76878B04DB6A14757BBD6B600B1C19157E7",
                 index=max_tx,
             ))
         amount += amount_in_current_base(listinput[-1])
         max_tx -= 1
         total -= 1
Esempio n. 5
0
def sent_func(output, pubkey):
    if output_available(output.condition, ne, pubkey):
        return neg(amount_in_current_base(output))
    return 0
Esempio n. 6
0
def received_func(output, pubkey):
    if output_available(output.condition, eq, pubkey):
        return amount_in_current_base(output)
    return 0