
How to easily perform same action on all wallets stored on daemon...
New cryptocurrency users are not usually familiar with requirement that wallets need to be optimized regularly to avoid failed transactions due to size constrains.
I made up nice shell script that I run using cron on my Linux server:
#!/bin/sh
curl -s -X POST http://127.0.0.1:33777/json_rpc -H 'Content-Type: application/json-rpc' -d '{"jsonrpc": "2.0", "method": "getAddresses", "password": "this_is_not_my_real_password", "params": {}, "id": "1"}' | jq '.result.addresses | .[]' | xargs -I ADDR curl -s -X POST http://127.0.0.1:33777/json_rpc -H 'Content-Type: application/json-rpc' -d '{"jsonrpc": "2.0", "method": "sendFusionTransaction", "password": "this_is_not_my_real_password", "params": {"addresses": ["ADDR"], "destinationAddress": "ADDR", "threshold" : 100000000, "anonymity": 0}, "id": "1"}'
What it essentially does is first fetch all addresses (subwallets) stored on wallet daemon (for my webwallet) using curl and then feed it through JSON parser (jq) and then use xargs to execute curl once with each address returned by "jq" (replacing "ADDR" with the actual address).
I replaced my real password with placeholder "this_is_not_my_real_password" as I don't want anyone to try to hack my wallet daemons even though access is restricted to loopback interface and not network interface that is open to internet or my hosting company.
".result.addresses" is the JSON leaf that contains the list of addresses to use, ".[]" will print just the addresses, one per line. Even though each of the addresses is quoted in jq output, the quoting is removed when xargs does the text replace, so the quotes need to be explicitly added around the text to replace.
"curl -s" will suppress any progress output so it can be cleanly used in scripts that redirect standard error stream (stderr) to "sendmail" program and send non-empty output to server administrator. Standard output stream (stdout) is piped to standard input stream (stdin) of next command in same line using "|".
"-I ADDR" means replace every occurrence of "ADDR" with current line of input to "xargs".
In case of error, output of "jq" command will be empty so "xargs" does nothing.
"33777" needs to be replaced with correct port number of the wallet daemon, JSON methods and result field names are examples that work with some coins based on Bytecoin 2 API.
Leave How to easily perform same action on all wallets stored on daemon... to:
Read more #cryptocurrency posts
Best Posts From Mika
We have not curated any of mtl1979's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Mika
- How to use MyHeritage Family Tree Builder without subscribing...
- PayPal launches its own stablecoin PYUSD... Is it safe or not?
- Design limitations of responsive websites
- April 1st, 2023 marks end of mainstream support of Ubuntu 18.04
- Understanding the Ethereum London Revised scam...
- How to use PancakeSwap for creating trading pair, swapping, buying and selling tokens - Part 2
- How to use PancakeSwap for creating trading pair, swapping, buying and selling tokens - Part 1
- How to combat abuse of token bridges...
- Finnish food and drink company recalls potato chips due to potential overdose...
- Why it is bad idea to let Ubuntu upgrade Python to 3.10...