On demand, an initial description of the Bitcredit block structure can be found here:
http://bitcredit-currency.org/viewtopic.php?f=24&t=635----------------------------------------------------------------
The Bitcredit protocol differs from the Bitcoin protocol in several aspects but there are also a lot of similarities.
The protocol documentation of Bitcoin is a good starting place, since most of the concepts described in there are applicable to Bitcredit as well, for example hashes, merkle trees, transaction signatures, verifications and more.
https://en.bitcoin.it/wiki/Protocol_documentationThe major differences in the Bitcredit protocol is a more extensive header for each block, a signature section, different formats for the transactions, plus a new transaction type, deposit.
Basic structure of a blockA block consists of:
1. A block header
2. Signatures
3. One coinbase transaction
4. One to ten deposit transactions
5. All other transactions
The block headerThe block header has several similarities with Bitcoin. The header has the following fields, in the order listed:
-
int nVersion - Block version information. Same as Bitcoin.
-
uint256 hashPrevBlock - The hash value of the previous block this particular block references. Same as Bitcoin.
-
uint256 hashMerkleRoot - The reference to a Merkle tree collection which is a hash of all transactions related to this block. Same as Bitcoin.
-
uint256 hashLinkedBitcoinBlock - A reference to the Bitcoin block that this block is linked to.
-
uint256 hashSigMerkleRoot - The reference to a Merkle tree collection which is a hash of all signatures related to this block.
-
unsigned int nTime - A timestamp recording when this block was created. Same as Bitcoin.
-
unsigned int nBits - The calculated difficulty target being used for this block. Not used the same as in Bitcoin, but also affected by the deposits added to this block.
-
unsigned int nNonce - The nonce used to generate this block… to allow variations of the header and compute different hashes. Same as Bitcoin.
-
uint64_t nTotalMonetaryBase - The sum of all rewards given plus all bitcoins that have been claimed up to and including this block.
-
uint64_t nTotalDepositBase - The same value as above, with the difference that coins that hasn't moved for a very long time gets subtracted.
-
uint64_t nDepositAmount - The deposit amount added to this block. This number must correspond to the sum of all deposits in this block.
Signatures-
std::vector vsig - the signatures do not correspond to anything in a Bitcoin block. The signature list is a list of signatures given from each deposit that is included in this block. The signature corresponds to a key that is included in each deposit transaction and is a signature from the creator of the deposit that approves the inclusion of the deposit in this specific block.
The signatures will also be used for other purposes in the future, for example as a security measure where a receiver of a transaction can sign a trasnaction to show that the transaction is in fact correct and addressed to the correct receiver before it can be included in a block.
Transactions, general structureAll transactions conforms to mostly the same format, with certain minor differences, depending on the type.
The following fields makes up a transaction in Bitcredit:
-
int nVersion - Transaction data format version. Same as Bitcoin.
-
unsigned int nTxType - The type of the transaction. This does not exist in Bitcoin. For the moment the types COINBASE, DEPOSIT and STANDARD exists, but more types are planned for inclusion, for extended transaction functionality.
-
std::vector vin - All transaction inputs. Different data type than Bitcoin. See description below.
-
std::vector vout - All transaction outputs. Same as Bitcoin.
-
CKeyID signingKeyId - A signing key id. This field only exists for deposits for the moment.
-
unsigned int nLockTime - The transaction may not be added to a block until after nLockTime. Same as Bitcoin.
Transaction inputsTransaction inputs differs from Bitcoin transaction inputs in that the nSequence field does not exist. The sequence field is (probably) an experimental feature that never have been implemented. The removal of this unimplemented field is twofold, first and foremost, to make transactions more compact. With a rising transaction rate it is important that the transaction byte size can be kept as small as possible. A standard transaction should really ideally be possible to compress even more since some bytes appear to be unnecessary large and can be compacted more. The second reason is security and complexity, since the removed field is intended for a replacement functionality. That replacement functionality could potentially cause security issues.
The following fields makes up a transaction input in Bitcredit:
-
COutPoint prevout - The previous output transaction reference, as an OutPoint structure. Same as Bitcoin.
-
CScript scriptSig - Computational Script for confirming transaction authorization. Same as Bitcoin.
The coinbase transactionThe coinbase transaction has the same function as in Bitcoin, for distributing rewards to miners. There are however some implementation differences between Bitcoin and Bitcredit.
- A coinbase transaction must have its nTxType field set to type COINBASE.
- A Bitcoin coinbase can not be spent until 101 blocks have been generated after the block containing the coinbase. It is the same in Bitcredit but with one exception, a deposit in the same block as the coinbase can spend the coinbase directly, thereby moving the newly created coins directly to deposit. This can be done to make it possible for new miners to get hold of coins to use as deposit directly, instead of trying to buy it from elsewhere. It also solves the problem of providing deposit for the genesis block, since before the genesis block there exists no bitcredits at all.
- The Bitcoin coinbase transaction enforces that the single input that it cointains references nothing. In Bitcredit this input is instead used for two purposes. The first is to provide a place for the so called extranonce. The extranonce is added into the CScript in Bitcoin, where in Bitcredit it is instead using the n field in the prevout member. The second purpose is that the hash field in the prevout member is used to store a hash of most of the fields in the Bitcredit block header. This makes sure that all coinbase transactions are unique and cannot be reused in other blocks, or by other miners mining on a separate chain.
The deposit transactionsThe deposit transactions are the functionality in Bitcredit that makes it possible to add deposits to a block.
- The deposit transaction must have its nTxType field set to type DEPOSIT.
- The deposit transactions must follow directly after the coinbase transaction.
- There can be between one and ten deposit transactions in a block.
- A deposit transaction can only have one single input and a maximum of two outputs. The first output is the coins that are sent to deposit. This output can not be spent until 15 000 blocks have been added after the current block. The second, optional, output is the deposit change. This output can be spent after 101 blocks. This mechanism allows a depositor to add just the correct amount of coins as deposit.
- For the moment it is only the deposit transaction that has the extra field signingKeyId. This key must sign the whole block once it has been assembled. The signatures are stored in the signatures section of the block. This mechanism enables a depositor to pre-create a deposit ahead of block creation. Once the block has been created, the depositor verifies that he approves the inclusion of the deposit in the block by signing it. This depositor may or may not be the same entity as the miner. By allowing deposits to be created ahead of the block a market where depositors offer up deposits for block creators can be established.
All other transactions- All other transactions must have its nTxType field set to type STANDARD.
The transactions following the deposit transactions are regular transactions that are handled in the same way that they are handled in Bitcoin. For comparing the difference in transaction structure as compared to Bitcoin, see the section "Transactions, general structure" above.