This updates the txscript dependencies and serves as a base for
txscript/v1.1.0.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/dcrec/secp256k1@v1.0.2
- github.com/decred/dcrd/dcrutil@v1.3.0
- golang.org/x/crypto@v0.0.0-20190611184440-5c40567a22f8
The full list of updated direct dependencies since the previous
txscripti/v1.0.2 release are as follows:
- github.com/decred/dcrd/chaincfg@v1.5.1
- github.com/decred/dcrd/dcrec@v1.0.0
- github.com/decred/dcrd/dcrec/edwards@v1.0.0
- github.com/decred/dcrd/dcrec/secp256k1@v1.0.2
- github.com/decred/dcrd/dcrutil@v1.3.0
- golang.org/x/crypto@v0.0.0-20190611184440-5c40567a22f8
This updates the database module to use v2 of the chaincfg module and
bumps the root module to require dcrutil@v1.3.0 accordingly.
Since v2 of the chaincfg module is only used in the tests and standalone
utility, a major version bump of the database module is not required.
This refactors the consensus code which extracts the null data from the
coinbase from txscript.ExtractCoinbaseNullData so that it is performed
directly in the validation code where it more properly belongs.
The only reason the extraction was previously done in txscript is
because it was not possible to parse scripts outside of it, but that is
no longer the case now that txscript offers an exported tokenizer for
that purpose.
The extraction code is ever so slightly more efficient now that it no
longer needs to be as generic since it now has direct knowledge of the
conditions that need to be handled.
Great care was taken to ensure the semantics are not changed while
refactoring the code and no additional tests are added in this commit
because all of the conditions and code paths are covered by the tests
recently added to the full block tests.
While here, also perform some related code cleanup in the function and
improve the error messages .
Since the txscript.ExtractCoinbaseNullData is no longer necessary, this
deprecates the function and releated error code and constant so they can
be removed in the next major version of txscript.
Finally, since this relies on the script tokenizer which is not yet in a
released version of the txscript module, bump the requirement to include
an as yet unreleased version of txscript to ensure the next time the
blockchain module is released, it will require a newer version of
txscript to be released first.
This implements a mock address params struct that implements the new
interface and modifies the test code to make use of the mock params
instead of chaincfg. This completely decouples the tests, with the
exception of the example code, from chaincfg and therefore any updates
to it such as introducing new test networks will not require changes to
the tests.
This introduces a new interface named AddressParams and updates the
functions that currently take a pointer to a chaincfg.Params struct to
accept the interface instead.
This removes the tight coupling between the two packages at the API
boundary and allows callers to easily provide custom values without
having to create and register and entire chaincfg network as previously
required.
It also updates the tests to make use of the interface.
This modifies NewWIF to accept the required network magic bytes directly
versus a chaincfg.Params struct in order to remove the tight coupling
between the two packages at the API boundary and allows callers to
easily provide custom values without having to create and register and
entire chaincfg network as previously required.
It also removes the now unused error return and updates the tests
accordingly.
This modifies DecodeWIF to accept the required network parameters for
the provided encoded WIF string and introduces a new error to indicate
the provided WIF string is for the wrong network.
This means that DecodeWIF will now return ErrWrongWIFNetwork if the WIF
string being decoded is not for the provided network. This differs from
the previous behavior that would accept arbirtary network bytes and
relied on globally-registered networks in chaincfg to determine which
network the string was for followed by requiring the caller to check if
the WIF was for the specific network it desired upon return.
Finally, it removes the no longer necessary IsForNet method and updates
the documentation accordingly.
This modifies the concrete address implementations to only store the
necessary individual parameters instead of the entire params struct to
further decouple from chaincfg.
This removes the DSA method from the Address interface in favor of only
defining it on the specific concrete address implementations to which it
applies. It also modifies the remaining instances to remove the network
parameters since they are already available on the type.
Finnaly, it updates the example code accordingly.
This removes the no longer necessary IsForNet method from the Address
interface and all concrete address implementations.
It also updates the tests accordingly.
This modifies DecodeAddress to accept the required network parameters
for the provided encoded address and return an error when the provided
address is for the wrong network.
This means that DecodeAddress will now return ErrUnknownAddressType if
the address being decoded is not for the provided network. This differs
from the previous behavior relied on globally-registered networks in
chaincfg to determine which network the encoded address was for followed
by requiring the caller to check if the address was for the specific
network it desired upon return.
It also updates the tests and example accordingly.
This adds a tested example for address decoding and removes the previous
non-functioning version of it from the pacakge documentation. The
previous example appers to have been missed when porting the code and
was no longer correct for Decred.
This serves as the final release of version 1 of the dcrutil module.
All future releases will be moving to version 2 of the module.
Consequently, it bumps the module version as follows:
- github.com/decred/dcrd/dcrutil@v1.3.0
It also removes the dcrutil override in the root module and updates it
so building the software will still produce binaries based on the v1
module until the v2 module is fully released.
This adds two new consensus tests to the full block tests for the
coinbase nulldata height commitment. The first new test ensures
coinbase transactions with the wrong script version are rejected and the
second test ensures data pushes that exceed the maximum allowed number
of bytes for the coinbase nulldata push are rejected.
This updates all of the modules that still rely on v1 of the chaincfg
module to use v1.5.1 which builds correctly with the major API bump
introduced in the edwards v1.0.0 module.
While here, it also updates all references to the v0 edwards and dcrec
modules to their tagged v1 counterparts, tidies all of the modules via
go mod tidy, and removes all unnecessary indirect entries from the mod
files to keep the modules using the versions the dependencies are tested
with.
The primary motivation for this change is that the chaincfg/v2 module
requires edwards/v1 which is not API compatible with edwards/v0.
Consequently, in order for each module to be incrementally updated to
use chaincfg/v2, all of its dependencies must also be able to build with
edwards/v1 which is the case as of chaincfg v1.5.1.
This defines several new functions on the Params struct which return the
magic prefix bytes for addresses.
The new functions are:
- AddrIDPubKeyV0
- AddrIDPubKeyHashECDSAV0
- AddrIDPubKeyHashEd25519V0
- AddrIDPubKeyHashSchnorrV0
- AddrIDScriptHashV0
This will allow the parameters to be used directly as input to an
interface in the future.
This updates the dcrutil dependencies and serves as a base for
dcrutil/v1.3.0.
The updated direct dependencies are as follows:
- github.com/decred/dcrd/chaincfg@v1.5.1
- github.com/decred/dcrd/dcrec@v1.0.0
- github.com/decred/dcrd/dcrec/edwards@v1.0.0
- golang.org/x/crypto@v0.0.0-20190611184440-5c40567a22f8
This updates the chaincfg module to make use of the recently-tagged
dcrec/edwards v1 module and thereby corrects the dependencies for the
chainec package within the chaincfg/v2 module.
The current network parameter definitions are all package-level globals
which have a few undesirable characteristics:
- They are subject to mutation and thus can easily cause subtle and hard
to find bugs
- Many of the fields are defined in terms of others, but due to the
struct being defined at the top level, it's not possible to reference
other fields within it
- They require a lot of unexported global variable state
- It makes it difficult to introduce a base set of parameters that would
likely help highlight exactly what the differences are between the
networks
Consequently, this converts all of the global network parameter
defintions to functions that return a new instance of the relevant
parameters which either directly addresses the aforementioned point, or
at the very least, allows them to be addresses in future commits.
The following is a high level overview of the changes:
- Move all default definitions into functions that return a new instance
of the relevant params
- Move global defintions of variables used in the structs into the
relevant funcs
- Improve consistency in the tests for each set of network params
- Update example in README.md
- Update example doc.go
This modifies the definitions for the required payouts in block one to
define required scripts instead of an address string as well as specify
the required script version and updates all of the network params
accordingly.
This is being done because addresses are a non-consensus construct that
essentially provide a human-readable method of specifying the actual
underlying cryptographic primitives. Thus, the consensus rules
themselves must not directly rely on the ability to interpret and parse
addresses.
It is important to note that, once the blockchain code is updated to
make use of the changes this introduces, it is technically a fork since
the code will be more restrictive, but since it only applies to block
one, it's irrelevant because:
- It's buried under years of blocks
- The actual ledger of block one is unchanged
This modifies the Params struct to store the genesis hash directly
instead of a pointer to it. This makes it more consistent with the rest
of the code base and avoids the need for a separate variable.
This moves the various code that is specific to regnet to the
regnetparams.go file to keep the information housed together. Along the
same lines, it moves the tests specific to the regnet params to
regnetparams_test.go.
It also unexports the block one ledger definition since it should only
be exposed via the params.
This moves the various code that is specific to simnet to the
simnetparams.go file to keep the information housed together. Along the
same lines, it moves the tests specific to the simnet params to
simnetparams_test.go.
It also unexports the block one ledger definition since it should only
be exposed via the params.
This moves the various code that is specific to testnet to the
testnetparams.go file to keep the information housed together. Along
the same lines, it moves the tests specific to the testnet params to
testnetparams_test.go.
It also unexports the block one ledger definition since it should only
be exposed via the params.