-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_net2.py
More file actions
24 lines (19 loc) · 899 Bytes
/
create_net2.py
File metadata and controls
24 lines (19 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from bitcoinapp.models import Transaction, Net2_edge, Tx_input, Tx_output, User, Address
def main():
total_tx=Transaction.objects.all().count()
i = 1
for tx in Transaction.objects.all():
print "transaction %d with hash %s of %d" % (i, tx.hash, total_tx)
if len(tx.tx_input_set.all())>0:
tx_in = tx.tx_input_set.all()[0]
#assume all inputs have the same user since this is how users were created
user1 = tx_in.address.user
for tx_out in tx.tx_output_set.filter(amount__lte=500000000):
user2=tx_out.address.user
if (user1!=user2):
amount=tx_out.amount
edge = Net2_edge.objects.create(from_user=user1,to_user=user2,val=amount)
edge.save()
i+=1
if __name__ == "__main__":
main()