dcrd/blockchain/standalone
Dave Collins 8354a310bc
main: Consume latest module minors and patches.
This updates the main module to use the latest available minor and patch
versions of all modules and reverts the recent change that incorrectly
removed all of the blake256 references from the various go.sum files.

The following required direct dependencies are bumped as follows:

- github.com/decred/dcrd/blockchain/stake@v1.2.1
- github.com/decred/dcrd/blockchain/stake/v2@v2.0.1
- github.com/decred/dcrd/certgen@v1.1.0
- github.com/decred/dcrd/chaincfg@v1.5.2
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/chaincfg/v2@v2.2.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.0
- github.com/decred/dcrd/gcs@v1.1.0
- github.com/decred/dcrd/hdkeychain/v2@v2.0.1
- github.com/decred/dcrd/txscript/v2@v2.0.0
- github.com/decred/dcrwallet/rpc/jsonrpc/types@v1.2.0
2019-08-08 10:05:35 -05:00
..
bench_test.go blockchain/standalone: Add subsidy calc funcs. 2019-08-06 21:19:56 -05:00
doc.go blockchain/standalone: Add IsCoinBaseTx. 2019-08-06 21:47:50 -05:00
error_test.go blockchain/standalone: Implement a new module. 2019-08-06 10:29:30 -05:00
error.go blockchain/standalone: Implement a new module. 2019-08-06 10:29:30 -05:00
example_test.go blockchain/standalone: Add merkle root calc funcs. 2019-08-06 10:40:57 -05:00
go.mod blockchain/standalone: Add merkle root calc funcs. 2019-08-06 10:40:57 -05:00
go.sum main: Consume latest module minors and patches. 2019-08-08 10:05:35 -05:00
merkle_test.go blockchain/standalone: Add IsCoinBaseTx. 2019-08-06 21:47:50 -05:00
merkle.go blockchain/standalone: Add merkle root calc funcs. 2019-08-06 10:40:57 -05:00
pow_test.go blockchain/standalone: Implement a new module. 2019-08-06 10:29:30 -05:00
pow.go blockchain/standalone: Implement a new module. 2019-08-06 10:29:30 -05:00
README.md blockchain/standalone: Add IsCoinBaseTx. 2019-08-06 21:47:50 -05:00
subsidy_test.go blockchain/standalone: Add subsidy calc funcs. 2019-08-06 21:19:56 -05:00
subsidy.go blockchain/standalone: Add subsidy calc funcs. 2019-08-06 21:19:56 -05:00
tx_test.go blockchain/standalone: Add IsCoinBaseTx. 2019-08-06 21:47:50 -05:00
tx.go blockchain/standalone: Add IsCoinBaseTx. 2019-08-06 21:47:50 -05:00

standalone

Build Status ISC License GoDoc

Package standalone provides standalone functions useful for working with the Decred blockchain consensus rules.

The primary goal of offering these functions via a separate module is to reduce the required dependencies to a minimum as compared to the blockchain module.

It is ideal for applications such as lightweight clients that need to ensure basic security properties hold and calculate appropriate vote subsidies and block explorers.

For example, some things an SPV wallet needs to prove are that the block headers all connect together, that they satisfy the proof of work requirements, and that a given transaction tree is valid for a given header.

The provided functions fall into the following categories:

  • Proof-of-work
    • Converting to and from the compact target difficulty representation
    • Calculating work values based on the compact target difficulty
    • Checking a block hash satisfies a target difficulty and that target difficulty is within a valid range
  • Merkle root calculation
    • Calculation from individual leaf hashes
    • Calculation from a slice of transactions
  • Subsidy calculation
    • Proof-of-work subsidy for a given height and number of votes
    • Stake vote subsidy for a given height
    • Treasury subsidy for a given height and number of votes
  • Coinbase transaction identification

Installation and Updating

$ go get -u github.com/decred/dcrd/blockchain/standalone

Examples

  • CompactToBig Example
    Demonstrates how to convert the compact "bits" in a block header which represent the target difficulty to a big integer and display it using the typical hex notation.

  • BigToCompact Example
    Demonstrates how to convert a target difficulty into the compact "bits" in a block header which represent that target difficulty.

  • CheckProofOfWork Example
    Demonstrates checking the proof of work of a block hash against a target difficulty.

  • CalcMerkleRoot Example
    Demonstrates calculating a merkle root from a slice of leaf hashes.

License

Package standalone is licensed under the copyfree ISC License.