コード例 #1
0
ファイル: models.py プロジェクト: rokj/sellout
    def get_btc_address(self, company_id):
        if self.pk and self.pk is not None:
            if self.btc_transaction_reference is not None and self.btc_transaction_reference != "":
                return self.btc_transaction_reference
            else:
                bitcoin_rpc = BitcoinRPC(settings.PAYMENT['bitcoin']['host'], settings.PAYMENT['bitcoin']['port'],
                                         settings.PAYMENT['bitcoin']['rpcuser'], settings.PAYMENT['bitcoin']['rpcpassword'])
                address = bitcoin_rpc.get_new_address(settings.PAYMENT['bitcoin']['account_prefix'] + str(company_id))

                self.btc_transaction_reference = address
                self.save()

                return address

        return ""
コード例 #2
0
ファイル: test_btc_price.py プロジェクト: rokj/sellout
import os

import django
from payment.service.Bitcoin import BitcoinRPC
import settings

django.setup()

from common.functions import calculate_btc_price

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webpos.settings")

btc_price = calculate_btc_price("EUR", 0.5)

print btc_price

bitcoin_rpc = BitcoinRPC(settings.PAYMENT['bitcoin']['host'], settings.PAYMENT['bitcoin']['port'], settings.PAYMENT['bitcoin']['rpcuser'], settings.PAYMENT['bitcoin']['rpcpassword'])
address = bitcoin_rpc.get_new_address("rokj_text")


コード例 #3
0
        else:
            cursor.execute("INSERT INTO bitcoin(key, value) VALUES (%s, %s)", (bitcoin_db_key, block, ))
    except Exception as e:
        print e
        return False

    cursor.close()

    return True

# main program
while True:
    last_checked_block = get_last_checked_block()

    try:
        bitcoin_client_rpc = BitcoinRPC(settings.PAYMENT['bitcoin']['host'], settings.PAYMENT['bitcoin']['port'],
                                 settings.PAYMENT['bitcoin']['rpcuser'], settings.PAYMENT['bitcoin']['rpcpassword'])
        transactions = bitcoin_client_rpc.list_since_block(last_checked_block)

        for transaction in transactions['transactions']:
            # POS Bills, POS Bills, POS Bills
            # POS Bills, POS Bills, POS Bills
            # POS Bills, POS Bills, POS Bills
            try:
                payment  = Payment.objects.get(Q(status=WAITING) | Q(status=NOT_ENOUGH_MONEY_ARRIVED), btc_transaction_reference=transaction['address'], type="bitcoin")

                # transaction_reference is bitcoin reference in this case
                total_received_by_address = bitcoin_client_rpc.get_received_by_address(payment.btc_transaction_reference, confirmations)
                total_received_by_address = Decimal(total_received_by_address)

                # we try to get timestamp of payment
                transaction_datetime = None