-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathsendmany64.py
executable file
·54 lines (45 loc) · 1.1 KB
/
sendmany64.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
from config import *
from list import segids
import json
import requests
import sys
# accept amount to send as argument
try:
amount = float(sys.argv[1])
except:
print("Please, specify an amount to send.")
quit()
# construct daemon url
rpcurl = (
'http://' +
rpcuser +
':' +
rpcpassword +
'@' +
rpcip +
':' +
rpcport)
# define function that posts json data
def post_rpc(url, payload, auth=None):
try:
r = requests.post(url, data=json.dumps(payload), auth=auth)
return(json.loads(r.text))
except Exception as e:
raise Exception("Couldn't connect to " + url + ": ", e)
# iterate addresses list, construct dictionary,
# with amount as value for each address
addresses_dict = {}
for e in segids:
address = e[-1]
addresses_dict[address] = amount
# define payload
payload = {
"jsonrpc": "1.0",
"id": "python",
"method": "sendmany",
"params": ["", addresses_dict]}
#print(json.dumps(payload))
# make rpc call, issue transaction
call_result = post_rpc(rpcurl, payload)
print(json.dumps(call_result))