Skip to content

Instantly share code, notes, and snippets.

@dooglus
Created February 21, 2013 06:44
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save dooglus/5002764 to your computer and use it in GitHub Desktop.
Save dooglus/5002764 to your computer and use it in GitHub Desktop.
create bootstrap.dat from bitcoin-qt's blk0000?.dat files
// g++ UniversalTimer.o BinaryData.o FileDataPtr.o BtcUtils.o BlockObj.o BlockUtils.o libcryptopp.a -o bootstrap.out -Icryptopp -DUSE_CRYPTOPP -D__STDC_LIMIT_MACROS -lpthread bootstrap.cpp
#include "BlockUtils.h"
int main(void)
{
string btcdir("/home/chris/.bitcoin");
string bootstrap(btcdir + "/" + "bootstrap.dat");
BlockDataManager_FileRefs::GetInstance().SelectNetwork("Main");
BlockDataManager_FileRefs & bdm = BlockDataManager_FileRefs::GetInstance();
BinaryData magic = bdm.getMagicBytes();
ofstream os;
// bdm.SetBlkFileLocation(btcdir, 4, 1); // 4 digit blk0001.dat from 0.7.x
bdm.SetBlkFileLocation(btcdir + "/blocks", 5, 0); // 5 digit blocks/blk00000.dat from 0.8.x
bdm.parseEntireBlockchain();
os.open(bootstrap.c_str(), ios::out | ios::binary);
for (uint32_t i=0; i<=216116; i++) {
BlockHeader * bhp = bdm.getHeaderByHeight(i);
os.write( bhp->serializeWholeBlock(magic, true).toBinStr().c_str(), bhp->getBlockSize()+8);
}
os.close();
}
@dooglus
Copy link
Author

dooglus commented Feb 21, 2013

git clone git://github.com/etotheipi/BitcoinArmory.git
build it
put the above into cppForSwig/bootstrap.cpp
edit btcdir to match the location of your bitcoin directory
build using the same flags as for BlockUtilsTest.out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment