Example #1
0
# Sending Bitcoins

if answer == "7":
    client = Client('Your API KEY', 'Your Secret Key')
    tx = client.send_money('2bbf394c-193b-5b2a-9155-3b4732659ede',
                           to='1AUJ8z5RuHRTqD1eikyfUUetzGmdWLGkpT',
                           amount='0.1',
                           currency='BTC',
                           idem='9316dd16-0c05')

# Pushing Transactions to Email

if answer == "8":
    HexTransaction = input("Insert your raw transaction: ")
    #example: 0100000001fd468e431cf5797b108e4d22724e1e055b3ecec59af4ef17b063afd36d3c5cf6010000008c4930460221009918eee8be186035be8ca573b7a4ef7bc672c59430785e5390cc375329a2099702210085b86387e3e15d68c847a1bdf786ed0fdbc87ab3b7c224f3c5490ac19ff4e756014104fe2cfcf0733e559cbf28d7b1489a673c0d7d6de8470d7ff3b272e7221afb051b777b5f879dd6a8908f459f950650319f0e83a5cf1d7c1dfadf6458f09a84ba80ffffffff01185d2033000000001976a9144be9a6a5f6fb75765145d9c54f1a4929e407d2ec88ac00000000
    pushtx.pushtx(HexTransaction)

#Sending  info to Email

if answer == "9":
    print("Please enter your Email Address: ")
    EmailAddres = input()
    subject = "Your Bitcoins Info"
    content = "Below Are you Bitcoin Details \n\n" + "Private Key " + PrivateVar + "\n\n" + "Public Key: " + PublicVar + "\n\n" + "Wallet Address " + WalletAddress + "\n\n"
    mail = smtplib.SMTP("smtp.gmail.com", 587)
    mail.ehlo()
    mail.starttls()
    mail.login("Enter Your Email", "Enter Your Password")
    mail.sendmail("Enter Email", EmailAddres, content)
    print("Email send Succesfully ")
    mail.close()
Example #2
0
# This will show the balance of a given address
addr = wallet.get_address('1NAF7GbdyRg3miHNrw2bGxrd63tfMEmJob')
print(addr.balance)


# To pull up and explore a transaction; This uses an example transaction
tx = blockexplorer.get_tx('d4af240386cdacab4ca666d178afc88280b620ae308ae8d2585e9ab8fc664a94')


# Blockchain posts must be hexlified first. Here is a function to change a string to hex...
data = binascii.hexlify('here is where you would put the transaction data to be hexlified.')


# Now, to push (or "broadcast") the above data to the blockchain, do the following...
pushtx.pushtx(data)


# Here is another example which uses a valid hex string as an example...

hex_encoded_string = '0100000001fd468e431cf5797b108e4d22724e1e055b3ecec59af4ef17b063afd36d3c5cf6010000008c4930460221009918eee8be186035be8ca573b7a4ef7bc672c59430785e5390cc375329a2099702210085b86387e3e15d68c847a1bdf786ed0fdbc87ab3b7c224f3c5490ac19ff4e756014104fe2cfcf0733e559cbf28d7b1489a673c0d7d6de8470d7ff3b272e7221afb051b777b5f879dd6a8908f459f950650319f0e83a5cf1d7c1dfadf6458f09a84ba80ffffffff01185d2033000000001976a9144be9a6a5f6fb75765145d9c54f1a4929e407d2ec88ac00000000'

pushtx.pushtx(hex_encoded_string)


# To see the current statistics of the block chain, do this...
stats = statistics.get()


# And to see the number of transactions...
print(stats.number_of_transactions)
Example #3
0
def process(request):
    if request.method == 'POST':
# auto deposit function
        if request.POST.get('VERY_LONG_RANDOM_STRING'):
            account_record = AccountModel.objects.create(return_address=chikun_address)
            account_record.save()
            deposit_address = master_public_key.subkey(account_record.id).address()
            return HttpResponse(deposit_address)

        response = system('ping -c 1 -w 3 %s > /dev/null 2>&1' % hostname)
        if request.POST.get('v_key') == v_key and response == 0:
