Commit Graph

23 Commits

Author SHA1 Message Date
Dave Collins
ee4a0e2e2a
multi: Use dcrec/edwards/v2 module.
This updates the following modules to use the dcrec/edwards/v2 module:

- chaincfg/v2
- dcrutil/v2
- txscript/v2
2019-10-08 10:43:08 -05:00
Dave Collins
6e647f731f
multi: Use crypto/ripemd160 module.
This updates the main, dcrutil, and blockchain modules to make use of
the new crypto/ripemd160 module.
2019-10-08 10:21:03 -05:00
Dave Collins
cebab1ef64
multi: Use secp256k1/v2 module.
This updates the following modules to use the secp256k1/v2 module:

- blockchain
- chaincfg/v2
- dcrutil/v2
- hdkeychain/v2
- mempool/v3
- txscript/v2
- main

The hdkeychain/v3 and txscript/v2 modules both use types from secp256k1
in their public API.

Consequently, in order avoid forcing them to bump their major versions,
secp256k1/v1.0.3 was released with the types redefined in terms of the
secp256k1/v2 module so callers still using v1 of the module that are not
ready to upgrade to the v2 module yet can interoperate by updating to
the latest patch version.
2019-10-08 10:14:13 -05:00
Dave Collins
9b753598df
dcrutil: Update to use chaincfg/v2 module. 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
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
cc484f03d5
dcrutil: Lookup params by addr prefix in chaincfg.
This modifies the code that looks up the params by a given network
prefix to make use of the new function provided by chaincfg in order to
ensure that it works with all registered networks as the package was
intended.
2019-03-16 19:54:44 -05:00
David Hill
d25931fd35
multi: preallocate memory. 2019-03-09 16:43:48 -06:00
Dave Collins
cf3f55f6b0
dcrutil: Fix typos found by misspell. 2019-02-14 22:59:08 -06:00
Dave Collins
6f9b6f1c6e
multi: Use regression test network in unit tests.
This modifies the majority of the tests that make use of chain
parameters and the RPC tests to use the resurrected regression test
network.

It also bumps the affected module versions as follows:

- github.com/decred/dcrd/txscript@v1.0.2
- github.com/decred/dcrd/blockchain/stake@v1.0.3
- github.com/decred/dcrd/mempool@v1.0.2

The blockchain and dcrutil modules are also affected, but since their
version has already been bumped since their last release tags, they are
not bumped again.
2018-10-09 19:40:10 -05:00
Dave Collins
47ade78c1a
multi: Resurrect regression network.
This resurrects the regression test network that was removed before
initial launch although it really should not have been.  The simulation
test network and the regression test network do not serve the same
purpose.  Specifically, the regression test network is intended for unit
tests, RPC server tests, and consensus tests.  On the other hand, the
simulation test network is intended for private use within a group of
individuals doing simulation testing and full integration tests between
different applications such as wallets, voting service providers, mining
pools, block explorers, and other services that build on Decred.

Keeping the concerns separate will allow the simulation test network to
be modified in ways such as activating consensus changes that have been
successfully voted into mainnet without also needing to vote them in on
the simulation test network while still preserving the ability for the
unit tests to properly test the voting semantics and handling to help
prevent regressions.

In addition to resurrecting the regression test network, this also fully
fleshes out new values for the various addresses prefixes (Rk, Rs, Re,
etc), HD key prefixes (rprv, rpub), and treasury multisig details.

As a part of resurrecting the network, a new CLI flag `--regnet` is
added to allow the RPC test harness connect to a running instance, the
areas of the code which involve votes have been modified to allow the
votes to apply to the new network, and tests have been added to the
relevant modules.

This bumps the affected module versions as follows:

- github.com/decred/dcrd/wire@v1.2.0
- github.com/decred/dcrd/chaincfg@v1.2.0
- github.com/decred/dcrd/dcrutil@v1.2.0
- github.com/decred/dcrd/hdkeychain@v1.1.1

The blockchain module is also affected, but since its version has
already been bumped since the last release tag, it is not bumped again.

Finally, this does not include switching unit tests or the RPC test
harness over the new network since that will be done in a separate
commit.
2018-10-09 18:52:13 -05:00
Dave Collins
9e1579771b
multi: Reset testnet and bump to version 3.
This adds a new testnet3 network with new genesis block, block one
ledger, treasury address, and network magic.

All consensus rules that were voted in by testnet2 are automatically
active on the new testnet3 without having to vote them in again.
Consequently, there are no consensus vote agendas defined for it.
2018-08-08 08:09:32 -05:00
David Hill
01316e20f3 multi: Continue conversion from chainec to dcrec. 2018-07-04 11:21:43 -04:00
Josh Rickmar
dcc58786d3 dcrutil: Disallow creation of hybrid P2PK addrs.
Hybrid pubkeys, which are a relic of OpenSSL used in Bitcoin Core, are
not usable with OP_CHECKSIG and we can potentially prevent creating
unspendable outputs by never allowing the creation of P2PK (or derived
P2PKH) addresses for these pubkeys.
2018-03-20 17:44:25 -04:00
David Hill
5fc31ca578 multi: fix misspell linter warnings 2018-02-18 12:26:52 -06:00
Josh Rickmar
8564843206 Import dcrutil repo under dcrutil directory. 2017-10-11 21:29:08 -04:00