Commit graph

157 commits

Author SHA1 Message Date
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
Mawuli Adzoe
3c3f9360f4 Fix tiny typo
I think the intent is: https://en.wiktionary.org/wiki/producible
2015-07-20 11:20:46 +00:00
Josh Rickmar
9ffb1ecd80 Add Common Name to certificate.
Some applications fail to parse the certificate if the CN is not set,
even if they (correctly) check SANs before the CN when validating a
hostname.  Even though the CN should be ignored if a matching SAN
hostname was found, we can prevent the parse from failing by also
including the hostname as the CN.

Additionally, switch from maps to slices to prevent DNS names and IP
addresses from being reordered when added to the certificate template.
2015-06-15 16:14:08 -04:00
Josh Rickmar
53b0b8cd09 Fix typo in test. 2015-06-11 16:39:44 -04:00
Dave Collins
1b73e9828d Relicense to the btcsuite developers. 2015-05-01 12:41:58 -05:00
Dave Collins
9556412b01 Update for recent wire API hash error changes. 2015-04-17 01:13:40 -05:00
Dave Collins
e330838900 Remove error return from Block.Sha function.
This commit remove the error return from the Block.Sha function since it
can never fail and ends up causing a lot of unneeded error checking
throughout the code base.
2015-04-17 00:42:08 -05:00
Dave Collins
ff58d6571d Update golang.org/x/crypto import paths to new location. 2015-03-03 21:09:03 -06:00
Dave Collins
499e9e0daa Update btcec path import paths to new location. 2015-02-06 10:35:18 -06:00
Dave Collins
1324fa1fad Update btcnet path import paths to new location. 2015-02-05 23:30:03 -06:00
Josh Rickmar
56fe089f4e Update Go versions for Travis. 2015-02-05 17:56:03 -05:00
Dave Collins
80b97479bd Update btcwire path import paths to new location. 2015-02-05 14:48:38 -06:00
Dave Collins
d71631b41f Update btcchain import paths to new location. 2015-01-30 16:15:57 -06:00
Dave Collins
b29aad9f09 Update btcscript import paths to new location. 2015-01-30 12:11:32 -06:00
Josh Rickmar
dca623d4ef Optimize base58 decoding.
This change introduces an autogenerated base58 digit table to remove
the need to find the index of a character in the modified base58
alphabet each time.  Additionally, it removes some unnecessary big
integer allocations to cut down on the GC churn.

Before:
BenchmarkBase58Encode         20          64998995 ns/op           0.08 MB/s
BenchmarkBase58Decode         50          35965928 ns/op           0.19 MB/s

Now:
BenchmarkBase58Encode         20          64644351 ns/op           0.08 MB/s
BenchmarkBase58Decode        200           7914748 ns/op           0.86 MB/s
2015-01-24 14:59:51 -05:00
Dave Collins
9dcef5b30f Update btcscript import paths to new location. 2015-01-16 19:35:54 -06:00
Dave Collins
b2c2b14526 Update btcchain import paths to new location. 2015-01-16 18:45:21 -06:00
Dave Collins
9e2037d6db Update btcec import paths to new location. 2015-01-16 18:04:23 -06:00
Dave Collins
7ac9b42a52 Update btcnet import paths to new location. 2015-01-16 17:36:18 -06:00
Dave Collins
fdc00f8eff Update btcwire import paths to new location. 2015-01-16 15:26:50 -06:00
Dave Collins
5dada8b184 Update fastsha256 import paths to new location. 2015-01-16 09:20:22 -06:00
Dave Collins
f80c4d718d Update btcutil import paths in README.md files. 2015-01-15 21:35:29 -06:00
Dave Collins
506d333934 Update btcutil import paths to new location. 2015-01-15 15:13:38 -06:00
Josh Rickmar
40ba1daf69 Add Amount.ToBTC convenience method.
Closes #26.
2015-01-02 09:19:16 -05:00
Dave Collins
8180321217 Add quick overview about addresses to doc.go.
Closes #4.
2014-12-22 13:39:51 -06:00
Dave Collins
97fea16721 Add package documentation for base58 package.
This commit adds a doc.go file in the base58 package which provides
package documentation for godoc.
2014-12-22 12:36:34 -06:00
Dave Collins
ff8cbd1786 Add testable examples for base58 package.
This commit creates and an example test file for the baes58 package that
integrates nicely with Go's example tooling.

This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
2014-12-22 11:58:06 -06:00
Dave Collins
cef307c87e Complete base58 migration to new package. 2014-12-22 10:56:00 -06:00
Dave Collins
fffd6a2e87 Add benchmarks to base58 package. 2014-12-22 10:45:21 -06:00
Dave Collins
a630ef8247 A few minor modifications to new base58 package.
- Call out in README.md that this is modified base58 (it's not the same as
  normal base58)
- Remove the blurb about test_coverage.txt since it is no longer needed
  now that the repo now has coveralls integrated
- Rename base58_check[_test].go -> basecheck[_test].go.  Since Go treats
  _<ext> special in some cases like for tests and conditional OS and
  architecture compilation, it's a good idea to avoid naming files with
  them to ensure a new special meaning doesn't break builds in the future
2014-12-22 10:29:07 -06:00
benma
07db1b5a70 Integrate the new base58 package. 2014-12-22 12:01:50 +01:00
benma
a72a54be16 Create a new sub-package base58.
It consists of the previous base58 implementation and new
base58 check encoding/decoding functions.
2014-12-22 11:43:07 +01:00
Dave Collins
a3d5cbad22 Add basic tests for NewTLSCertPair. 2014-12-20 15:30:08 -06:00
Dave Collins
5509c323a4 Add test coverage badge to README.md. 2014-12-20 05:19:47 -06:00
Dave Collins
cd83976947 Update TravisCI to use goclean script. 2014-12-20 05:01:59 -06:00
David Hill
c64741f903 Add PEM encode error checking 2014-12-13 10:29:36 -05:00