Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you explain these variables #202

Open
alialsaif opened this issue May 2, 2014 · 1 comment
Open

Could you explain these variables #202

alialsaif opened this issue May 2, 2014 · 1 comment

Comments

@alialsaif
Copy link

I was looking at the code base and came by this :

BITCOIN_PORT = 8333
BITCOIN_RPC_PORT = 8332
ARMORY_RPC_PORT = 8225
MAGIC_BYTES = '\xf9\xbe\xb4\xd9'
GENESIS_BLOCK_HASH_HEX = '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000'
GENESIS_BLOCK_HASH = 'o\xe2\x8c\n\xb6\xf1\xb3r\xc1\xa6\xa2F\xaec\xf7O\x93\x1e\x83e\xe1Z\x08\x9ch\xd6\x19\x00\x00\x00\x00\x00'
GENESIS_TX_HASH_HEX = '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a'
GENESIS_TX_HASH = ';\xa3\xed\xfdz{\x12\xb2z\xc7,>gv\x8fa\x7f\xc8\x1b\xc3\x88\x8aQ2:\x9f\xb8\xaaK\x1e^J'
ADDRBYTE = '\x00'
P2SHBYTE = '\x05'
PRIVKEYBYTE = '\x80'

Could you please define these variables and how the values got assigned? I'm attempting to port armory to an altcoin that's based on bitcoin and from reading the response on Issue #32 I came to understand that these values is where I should start.

I've come across : http://blockexplorer.com/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f and compared the genesis hash and its tx hash and noticed they were placed in the code after being reordered. Could you please elaborate on that as well? if I had the hex for a genesis block that uses the same mechanics, do I need to reorder it before inserting it?

also what's the difference between GENESIS_BLOCK_HASH_HEX and GENESIS_BLOCK_HASH ? can one be calculated by having the other or are they different values? same goes with the TX variables.

@cj-dimaggio
Copy link

Hey, this is a pretty old but seeing as the issue is still open I figured I'd try to answer for anybody still curious.

Those variables appear to be Bitcoin specific constants that the protocol uses. For instance:

BITCOIN_PORT is, as the name suggests, the port the bitcoin process runs and makes connections on

BITCOIN_RPC_PORT is the port the bitcoin server listens on for JSON-RPC requests

MAGIC_BYTES if memory services is a string of binary that denotes the beginning of a new block (As Armory is predominantly a blockchain parser this is crucial)

ADDRBYTE, its been a little while since I messed around with the bitcoin binary but if memory serves this is the byte that designates which network the address is for (mainnet addresses are formatted differently than testnet/regtest)

The basics of GENESIS_TX and GENESIS_BLOCK are self explanatory, they denote the unique starting point of the block chain. HASH and HEX_HASH both represent the same data but in different ways. HASH represents bytes as a python string and HEX_HASH represents the bytes as hexadecimal. You can convert the string using binascii:

>>> import binascii
>>> binascii.b2a_hex('\xbe1\x04\xe83\x02~\xc5')
'be3104e833027ec5'
>>> binascii.a2b_hex('be3104e833027ec5')
'\xbe1\x04\xe83\x02~\xc5'

I'm not exactly sure what you're referring to when you talk about "reordering". if you are talking about why the genesis hash is in a different format on blockexplorer this is because the bitcoin client saves the binary in "little endian" but most sites (such as blockexplorer and blockchain.info) present it in "big endian".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants