Hello...Dai_trying wrote:I had some time this morning to look at this and although this might not work I thought I would let you see what I have so far as it's not too far off.
First I created a quick bash script to act as bitcoin-cli simply to interpret the parameters
I included 1 more parameter than you would be using in case there was some extra info being sent.Code: Select all
#!/bin/bash echo "Param 1 = $1" echo "Param 2 = $2" echo "Param 3 = $3" echo "Param 4 = $4" echo "Param 5 = $5" echo "Param 6 = $6" echo "Param 7 = $7"
Next the file with codesI named it BitcoinList.txt and you would need to edit the script to reflect the actual file you use.Code: Select all
1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX 1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz
Then the Python script:which gives me the result :Code: Select all
import json import subprocess a = 0 d = {} e = [] with open('BitcoinList.txt') as input_file: for i in input_file: a += 1 b = a/100 d[i.strip()] = '%.2f' % b e.append(i.strip()) r = json.dumps(d) s = json.dumps(e) subprocess.check_call(['/path/to/bin/bitcoin-cli', 'sendmany', '""', r, '1', '"Description comment"', s])
What is left to do is adding the escapes (\) and maybe some extra quotes but I'm out of time for today so thought I would get this out in case you can tweak it, it is quite a simple script so should not be too difficult to do.Code: Select all
Param 1 = sendmany Param 2 = "" Param 3 = {"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX": "0.01", "1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz": "0.02"} Param 4 = 1 Param 5 = "Description comment" Param 6 = ["1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX", "1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz"] Param 7 =
HTH
Many thanks for the effort. It looks like very much to what I need. I'm going to try another approach in my bash script to see what comes out.
I'm thinking about to do what I'm already doing about building the command, but instead of trying to issue it, I'll right the output to a file already formatted and then will try to load only the JSON objects I need to send to the command already formatted!
If even like this it doesn't work, I'll consider to migrate the rest of the code and this task to python.
Thanks
Psy