Commit Graph

4442 Commits

Author SHA1 Message Date
Dave Collins
b5dd4a030a
txscript: Prepare v1.1.0.
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
2019-06-19 14:47:05 -05:00
Dave Collins
10147bc8f8
database: Use chaincfg/v2.
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.
2019-06-19 14:18:43 -05:00
Dave Collins
ce852eb852
blockchain: Do coinbase nulldata check locally.
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.
2019-06-19 13:26:33 -05:00
Dave Collins
a0b84e4005
docs: Update for dcrutil v2 module. 2019-06-19 12:09:20 -05:00
Dave Collins
ed43e59df5
release: Introduce dcrutil v2 module. 2019-06-19 12:09:19 -05:00
Dave Collins
9b753598df
dcrutil: Update to use chaincfg/v2 module. 2019-06-19 12:09:18 -05:00
Dave Collins
e1840ea6cc
dcrutil: Use mock addr params in tests.
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.
2019-06-19 12:09:18 -05:00
Dave Collins
2779e67a20
dcrutil: Introduce AddressParams interface.
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.
2019-06-19 12:09:17 -05:00
Dave Collins
423c3344d6
dcrutil: Accept magic bytes directly in NewWIF.
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.
2019-06-19 12:09:16 -05:00
Dave Collins
5ca5f814cd
dcrutil: Require network on WIF decode.
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.
2019-06-19 12:09:16 -05:00
Dave Collins
736e0317b8
dcrutil: Don't store net ref in addr impls.
This modifies the concrete address implementations to only store the
necessary individual parameters instead of the entire params struct to
further decouple from chaincfg.
2019-06-19 12:09:15 -05:00
Dave Collins
07786d83e1
dcrutil: Rename EncodeAddress to Address.
This renames the EncodeAddress method on the Address interface to
Address and updates all of the concrete implementations and tests
accordingly.
2019-06-19 12:09:14 -05:00
Dave Collins
37531d2b35
dcrutil: Remove Net from Address interface.
This removes the no longer necessary Net method from the Address
interface and all concrete address implementations.
2019-06-19 12:09:14 -05:00
Dave Collins
54cd596803
dcrutil: Remove DSA from Address interface.
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.
2019-06-19 12:09:13 -05:00
Dave Collins
b13eb4511f
dcrutil: Remove IsForNet from Address interface.
This removes the no longer necessary IsForNet method from the Address
interface and all concrete address implementations.

It also updates the tests accordingly.
2019-06-19 12:09:12 -05:00
Dave Collins
0ba5ac74e5
dcrutil: Require network on address decode.
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.
2019-06-19 12:09:12 -05:00
Dave Collins
ff1268a1ef
dcurtil: Remove unused ErrMissingDefaultNet. 2019-06-19 12:09:11 -05:00
Dave Collins
be589d216c
dcrutil: Remove unused ErrAddressCollision. 2019-06-19 12:09:10 -05:00
Dave Collins
2142c4037c
dcrutil: Make docs example testable and correct it.
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.
2019-06-19 12:09:10 -05:00
Dave Collins
eab91970f5
release: Freeze version 1 dcrutil module.
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.
2019-06-19 12:09:05 -05:00
Dave Collins
e62a21858b
fullblocktests: Add coinbase nulldata tests.
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.
2019-06-18 14:47:32 -05:00
David Hill
893aa30dce multi: Use https links where available. 2019-06-18 14:20:06 -05:00
David Hill
2036772446 addrmgr: drop container/list. 2019-06-18 14:44:55 -04:00
Dave Collins
c33be8c68c
multi: Update all modules for chaincfg v1.5.1.
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.
2019-06-17 15:54:31 -05:00
David Hill
542c5e01e7 secp256k1: Introduce v2 module 2019-06-17 16:15:34 -04:00
David Hill
1d6a39546a secp256k1: unexport NAF 2019-06-17 12:12:59 -04:00
David Hill
c7a988b7cb schnorr: add signature IsEqual and Verify methods 2019-06-17 12:12:59 -04:00
David Hill
9149b2ba68 schnorr: unexport functions 2019-06-17 12:12:59 -04:00
David Hill
6b4d1a47b7 schnorr: remove curve param 2019-06-17 12:12:59 -04:00
David Hill
1cf1fc5998 release: freeze version 1 dcrec/secp256k1 module.
This serves as the final release of version 1 of the dcrec/secp256k1 module.
All future releases will be moving to version 2 of the module.
2019-06-17 12:12:59 -04:00
Dave Collins
2968070c7b
chaincfg: Add addr params accessor funcs.
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.
2019-06-14 17:55:37 -05:00
Dave Collins
6bb0838e84
docs: Update for dcrec/edwards v2 module.
This updates the docs/README.md file, module hierarchy graphviz, and
module hierarchy diagram to reflect the new module version.
2019-06-14 11:34:48 -05:00
David Hill
bb479d1209 edwards: Introduce v2 module. 2019-06-14 08:21:57 -04:00
David Hill
88c18b4490 edwards: add Sign method to PrivateKey 2019-06-14 08:21:54 -04:00
David Hill
aa76fb64a1 edwards: add signature IsEqual and Verify methods 2019-06-14 08:21:53 -04:00
David Hill
f0ef1e4e2c edwards: unexport a slew of funcs 2019-06-14 08:21:50 -04:00
David Hill
06102241bf edwards: unexport EncodedBytesToBigIntPoint 2019-06-14 08:21:44 -04:00
David Hill
be5b1ad1ed edwards: remove curve param 2019-06-14 08:21:40 -04:00
David Hill
db81028c54 release: freeze version 1 dcrec/edwards module.
This serves as the final release of version 1 of the dcrec/edwards module.
All future releases will be moving to version 2 of the module.
2019-06-13 17:47:58 -04:00
David Hill
d0a6bf024d rpcserver: Fix misspelling. 2019-06-13 16:45:42 -05:00
Dave Collins
8deeee97c4
dcrutil: Prepare v1.3.0.
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
2019-06-13 14:08:53 -05:00
Dave Collins
5070857dbe
chaincfg: Use dcrec/edwards/v1.0.0.
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.
2019-06-13 01:37:13 -05:00
Dave Collins
67ace6e117
docs: Update for chaincfg v2 module.
This updates the docs/README.md file, module hierarchy graphviz, and
module hierarchy diagram to reflect the new module version
2019-06-12 20:14:35 -05:00
Dave Collins
c1e08e919e
chaincfg: Introduce chaincfg v2 module. 2019-06-12 20:14:34 -05:00
Dave Collins
cba25b056d
chaincfg: Convert global param defs to funcs.
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
2019-06-12 20:14:34 -05:00
Dave Collins
b863fd5875
chaincfg: Use scripts in block one token payouts.
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
2019-06-12 20:14:33 -05:00
Dave Collins
0f368c29c8
chaincfg: Concrete genesis hash in Params struct.
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.
2019-06-12 20:14:32 -05:00
Dave Collins
85a0e66eea
chaincfg: Move regnet code to regnet files.
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.
2019-06-12 20:14:31 -05:00
Dave Collins
4dab5d430a
chaincfg: Move simnet code to testnet files.
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.
2019-06-12 20:14:31 -05:00
Dave Collins
8b333b7eb1
chaincfg: Move testnet3 code to testnet files.
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.
2019-06-12 20:14:30 -05:00