Skip to content

Instantly share code, notes, and snippets.

// Copyright (c) 2013-2014 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
from:
https://github.com/conformal/btcwire/blob/master/msgblock_test.go#L511-L550
// Block one serialized bytes.
var blockOneBytes = []byte{
0x01, 0x00, 0x00, 0x00, // Version 1
from:
https://en.bitcoin.it/wiki/Block_hashing_algorithm
<?PHP
function SwapOrder($in){
$Split = str_split(strrev($in));
$x='';
for ($i = 0; $i < count($Split); $i+=2){
from:
https://en.bitcoin.it/wiki/Block_hashing_algorithm
this python code will calculate the hash of the block with the smallest hash as of June 2011, Block 125552. The header is built from the six fields described above, concatenated together as little-endian values in hex notation:
>>> import hashlib
>>> header_hex = ("01000000" +
"81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
"e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
"c7f5d74d" +
from:
https://code.google.com/p/blockchain/source/browse/trunk/BlockChain.cpp
inline uint32_t readVariableLengthInteger(void)
{
uint32_t ret = 0;
uint8_t v = readU8();
if ( v < 0xFD ) // If it's less than 0xFD use this value as the unsigned integer
{
from:
http://godoc.org/github.com/conformal/btcscript
const (
OP_FALSE byte = 0 // AKA OP_0
OP_0 = 0
OP_DATA_1 = 1
OP_DATA_2 = 2
OP_DATA_3 = 3
OP_DATA_4 = 4
from:
https://github.com/conformal/btcwire/blob/master/common.go
// readVarInt reads a variable length integer from r and returns it as a uint64.
func readVarInt(r io.Reader, pver uint32) (uint64, error) {
b := make([]byte, 8)
_, err := io.ReadFull(r, b[0:1])
if err != nil {
return 0, err
}
http://blockr.io/block/info/210965
blk0003.dat
from:
http://2.bp.blogspot.com/-DaJcdsyqQSs/UsiTXNHP-0I/AAAAAAAATC0/kiFRowh-J18/s1600/blockchain.png
http://codesuppository.blogspot.com/2014/01/how-to-parse-bitcoin-blockchain.html
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
f9beb4d9 uint32_t:magicID:4 bytes
Verifying myself: My Bitcoin username is +qikcoin. https://onename.io/qikcoin

Keybase proof

I hereby claim:

  • I am qikcoin on github.
  • I am qikcoin (https://keybase.io/qikcoin) on keybase.
  • I have a public key whose fingerprint is 040E 5AC6 5783 64F0 0D46 1E00 6FB0 4365 A498 30CB

To claim this, I am signing this object: