Browse Source

Block.md content. Remove blockheader doc

patch-2
Esteban Ordano 10 years ago
parent
commit
7c012eaa95
  1. 50
      docs/Block.md
  2. 1
      docs/Blockheader.md
  3. 1
      docs/Transaction.md

50
docs/Block.md

@ -1 +1,51 @@
# Block
A Block instance represents the information on a block in the bitcoin network.
Note that creating it takes some computing power, as the tree of transactions
is created or verified.
Given a hexa or base64 string representation of the serialization of a block
with its transactions, you can instantiate a Block instance. It will calculate
and check the merkle root hash (if enough data is provided), but transactions
won't neccesarily be valid spends, and this class won't validate them. A binary
representation as a `Buffer` instance is also valid input for a Block's
constructor.
```javascript
assert(Block.isValidHeader(data);
assert(Block.isValidBlock(data);
var block = new Block(hexaEncodedBlock);
assert(block.id && block.hash && block.id === block.hash);
assert(block.version === Block.CurrentVersion);
assert(block.prevHash);
assert(block.timestamp);
assert(block.nonce);
assert(block.size);
assert(block.transactions[0] instanceof Transaction);
```
## Navigating through transactions
The set of transactions in a block can be explored by iterating on the block's
`transactions` member.
```javascript
for (var transaction in block.transactions) {
// ...
}
```
It is also possible to explore a block's Merkle tree of transaction hashes.
Head to the [Merkle tree](./DataStructures.html#MerkleTree) documentation for
more information:
```javascript
var root = block.tree.root;
assert(root instanceof bitcore.DataStructures.MerkleTree.Node);
assert(root.hash === block.id);
assert(root.isLeaf === false);
assert(root.left instanceof bitcore.DataStructures.MerkleTree.Node);
assert(root.right instanceof bitcore.DataStructures.MerkleTree.Node);
assert(root.left.left.left.left.content === block.transactions[0]);
```

1
docs/Blockheader.md

@ -1 +0,0 @@
# Blockheader

1
docs/Transaction.md

@ -49,6 +49,7 @@ You can take a look at the javadocs for the [Transaction class here](link
missing). This document will go over the expected high level use cases.
* from(utxo)
* fromMultisig(utxo, pubkeys, threshold)
* change(address)
* fee(amount)
* usingStrategy(strategy)

Loading…
Cancel
Save