This change will reduce the total number of allocations required to
create/store the allocated filter as we’ll now perform a _single_
allocation, rather than one each time the the dynamically size slice
reaches capacity.
This commit adds support for bech32 encoded segwit
addresses, namely AddressWitnessPubKeyHash and
AddressWitnessScriptHash. These are both specified
in BIP 173.
The bech32 format is used to encode base32 data
in a string format specified in BIP 173. This is
among other things used to encode native segwit
addresses, also specified in the same BIP.
This commit adds the package bech32, which
contains the necessary utility methods to create
bech32 encoded strings from arbitrary data.
Allow users to create custom ExtendedKeys by exporting the newExtendedKey function.
The comment is updated to reflect that this function is only intended to be used
by custom applications.
The github markdown interpreter has been changed such that it no longer
allows spaces in between the brackets and parenthesis of links. This
updates all of the markdown files accordingly.
While here, it also corrects a couple of inconsistencies in regards to
other README.md files in the project.
Putting the test code in the same package makes it easier for forks
since they don't have to change the import paths as much.
Also, address a few style and consistent nits while here:
- Prefer t.Fatalf over t.Errorf followed by a return
- Use the consistent style of starting a test function comments with the
test name
- Prefix test errors by the function being called instead of the one
doing the calling since the caller itself is already logged by the
test framework
- Check err in max depth test before checking the returned key is nil
BIP32 keys serialize the depth as a uint8 over the wire. I noticed
uint16 was being used and that the depth was being taken modulo 256
during serialization.
This seems like a bug, as the behaviour is not described in the BIP,
and also introduces incompatibilities which can be hard to make sense
of. For example, the parent fingerprint should be 0x00000000 for a key
of depth zero, whereas with the existing code if depth=256, then the
serialization will set 0 but still set a parent fingerprint.
This updates all code in the main package and subpackages to make use of
the new chainhash package since the old wire.ShaHash type and functions
have been removed in favor of the abstracted package.
Also, since this required API changes anyways and the hash algorithm is
no longer tied specifically to SHA, all other functions throughout the
code base which had "Sha" in their name have been changed to Hash so
they are not incorrectly implying the hash algorithm.
The following is an overview of the changes:
- Update all references to wire.ShaHash to the new chainhash.Hash type
- Rename the following functions and update all references:
- Block.Sha -> Hash
- Block.TxSha -> TxHash
- Tx.Sha -> Hash
- bloom.Filter.AddShaHash -> AddHash
- Rename all variables that included sha in their name to include hash
instead
- Add license headers to coinset package files
The vet tool moved into the Go source tree as of Go 1.5. Its previous
location in the x/tools repo was deprecated at that time and has now
been removed.
This commit updates the .travis.yml configuration to avoid fetching vet
from the old location and to simply use the version now available as
part of the standard Go install.
Also, while here, remove the check for changing the tool path since it
is no longer needed.
Interpreting a 0 as the lower limit of 1e-9 seems more intuitive behavior when receiving an out-of-bounds argument.
davecgh's fixes to TestFilterFPRange
This corrects an issue with the serialization of extended private keys
where certain underlying derivations could cause lead to printing
extended privkeys that did not have the expected xprv prefix.
In addition, tests for private key derivation have been added as well as
a specific test which triggers the previously failing case.
This changes the NewMaster function to accept the network the generated
extended master key is associated with. This could previously be done
by calling SetNet on the returned extended key, but that approach is
more error prone since it is easy for a caller to forget to do it or
never know they should to begin with.