示例#1
0
def make_commission_payment(unpaid_commissions, total_commission, returned_txs):
    extra_fees = 0
    for r in returned_txs:
        extra_fees += (r.fee - FEE)
    print "Absorbing %f extra fees into commission" % extra_fees
    final_commission = total_commission - FEE - extra_fees
    if final_commission > 0:
        tx_id = util.make_bitcoin_payment(COMMISSION_ADDRESS, final_commission)
        if tx_id.find(" ") == -1 and tx_id.lower().find("error") == -1:
            actual_fee_paid = get_actual_tx_fee(tx_id)
            commission_tx = {
                "amount": total_commission,
                "tx_id": tx_id,
                "fee": actual_fee_paid
                }
            commission_tx_obj = Commission_Tx(**commission_tx)
            commission_tx_obj.save()
            for commission_amount in unpaid_commissions:
                commission_tx_link = {
                    "commission_amount": commission_amount,
                    "commission_tx": commission_tx_obj
                    }
                commission_tx_link_obj = Commission_Tx_Link(**commission_tx_link)
                commission_tx_link_obj.save()
        else:
            print "ERROR SENDING COMMISSION: %s" % tx_id
示例#2
0
def make_commission_payment(unpaid_commissions, total_commission,
                            returned_txs):
    extra_fees = 0
    for r in returned_txs:
        extra_fees += (r.fee - FEE)
    print "Absorbing %f extra fees into commission" % extra_fees
    final_commission = total_commission - FEE - extra_fees
    if final_commission > 0:
        tx_id = util.make_bitcoin_payment(COMMISSION_ADDRESS, final_commission)
        if tx_id.find(" ") == -1 and tx_id.lower().find("error") == -1:
            actual_fee_paid = get_actual_tx_fee(tx_id)
            commission_tx = {
                "amount": total_commission,
                "tx_id": tx_id,
                "fee": actual_fee_paid
            }
            commission_tx_obj = Commission_Tx(**commission_tx)
            commission_tx_obj.save()
            for commission_amount in unpaid_commissions:
                commission_tx_link = {
                    "commission_amount": commission_amount,
                    "commission_tx": commission_tx_obj
                }
                commission_tx_link_obj = Commission_Tx_Link(
                    **commission_tx_link)
                commission_tx_link_obj.save()
        else:
            print "ERROR SENDING COMMISSION: %s" % tx_id
示例#3
0
def make_return_payment(address, amount_to_return, returned_amounts):
    amount_to_return -= FEE
    if amount_to_return > 0:
        tx_id = util.make_bitcoin_payment(address, amount_to_return)
        if tx_id.find(" ") == -1 and tx_id.lower().find(
                "error"
        ) == -1:  #TODO this is a poor condition, works but is poor
            actual_fee_paid = get_actual_tx_fee(tx_id)
            returned_tx = {
                "returned_amount": amount_to_return,
                "tx_id": tx_id,
                "fee": actual_fee_paid
            }
            returned_tx_obj = Returned_Tx(**returned_tx)
            returned_tx_obj.save()

            for returned_amount in returned_amounts:
                return_link = {
                    "returned_tx": returned_tx_obj,
                    "returned_amount": returned_amount
                }
                return_link_obj = Returned_Tx_To_Returned_Amount_Link(
                    **return_link)
                return_link_obj.save()
            return returned_tx_obj
        else:
            print "NOT RETURNED:", tx_id
            print "Unreturned address:", address
            print "Unreturned amount:", amount_to_return
            print
    else:
        print "Amount less than 0: %f %s" % (amount_to_return, address)
        returned_tx = {
            "returned_amount": 0,
            "tx_id": "Amount less than 0 - %f" % amount_to_return,
            "fee": 0
        }
        returned_tx_obj = Returned_Tx(**returned_tx)
        returned_tx_obj.save()
        # TODO this amount before fees is left hanging in the wallet.

        for returned_amount in returned_amounts:
            return_link = {
                "returned_tx": returned_tx_obj,
                "returned_amount": returned_amount
            }
            return_link_obj = Returned_Tx_To_Returned_Amount_Link(
                **return_link)
            return_link_obj.save()
示例#4
0
def make_return_payment(address, amount_to_return, returned_amounts):
    amount_to_return -= FEE
    if amount_to_return > 0:
        tx_id = util.make_bitcoin_payment(address, amount_to_return)
        if tx_id.find(" ") == -1 and tx_id.lower().find("error") == -1: #TODO this is a poor condition, works but is poor
            actual_fee_paid = get_actual_tx_fee(tx_id)
            returned_tx = {
                "returned_amount": amount_to_return,
                "tx_id": tx_id,
                "fee": actual_fee_paid
                }
            returned_tx_obj = Returned_Tx(**returned_tx)
            returned_tx_obj.save()
            
            for returned_amount in returned_amounts:
                return_link = {
                    "returned_tx": returned_tx_obj,
                    "returned_amount": returned_amount
                    }
                return_link_obj = Returned_Tx_To_Returned_Amount_Link(**return_link)
                return_link_obj.save()
            return returned_tx_obj
        else:
            print "NOT RETURNED:", tx_id
            print "Unreturned address:", address
            print "Unreturned amount:", amount_to_return
            print
    else:
        print "Amount less than 0: %f %s" % (amount_to_return, address)
        returned_tx = {
            "returned_amount": 0,
            "tx_id": "Amount less than 0 - %f" % amount_to_return,
            "fee": 0
            }
        returned_tx_obj = Returned_Tx(**returned_tx)
        returned_tx_obj.save()
        # TODO this amount before fees is left hanging in the wallet.

        for returned_amount in returned_amounts:
            return_link = {
                "returned_tx": returned_tx_obj,
                "returned_amount": returned_amount
                }
            return_link_obj = Returned_Tx_To_Returned_Amount_Link(**return_link)
            return_link_obj.save()