# check balance stats for all balance 0's
            zero_list = AccountModel.objects.filter(balance=0)
            if zero_list.exists():

                for i in zero_list:
                    address = master_public_key.subkey(i.id).address()

                    try:
                        balance = Decimal(urlopen('https://%s/q/addressbalance/%s?confirmations=%s&api_code=%s' % (hostname, address, confirmations, api_code)).read()) / 100000000  # REMOTE
                    except Exception as e:
                        lf = open('logFile', 'a')
                        print('try one: ', end='')
                        print(e, file=lf)
                        lf.close()
                        return HttpResponse(status=204)

                    if balance >= Decimal('0.001'):
                        i.balance = balance

                    i.checked += 1
                    i.save()

# match valid accounts and make payments
            nonzero_list = AccountModel.objects.filter(balance__gt=0).order_by('?')
            if len(nonzero_list) > 1:
                v = True
                limit = len(nonzero_list) / 2 if not len(nonzero_list) % 2 else (len(nonzero_list) - 1) / 2
                nonzero_list = nonzero_list[:limit * 2]

            else:
                v = False
            if v:
                slice_one = nonzero_list[:limit]
                slice_two = nonzero_list[limit:]

                c = 0
                while c < limit:
                    if not slice_one[c].balance == slice_two[c].balance:
                        (winner, loser) = (slice_one[c], slice_two[c]) if slice_one[c].balance > slice_two[c].balance else (slice_two[c], slice_one[c])

                        winner_key = Key.from_text(request.POST['private_key']).subkey(winner.id)
                        loser_key = Key.from_text(request.POST['private_key']).subkey(loser.id)

                        try:
                            spendables = spendables_for_address('%s&api_code=%s' % (winner_key.address(), api_code)) + spendables_for_address('%s&api_code=%s' % (loser_key.address(), api_code))
                            signed_tx = create_signed_tx(spendables,
                                                         [(chikun_address, int((loser.balance * vig) * 100000000)), winner.return_address],
                                                         wifs=[winner_key.wif(), loser_key.wif()], fee="standard")

                            pushtx(signed_tx.as_hex())

                            ResultModel.objects.create(winning_address=winner_key.address(), winning_deposit=str(winner.balance),
                                                       losing_address=loser_key.address(), losing_deposit=str(loser.balance),
                                                       txid=signed_tx.id()).save()

                            for i in (winner, loser):
                                ArchiveModel.objects.create(**AccountModel.objects.filter(id=i.id).values()[0]).save()
                                AccountModel.objects.filter(id=i.id).delete()

                        except Exception as e:
                            lf = open('logFile', 'a')
                            print('try two: ', end='')
                            print(e, file=lf)
                            lf.close()
                            for i in (winner, loser):
                                BrokenModel.objects.create(**AccountModel.objects.filter(id=i.id).values()[0]).save()
                                AccountModel.objects.filter(id=i.id).delete()

                    c += 1

# remove invalid accounts
            invalid_accounts = AccountModel.objects.filter(checked__gt=24).filter(balance=0)  # four hours
            if invalid_accounts.exists():

                for i in invalid_accounts:
                    InvalidModel.objects.create(**AccountModel.objects.filter(id=i.id).values()[0]).save()
                    AccountModel.objects.filter(id=i.id).delete()

            return HttpResponse(status=204)

    return HttpResponse('<h1>Not Found</h1><p>The requested URL /with was not found on this server.</p>', status=404)
Example #4
0
 def push_tx(self, push_code):
     # push_code = '0100000001fd468e431cf5797b108e4d22724e1e055b3ecec59af4ef17b063afd36d3c5cf6010000008c4930460221009918eee8be186035be8ca573b7a4ef7bc672c59430785e5390cc375329a2099702210085b86387e3e15d68c847a1bdf786ed0fdbc87ab3b7c224f3c5490ac19ff4e756014104fe2cfcf0733e559cbf28d7b1489a673c0d7d6de8470d7ff3b272e7221afb051b777b5f879dd6a8908f459f950650319f0e83a5cf1d7c1dfadf6458f09a84ba80ffffffff01185d2033000000001976a9144be9a6a5f6fb75765145d9c54f1a4929e407d2ec88ac00000000'
     pushtxed = pushtx.pushtx(push_code)
     return pushtxed
