Commit graph

192 commits

Author SHA1 Message Date
Alex
3069dcf175 gcs: add package for building and using Golomb-coded set filters 2018-05-15 19:14:18 -07:00
Olaoluwa Osuntokun
06f32abe07
hdkeychain: address go vet warnings 2018-05-14 19:59:48 -07:00
Olaoluwa Osuntokun
a5016344ef
bloom: update due to latest wire updates 2018-05-14 19:59:31 -07:00
Olaoluwa Osuntokun
672f737332
build: use go 1.9.4 and 1.10 for travis builds 2018-05-14 19:51:39 -07:00
Olaoluwa Osuntokun
501929d3d0
add cached version of HasWitness 2017-07-26 11:36:19 -07:00
Olaoluwa Osuntokun
9c01665307
add new WitnessHash method to Tx
This commit adds a new method to btcutil.Tx which implements a memoized
equivalent to the `Hash` method but for the newly defined `wtxid.
2017-07-26 11:36:13 -07:00
Olaoluwa Osuntokun
6950f39a70
add new BytesNoWitness method to Block
This commit adds a new method to btcutil.Block for obtaining the
serialization of a Block *without* any witness data (if any).
2017-07-26 11:36:09 -07:00
Johan T. Halseth
fd898ec77a bech32 encoded segwit addresses.
This commit adds support for bech32 encoded segwit
addresses, namely AddressWitnessPubKeyHash and
AddressWitnessScriptHash. These are both specified
in BIP 173.
2017-07-25 22:14:01 -05:00
Johan T. Halseth
38c25ef9cd bech32: Add bech32 encoding package.
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.
2017-07-25 22:14:01 -05:00
Thomas Kerin
5ffa719c38
Expose hdkeychain.Depth() - returning number of derivations since the root 2017-06-12 02:02:13 +02:00
Chris Pacia
61ec18f9c8 Export NewExtendedKey
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.
2017-06-05 14:41:43 -04:00
Dave Collins
fac8a9a582
multi: Update markdown files for GFM changes.
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.
2017-05-25 13:01:10 -05:00
Dave Collins
66871daeb1 hdkeychain: Add new test vector 3 tests.
This adds the new test vectors added to BIP32 on 2017-02-24 which test
hardened derivation with leading zeros.
2017-05-10 00:19:46 -05:00
Dave Collins
1fb0120cc6
hdkeychain: Consolidate tests into package.
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
2017-05-09 12:09:02 -05:00
Thomas Kerin
4f8b4dbcb2 hdkeychain: BIP32 maximum depth is 255.
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.
2017-05-09 11:40:57 -05:00
David Hill
dcd4997b06 Switch to upstream golang.org/x/crypto 2017-05-08 23:05:27 -05:00
David Hill
a5ecb5d954 travis: +go 1.8.x -go 1.6.x (#94) 2017-04-19 10:14:49 -04:00
David Hill
86346b5a95 build: Add gosimple linter to goclean.sh 2017-01-11 15:38:44 -05:00
David Hill
bca6409ade Drop fastsha256 in favor of crypto/sha256 2017-01-10 17:09:00 -05:00
John C. Vernaleo
96e858f48e Remove -v from go test.
This caused unhelpful clutter in travis output.

Closes #89
2016-12-07 10:12:35 -05:00
David Hill
2d8020d311 build: Add unconvert linter to goclean.sh 2016-12-01 18:02:50 -05:00
John C. Vernaleo
1425c4327e Modify goclean to use gometalint like btcd 2016-12-01 11:23:38 -06:00
Dave Collins
183acb4ad9
Correct LICENSE to the btcsuite developers.
This appears to have been missed during the relicense
2016-11-16 15:37:28 -06:00
David Hill
f6a0d000db Reduce allocs in Block.Bytes() 2016-11-16 12:40:24 -05:00
Dave Collins
9b9ce80a2e coinset: Add missing import in wire. 2016-10-27 15:27:44 -05:00
Dave Collins
aa9087a7ef
coinset: Update for wire.NewMsgTx API change. 2016-10-26 22:49:46 -05:00
David Hill
68e5965458 Update travis to test against golang 1.7 (#80) 2016-08-17 13:13:29 -05:00
Waldir Pimenta
6906ba090e add license title (#79)
background: https://github.com/btcsuite/btcd/pull/717
2016-08-11 20:46:26 -05:00
Dave Collins
22c91fa80a Update for recent chainhash-related API changes. (#78)
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
2016-08-08 12:38:16 -05:00
Dave Collins
2c26dd81a5 bloom: Avoid a few unnecessary hash copies. (#76)
This changes several places which call the Bytes method of a ShaHash to
simply use a slice of it in order to avoid the extra unnecessary copies.
2016-04-23 03:34:57 -05:00
Dave Collins
bdf4400eca TravisCI: Remove external go vet reference. (#74)
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.
2016-04-07 13:25:49 -05:00
Olaoluwa Osuntokun
e0dbb5b535 txsort: Update package for BIP0069 acceptance.
BIPLI01 has been accepted as BIP0069, so update the README, comments,
tests, and testdata files as such.
2016-03-22 12:49:35 -07:00
Dave Collins
52bb44a147 Update TravisCI for Go 1.6.
Now that Go 1.6 has been released, remove the old Go versions from the
configurations tested by TravisCI and add the latest point releases.
2016-03-22 12:39:47 -05:00
Dave Collins
ae78918521 bloom: Correct merkle block test error print.
The test would have erroneously printed the function address instead of
the received bytes if it failed.
2016-03-22 12:33:12 -05:00
Tadge Dryja
44e3030885 Fix range check in bloom filter false positive rate
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
2016-02-26 22:20:35 -08:00
Dave Collins
2d190f72ff hdkeychain: Correct extended privkey serialization.
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.
2016-02-09 17:34:25 -06:00
Dave Collins
ff82dacded hdkeychain: Update NewMaster to accept network.
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.
2015-11-10 11:31:41 -06:00
Dave Collins
e8bab6bc19 docs: Make various README.md files consistent.
First, it removes the documentation section from all the README.md files
and instead puts a web-based godoc badge and link at the top with the
other badges. This is being done since the local godoc tool no longer
ships with Go by default, so the instructions no longer work without
first installing godoc. Due to this, pretty much everyone uses the
web-based godoc these days anyways. Anyone who has manually installed
godoc won't need instructions.

Second, it makes sure the ISC license badge is at the top with the other
badges and removes the textual reference in the overview section.

Third, it's modifies the Installation section to Installation and
Updating and adds a -u to the go get command since it works for both and
thus is simpler.

Finally, it replaces the badges with SVG versions from shields.io so
they are consistent.
2015-10-23 17:17:38 -05:00
Dave Collins
d6989ebc71 txsort: Correct the names of the tests. 2015-10-23 14:34:12 -05:00
Dave Collins
0df67ee064 txsort: Add InPlaceSort function.
This adds a new function with loud warnings which allows sorting a
transaction in place by mutating it.  This is more efficient for the
caller if they are the ones creating the transaction and are sure it
will not invalid any cache or containing structures.

The Sort function which makes a copy and is therefore does not mutate
the passed transaction is still available and the default method.
2015-10-23 12:46:06 -05:00
Dave Collins
e0e9257790 txsort: Convert tests, optimize, and cleanup code.
- Move hex for test txns into separate files in the testdata directory
- Convert tests to table-driven tests
- Make comments more consistent with the rest of the codebase
- Optimize the input sorting function to perform the hash equivalence
  check before reversing the bytes so it can be avoided in that case
2015-10-23 12:43:47 -05:00
Dave Collins
98fd0a0661 txsort: Convert to package
This converts the txsort code into a separate package and renames
'TxSort' and 'IsTxSorted' to 'Sort' an `IsSorted`, respectively.

It also adds a 'doc.go' and 'README.md' so it is consistent with the
other packages.
2015-10-23 12:09:28 -05:00
tx
5fd45e8085 Add TxSort and TxIsSorted functions to btcutil
These functions sort transaction inputs and outputs according to BIP LI01
(https://github.com/kristovatlas/rfc/blob/master/bips/bip-li01.mediawiki)

This is useful to standardize transactions for faster  multi-party
agreement as well as preventing information leaks in a single-party
use case.
2015-10-22 23:49:53 -07:00
Mawuli Adzoe
03f6069579 Update docs for NewAmount
- Documentation update to NewAmount.
  Call out the fact it's specifically for converting BTC to Satoshi.
  The caller should perform a simple type cast to an Amount when dealing
  with int64 values which denote a quantity of Satoshi.
2015-08-12 07:01:50 +00:00
Dave Collins
1c7f05922f Convert block heights to int32.
This commit converts all block height references to int32 instead of
int64.  The current target block production rate is 10 mins per block
which means it will take roughly 40,800 years to reach the maximum
height an int32 affords.  Even if the target rate were lowered to one
block per minute, it would still take roughly another 4,080 years to
reach the maximum.

In the mean time, there is no reason to use a larger type which results
in higher memory usage.
2015-08-07 22:30:27 -05:00
Dave Collins
d39a255dbc Return matched tx indices from NewMerkleBlock.
This commit modifies the NewMerkleBlock function to return the matched
transaction indices instead of their hashes.  This is being done because
it is much easier for the caller to lookup the matched transactions from
the original passed block based on their transaction index within the
block versus their hashes.
2015-07-28 04:02:49 -05:00
Dave Collins
f3db5cf7e5 Use container-based builds on TravisCI.
Also, import the goclean.sh script directly into this repository and
call it directly instead of using a remote gist.
2015-07-28 03:45:19 -05:00
Mawuli Adzoe
deba3d6436 Fix tiny typo in docs. 2015-07-24 06:59:43 +00:00
Mawuli Adzoe
ee7c40a181 Add testable example for UnitConversions
Fix imports, fix output pretty print

Use btcutil.Amount() instead of btcutil.NewAmount()

Trim off unnecessary .String()

Testable example for Amount

Improve example for btcutil.Amount
2015-07-22 21:20:10 +00:00
Mawuli Adzoe
7501aee141 Improve godocs. Add testable example for NewAmount
This is consistent with the rest of the code base.
i.e.: base58/bloom/hash160/hdkeychain.
2015-07-21 03:50:16 +00:00