just code ... I use Ruby , but I think it's simple to read
# `` == call system , return stdout
# system() == call system too , but return false if has stderr
# "".strip == remove space & "\n"
# [].sample == random pick
# unless == if !
cmd = "bitcoin-cli"
#init chain
`#{cmd} generate 101`
addresses = []
5.times do
addresses << `#{cmd} getnewaddress`.strip
end
block = 101
while block < 500
5.times do
unless system("#{cmd} sendtoaddress #{addresses.sample} 1")
`#{cmd} generate 1`
block += 1
end
end
gencount = rand(10)
if gencount == 0
`#{cmd} generate 1`
block += 1
end
end
`#{cmd} generate 12`
# ^ try to cleanup mempool ...
my final balance is 162.51119684 (it randomly) , but if I restart node , balance show 3202.42966146 , show balance use command : getinfo (okay I know the command has warning ...)
and I use this command to start full node (v150100) Linux amd64
bitcoind -regtest -rpckeepalive=true -rpctimeout=30 -usehd=0 -upnp=0 -server=1 -checkblocks=16 -maxuploadtarget=10 -onlynet=ipv4 -connect=0 -whitelist=127.0.0.1 -maxorphantx=0 -maxmempool=5 -mempoolexpiry=0 -maxconnections=0 -dnsseed=0
so~ this is bug? I don't know but I think I need report ...