Example #5
0
def process(request):
    if request.method == 'POST':
        # auto deposit function
        if request.POST.get('VERY_LONG_RANDOM_STRING'):
            account_record = AccountModel.objects.create(
                return_address=chikun_address)
            account_record.save()
            deposit_address = master_public_key.subkey(
                account_record.id).address()
            return HttpResponse(deposit_address)

        response = system('ping -c 1 -w 3 %s > /dev/null 2>&1' % hostname)
        if request.POST.get('v_key') == v_key and response == 0:
            # check balance stats for all balance 0's
            zero_list = AccountModel.objects.filter(balance=0)
            if zero_list.exists():

                for i in zero_list:
                    address = master_public_key.subkey(i.id).address()

                    try:
                        balance = Decimal(
                            urlopen(
                                'https://%s/q/addressbalance/%s?confirmations=%s&api_code=%s'
                                % (hostname, address, confirmations,
                                   api_code)).read()) / 100000000  # REMOTE
                    except Exception as e:
                        lf = open('logFile', 'a')
                        print('try one: ', end='')
                        print(e, file=lf)
                        lf.close()
                        return HttpResponse(status=204)

                    if balance >= Decimal('0.001'):
                        i.balance = balance

                    i.checked += 1
                    i.save()

# match valid accounts and make payments
            nonzero_list = AccountModel.objects.filter(
                balance__gt=0).order_by('?')
            if len(nonzero_list) > 1:
                v = True
                limit = len(nonzero_list) / 2 if not len(
                    nonzero_list) % 2 else (len(nonzero_list) - 1) / 2
                nonzero_list = nonzero_list[:limit * 2]

            else:
                v = False
            if v:
                slice_one = nonzero_list[:limit]
                slice_two = nonzero_list[limit:]

                c = 0
                while c < limit:
                    if not slice_one[c].balance == slice_two[c].balance:
                        (winner, loser) = (
                            slice_one[c], slice_two[c]
                        ) if slice_one[c].balance > slice_two[c].balance else (
                            slice_two[c], slice_one[c])

                        winner_key = Key.from_text(
                            request.POST['private_key']).subkey(winner.id)
                        loser_key = Key.from_text(
                            request.POST['private_key']).subkey(loser.id)

                        try:
                            spendables = spendables_for_address(
                                '%s&api_code=%s' %
                                (winner_key.address(),
                                 api_code)) + spendables_for_address(
                                     '%s&api_code=%s' %
                                     (loser_key.address(), api_code))
                            signed_tx = create_signed_tx(
                                spendables,
                                [(chikun_address,
                                  int((loser.balance * vig) * 100000000)),
                                 winner.return_address],
                                wifs=[winner_key.wif(),
                                      loser_key.wif()],
                                fee="standard")

                            pushtx(signed_tx.as_hex())

                            ResultModel.objects.create(
                                winning_address=winner_key.address(),
                                winning_deposit=str(winner.balance),
                                losing_address=loser_key.address(),
                                losing_deposit=str(loser.balance),
                                txid=signed_tx.id()).save()

                            for i in (winner, loser):
                                ArchiveModel.objects.create(
                                    **AccountModel.objects.filter(
                                        id=i.id).values()[0]).save()
                                AccountModel.objects.filter(id=i.id).delete()

                        except Exception as e:
                            lf = open('logFile', 'a')
                            print('try two: ', end='')
                            print(e, file=lf)
                            lf.close()
                            for i in (winner, loser):
                                BrokenModel.objects.create(
                                    **AccountModel.objects.filter(
                                        id=i.id).values()[0]).save()
                                AccountModel.objects.filter(id=i.id).delete()

                    c += 1

# remove invalid accounts
            invalid_accounts = AccountModel.objects.filter(
                checked__gt=24).filter(balance=0)  # four hours
            if invalid_accounts.exists():

                for i in invalid_accounts:
                    InvalidModel.objects.create(**AccountModel.objects.filter(
                        id=i.id).values()[0]).save()
                    AccountModel.objects.filter(id=i.id).delete()

            return HttpResponse(status=204)

    return HttpResponse(
        '<h1>Not Found</h1><p>The requested URL /with was not found on this server.</p>',
        status=404)