def bitcoin_active_receive_confirmation():
    payments = _filter_payments_pending_active_receive_confirmation()
    for payment in payments:
        valid, verr = _validate_payment_for_active_receive_confirmation(payment)
        if valid:
            address = payment.bitcoin_receive_address.address
            amount_received = bitcoin_adapter.get_received_by_address(address)
            if amount_received > 0:
                payment.confirm_bitcoin_trn(amount_received)
                _log_info_active_receive_confirmation(address, amount_received, payment)
        else:
            logger.error('invalid payment for active receive confirmation: %s / %s' % (payment.id, verr))
def bitcoin_active_receive_confirmation():
    payments = _filter_payments_pending_active_confirmation()
    for payment in payments:
        valid, verr = _validate_payment_for_active_receive_confirmation(payment)
        if valid:
            address = payment.bitcoin_receive_address.address
            amount_received = bitcoin_adapter.get_received_by_address(address)
            if amount_received > 0:
                payment.confirm_bitcoin_trn(amount_received)
                if payment.status == Payment.CONFIRMED_TRN:
                    logger.info('Actively Confirmed bitcoin full receive: %s/%s, addr: %s, payment_id: %s' %
                                (amount_received,
                                payment.total,
                                address,
                                payment.id))
                else:
                    logger.info('Actively Confirmed bitcoin underpay: %s/%s, addr: %s, payment_id: %s' %
                                (amount_received,
                                 payment.total,
                                 address,
                                 payment.id))
        else:
            logger.error('invalid payment for active receive confirmation: %s / %s' % (payment.id, verr))