dcrd/blockchain/standalone
Dave Collins baf32f0cfc
blockchain: Prepare v4.0.0.
This updates the blockchain module dependencies, the copyright year in
the files modified since the previous release, and serves as a base for
blockchain/v4.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0
- github.com/decred/dcrd/blockchain/standalone/v2@v2.1.0
- github.com/decred/dcrd/database/v3@v3.0.0
- github.com/decred/dcrd/dcrutil/v4@v4.0.0
- github.com/decred/dcrd/gcs/v3@v3.0.0
- github.com/decred/dcrd/lru@v1.1.1
- github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7

The full list of updated direct dependencies since the previous
blockchain/v3.0.3 release are as follows:

- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0
- github.com/decred/dcrd/blockchain/standalone/v2@v2.1.0
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/database/v3@v3.0.0
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/dcrutil/v4@v4.0.0
- github.com/decred/dcrd/gcs/v3@v3.0.0
- github.com/decred/dcrd/lru@v1.1.1
- github.com/decred/dcrd/txscript/v4@v4.0.0
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0
- github.com/syndtr/goleveldb@v1.0.1-0.20210819022825-2ae1ddf74ef7

Finally, all modules in the repository that depend on the module are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2021-12-17 13:37:03 -06:00
..
bench_test.go blockchain/standalone: Add subsidy calc funcs. 2019-08-06 21:19:56 -05:00
doc.go blockchain/standalone: Add inclusion proof funcs. 2019-10-12 12:05:58 -05:00
error_test.go blockchain: Prepare v4.0.0. 2021-12-17 13:37:03 -06:00
error.go blockchain/standalone: Prepare v2.0.0. 2020-09-30 11:23:35 -05:00
example_test.go blockchain/standalone: Prepare v2.0.0. 2020-09-30 11:23:35 -05:00
go.mod blockchain/standalone: Remove txscript dep. 2020-09-27 21:31:42 -05:00
go.sum blockchain/standalone: Remove txscript dep. 2020-09-27 21:31:42 -05:00
inclusionproof_test.go blockchain/standalone: Add inclusion proof funcs. 2019-10-12 12:05:58 -05:00
inclusionproof.go multi: Address a bunch of lint issues. 2019-12-30 13:54:41 -06:00
merkle_test.go multi: Implement combined merkle root and vote. 2019-10-12 12:05:57 -05:00
merkle.go multi: Implement combined merkle root and vote. 2019-10-12 12:05:57 -05:00
pow_test.go multi: update blockchain/standalone error types. 2020-09-27 21:30:48 -05:00
pow.go blockchain/standalone: Implement a new module. 2019-08-06 10:29:30 -05:00
README.md multi: Update README.md files for go modules. 2021-01-22 14:39:23 -06:00
subsidy_test.go standalone: Add modified subsidy split calcs. 2021-12-15 12:07:57 -06:00
subsidy.go standalone: Add modified subsidy split calcs. 2021-12-15 12:07:57 -06:00
treasury_test.go standalone: Add InsideTSpendWindow tests. 2020-09-30 11:20:54 -05:00
treasury.go standalone: Misc comment consistency cleanup. 2020-09-30 11:20:55 -05:00
tx_test.go standalone: Add IsTreasuryBase tests. 2020-09-30 11:20:55 -05:00
tx.go standalone: Add IsTreasuryBase tests. 2020-09-30 11:20:55 -05:00

standalone

Build Status ISC License Doc

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

This package is part of the github.com/decred/dcrd/blockchain/standalone/v2 module. Use the standard go tooling for working with modules to incorporate it.

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.