Accepting Bitcoin - monitoring transactions coming in - python-2.7

I want to accept Bitcoin on my site. I assign each incoming sale a Bitcoin public key/address from a pool of non-used addresses.
I add records to the pool of non-used addresses by generating 1000 receiving addresses on a separate computer using MultiBit and then importing them into the table. I do this as often as I need when I am running out of addresses.
My question is this:
What is the best way or API (and most simple, that does not require bitcoind installation?!) to monitor incoming deposits to a list of addresses to which I don't have public keys for? Basically I would need a cron to check for incoming transactions to these addresses so I can detect payment acceptance.

If you use btc.blocker.io's API you can find the balance of any address use the url like so
http://btc.blockr.io/api/v1/address/info/PublicAdressGoesHere
It will have an outcome something close to this
{"status":"success","data":{"address":"198aMn6ZYAczwrE5NvNTUMyJ5qkfy4g3Hi","is_unknown":false,"balance":8000.00176957,"balance_multisig":0,"totalreceived":8000.00176957,"nb_txs":30,"first_tx":{"time_utc":"2009-02-22T10:50:53Z","tx":"0f0fbcc18fd0d090ad3402574df8404cec1176bc000f9aa0dc19f8d832ff94db","block_nb":"5219","value":400,"confirmations":385428},"last_tx":{"time_utc":"2015-11-25T00:47:46Z","tx":"77bfb2a8098508646980195c7885baf710c1b30b83cfb7432c6de01a1afe1bc7","block_nb":"385201","value":0.000135,"confirmations":5446},"is_valid":true},"code":200,"message":""}
if you want to read the data in python try using this code. It will out put the data into a file called data.txt And it takes data in from a file called address.txt. only do one address at a time
import urllib2.urlopen
with open("address.txt","r") as file:
address = str(file.read())
data = urllib2.urlopen("http://btc.blockr.io/api/v1/address/info/" + address)
with open("data.txt", "w") as a:
a.write(str(data.read()))
hope this helps!

Related

Best way to do TRC20 transaction callbacks

I am working on TRC20 network and I am using it to monitor a list (1000+) addresses to check if there are any USDT being sent in.
I tried 2 methods but I am not sure what is the best approach to do this.
Method 1: which is the .watch() function from the official documentation
https://developers.tron.network/reference/methodwatch
I am able to get lots of transaction information, but I did a test with my own transactions and its really wonky, as in I am not able to catch my own transactions reliably.
Method 2: calling the api to get all transactions of a wallet address.
https://developers.tron.network/reference/get-transaction-info-by-account-address
The issue with this is I have to do polling every x minutes on 1000+ addresses ( which will grow in the future).
Would like to ask if anyone could share how do platforms monitor their addresses. I joined the tron developer community and its full of scammers.
Method 2:

Can I send XRP to multiple addresses?

I'm new to XRP devlopment and I was making an api for an exchange project with XRP and wanted to know that is XRP can be sent to multiple addresses?
No, it is currently not possible for a single transaction to send to multiple destination addresses. Instead, you should create one transaction for each destination. Be sure to increment the account sequence number (Sequence) so that each transaction sent from the same (source) account has a unique, sequential, monotonically-increasing sequence number.

How many Tasks can I add to a Chilkat Task Chain?

How many Tasks can I add to a Task Chain? I'm using the ActiveX component.
Specifically I'm adding emails using MailMan.SendMailAsync and will have thousands of emails queued.
Theoretically there is no limit, other than eventual memory limitations.
In any case, I wouldn't recommend it as a solution for sending thousands of emails. The reason is that here is no good way to handle external problems that may occur midway in the sending process, such as network or mail server problems.
A better and more scalable approach might be to write all the .eml files to a directory. You could write code to do the following until the "mail queue directory" is empty.
Select a .eml in the directory.
Load it into a Chilkat Email object.
Send the email using Chilkat MailMan via the SendEmail or SendEmailAsync method.
If your programming language allows you to create background threads, then you could create N threads, each with its own MailMan object that does the above. You would want to control/synchronize access to .eml files in some way to ensure that no two threads simultaneously choose the same .eml file. Also, N would limited to the number of connections from the same IP an SMTP server might allow.
If you're sending the same email to each recipient, or the same email template with replacements, then there's no need to actually write the full email for every recipient ahead of time. You could just manage the list, and for each subsequent email just update it with a new To/CC/BCC address (taking care to clear the To/CC/BCC email addresses from the Email object prior to calling AddTo/AddCc/AddBcc to add the new email address, otherwise the recipient list in the email grows with each iteration), do subject/body string replacements, etc. and send.

Sending SMS and email to 100000 members in django-mysql envrionment

I am having a real headache on how to handle this one. Basically, the application got members that are projected to reach one million at the end of the year. It relies heavily on USSD but also have email. Actually for now, I would prefer to send the SMS first.
The issue is this: the members have groups based on their activities and a single member can have multiple groups. Currently, the highest number of members in a group is 17,000.00. The group can basically send SMS to those 17,000 members. The group leaders specify paramters ("All Members","Females","Age 24-28" etc) and send the SMS, which must save a copy in the database. Currently, there are 5 active groups but they will certainly increase in the future and they can all request to broadcast SMS to members at once.
The phone numbers of members is kept in:
class Profile(model.Models):
user=models.ForeignKey(User)
phone=models.CharField(max_length=13)
Similarly, the app should basically scan the member profiles to send them period notifications. For now, I am following the following:
Select the phone numbers of all members that satisfy the criteria
Create an id for the broadcast and wait for previously stacked SMS requests to finish. Then add the selected phones to a secondary table referencing to the broadcast
Loop through each phone and send one by one. Once finished, mark the broadcast as finished
class BroadCast(models.Model):
code=models.CharField(max_length=50) #rand generated
group=models.ForeignKey(Corporate)
finished=models.IntegerField(default=0)
message=models.CharField(max_length=200)
class Phone(models.Model):
broadcast=models.ForeignKey(BroadCast)
But am disappointed by its performance especially for multiple requests. What can i do to improve it?
I am using twilio paid SMS.
tele=models.CharField(max_length=13)
I had an sms application before that had scaled and slowed down when the user base was large, to fix that we used queue for the sms sending task. Worked wonders and should also work perfectly in your case.

How to send mass mail in Django and get status for every message?

I'm creating a web app for handling various surveys. An admin can create his own survey and ask users to fill it up. Users are defined by target groups assigned to the survey (so only user in survey's target group can fill the survey).
One of methods to define a target group is a "Token target group". An admin can decide to generate e.g. 25 tokens. After that, the survey can be accessed by anyone who uses a special link (containing the token of course).
So now to the main question:
Every token might have an e-mail address associated with itself. How can I safely send e-mails containing the access link for the survey? I might need to send a few thousand e-mails (max. 10 000 I believe). This is an extreme example and such huge mailings would be needed only occasionally.
But I also would like to be able to keep track of the e-mail message status (was it send or was there any error?). I would also like to make sure that the SMTP server doesn't block this mailing. It would also be nice if the application remained responsive :) (The task should run in background).
What is the best way to handle that problem?
As far as I'm concerned, the standard Django mailing feature won't be much help here. People report that setting up a connection and looping through messages calling send() on them takes forever. It wouldn't run "in background", so I believe that this could have negative impact on the application responsiveness, right?
I read about django-mailer, but as far as I understood the docs - it doesn't allow to keep track of the message status. Or does it?
What are my other options?
Not sure about the rest, but regardless for backgrounding the task (no matter how you eventually do it) you'll want to look for Celery
The key here is to reuse connection and to not open it again for each email. Here is a documentation on the subject.