Scripts for using Blackcoin from the Command Line Interface
Blackcoin-More (Linux)
Since we have been having "dust storms" I wrote a script for cleaning dust out of wallets. And, because some Legacy clients have been going off chain I wrote a script for comparing the local chain with the BlackcoinNL hosted explorer. After doing that I simply combined them all into a single script with the other scripts I use regularly.
I put symlinks into /usr/local/bin/
for blackmored
, blackmore-cli
, and blk
(the script below). This simple shell script that improves my security (by not saving my password in a file or memory), and simplifies regular tasks.
The alias alias blkc='blackmore-cli'
in .bashrc
is useful as well.
Make sure you chmod 700 $USER all-the-things
(or 755
)
blk
#!/bin/bash
usage="Usage: blk [ info | stake | latest | dust | past24 ] \n \n
info: Check basic info. \n
stake: Enables staking; Passes password without storing it in memory. \n
latest: Compares latest block with the BlackcoinNL hosted block explorer. \n
dust: Prunes dust from wallet. Dust is defined as less than .0001BLK. Requires jq. \n
past24: Shows staking numbers from the past 24hrs. \n"
blkc='/usr/local/bin/blackmore-cli -datadir=/var/lib/.blackmore/'
case $1 in
info )
$blkc getwalletinfo | egrep "balance|staked_balance|txcount|unconfirmed_balance|immature_balance|total_balance";
$blkc getnetworkinfo | egrep "subversion|connections";
$blkc getinfo | egrep "blocks";
$blkc getblockchaininfo | egrep "best";
$blkc getstakinginfo | egrep "enabled|staking|netstakeweight|expectedtime";
;;
stake )
echo 'enter Blackcoin Password'
read -s BLKPW
$blkc walletpassphrase $BLKPW 99999999 true
BLKPW=null
;;
latest )
latest=$($blkc getblockcount) && \
blacksight=$(curl -s https://node.blackcoin.io/insight-api/block-index/$latest? | cut -d '"' -f4) && \
blackmore=$($blkc getblockhash $latest) && \
diff -sy --label Local <(echo $blackmore) --label Explorer <(echo $blacksight)
;;
dust )
IFS=$'\n';
$blkc listtransactions "*" 99999 | jq -r '.[] | select(.category != "send") | select(.amount < .0001) | .txid' | uniq >txid.txt
while read line; do
echo $line
$blkc removeprunedfunds $(echo $line)
done < "txid.txt"
;;
past24 )
latest=$($blkc getblockcount)
since=$(expr $latest - 1350)
hash=$($blkc getblockhash $since)
past24=$($blkc listsinceblock $hash | jq -r '.[] | .[] | select(.confirmations > 0) | select(.amount = 0) .confirmations' 2> /dev/null | wc -l)
total=$($blkc getwalletinfo | jq -r ' .total_balance | round')
per10k=$(echo "scale=2; $past24/($total/10000)" | bc -l)
echo $past24 stakes over the past 24hrs... "$per10k" per 10k BLK...
;;
*)
echo -e $usage
;;
esac
jq
is required for the dust pruning script, and can be found via your favorite package manager.
Blackcoin-Legacy (Windows)
The script below is almost exactly the same as the blk latest
command above, but it's written with blackcoind.exe
for Windows, which is not in the user PATH.
I don't use Windows, but I'm told the easiest way to get bash on Windows is to install https://gitforwindows.org/
Then you can just copy paste this line (while in the directory with blackcoind.exe):
latest=$(./blackcoind.exe getblockcount) && \
blacksight=$(curl -s https://node.blackcoin.io/insight-api/block-index/$latest? | cut -d '"' -f4) && \
blackcoin=$(./blackcoind.exe getblockhash $latest) && \
diff -sy --label Local <(echo $blackcoin) --label Explorer <(echo $blacksight)
Mac
Mac dropped their old OS for Unix a while back, so the script at the top should work just fine for Blackcoin-More, and can be adjusted for Blackcoin-Legacy if needed.
Again, jq
does not come installed, so you need to pick that up:
- First, install the
brew
package manager: (Link) brew install jq
OR
Install from: http://macappstore.org/jq/
Need Help?
BlackcoinNL supported chatrooms:
- BlackcoinNL Discord Invite -> https://discord.gg/EmWf2teMma
- Discord for countries that block it -> https://www.blackcoin.nl/chat-service-bridge/
- Telegram by BlackcoinNL -> T.me/BlackcoinNL
- Keybase -> https://keybase.io/blackcoin
Other commonly used Blackcoin Social Media:
- IRC -> https://en.irc2go.com/webchat/?net=freenode&room=blackcoin
- Gitter -> https://gitter.im/BlackCoin_Hub/
- Reddit -> https://reddit.com/r/blackcoin
- BlackcoinNL Twitter -> https://twitter.com/BlackcoinNL
- BlackcoinOrg Twitter -> https://twitter.com/BlackcoinOrg
- BlackcoinOrg Facebook -> https://facebook.com/BlackcoinOrg