Some occasional contributions ...
I came across a coherent commit for adding coincontrol to a peercoin fork (I've mislaid the pointer) which I thought seemed a likely proposition, so I had a go at applying the commits (aka "cherrypicking") to the Slimcoin codebase. It was an unexpectedly good fit (it's not the first time I've had a go at adding coincontrol to the Slimcoin wallet, so I found the exercise instructive in that respect) and it appears to function as expected, although please note, I've not yet actually tried
using it but it does sanely report my UTXO set.
The presence of the "custom change address" option may be cause for cautious optimism that this change might help resolve the exchange's issues with the API. I haven't done
any testing so expectations should be contained for now.
In pursuit of getting a clean (i.e. orphanless) and more tractable mapping of the blockchain to RDF, I added a couple of chain admin utilities,
linearizehashes and
dumpbootstrap, producing respectively, a file of linearized (i.e. orphanless) hashes and a file of linearized (i.e. orphanless) blocks in sequence. As part of the same exercise, I added some wallet maintenance facilities -
checkwallet,
repairwallet and
zapwallettxes. This is the RPC-API view:
and this is the GUI view:
Be warned, it is untested. However it did repair (a copy of) my wallet, OTOH, I suspect
zapwallettxes is actually
zapwallet, 'cos that's what it seemed to do to (a copy of) my wallet but I could be mistaken, it seemed to work okay the second time (and the advice is correct, it is a
slow process - many hours to rescan 1.4-odd million blocks ) ... and anyway, I need to take another, closer look at the db calls, just out of principle.
Not at all coincidentally and with barrystyle's guidance, I managed to complete the forensic analysis of the Slimcoin genesis block and, with the assistance of
dumpbootstrap, was able to extend the analysis to include all of the (linearized) blockchain. The end result is a kind of generalised access utility for reading blocks out of the blockchain and processing them. I have an idiosyncratic model of TDD and do most of my rapid prototyping development from within Sublime Text, using a Build Process to execute a Python unittest class and tests, of which this is one pertinent example showing basic use.
slmoffsets.txt is a file of linearized sequential offsets into the linearised, sequential blocks in
bootstrap.dat, which I wantonly press into service as a noncommittal lookup table via the shell utilities
head and
tail. In these fragments, mentions of
datadir are, confusingly, actually references to the
bootstrap.dat file. It is a work-in-progress ...
def read_block_at_height(self, blockheight):
# Get offset from lookuptable of sequential offsets
offset = int(subprocess.getoutput('head -%s %s | tail -1' % (blockheight, os.getcwd() + '/slmoffsets.txt')))
# Position the read cursor at the offset and return the result of
# calling read_block at that point in bootstrap.dat
ds = BCDataStream()
with open(datadir, "rb") as file:
ds.map_file(file, 0)
ds.seek_file(offset)
data = self.read_block(ds, blockheight)
file.close()
return data
I created the offset map with
@unittest.skip("Suspended, skipping")
def test_create_offsetlookup(self):
"""
Write a text file of sequential offsets to blocks in the bootstrap
file for use as a lookup table (see test_read_block_at_1100000,
below, for usage example). Cheap and cheerful.
"""
ds = BCDataStream()
with open(datadir, "rb") as file, open('slm-offsets', 'w') as ofile:
ds.map_file(file, 0)
ofile.write("{}\n".format(ds.read_cursor))
self.read_genesis_block(ds)
cnt = 1
while True:
try:
# Only interested in offset so ignore the output
_ = self.read_block(ds)
ofile.write("{}\n".format(ds.read_cursor))
except:
break
cnt += 1
ds.close_file()
print("Done")
Full deal, including a premilled offsets up to ... hang on ..
$ wc -l slmoffsets.txt
1477565 slmoffsets.txt
block 1477565 are in
contrib/toolbag in the
"develop" branch of the Slimcoin repos.
There's a
blockreader.py which I'm now using and a
blockreader-workings-out.py in case I've gone down a developmental rabbit hole and later need to restore to a previous save point and try another route.
The develop branch includes the pos-optimization contrib, the coincointrol feature and the chain/block management features.
Handle with care.Cheers
Graham