Commit graph

261 commits

Author SHA1 Message Date
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
Josh Rickmar
f9cc0f47b4 Switch to new subrepo import paths. 2014-12-11 10:28:43 -05:00
Jonathan Gillham
a5298a643e Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change. 2014-10-01 13:54:42 +01:00
Dave Collins
ea27722dac Export the hdkeychain min and max seed byte lens. 2014-09-25 22:13:42 -05:00
Dave Collins
2539ca9860 Fix hdkeychain to avoid zeroing net version bytes.
This commit corrects the Zero function in hdkeychain to nil the version
instead of zeroing the bytes.  This is necessary because the keys are
holding onto a reference into the specific version bytes for the network
as provided by the btcnet package.  Zeroing them causes the bytes in the
btcnet package to be zeroed which then leads to issues later when trying
to use them.

Also, to prevent regressions, new tests have been added to exercise this
scenario.

Pointed out by @jimmysong.
2014-09-08 14:30:56 -05:00
Josh Rickmar
d4a2dd199b Update test coverage report. 2014-09-01 21:16:08 -05:00
Josh Rickmar
3fd010412c Remove embedded bloom.Filter mutex.
This prevents the caller from being able to accidentally lock or
unlock access to the filter internal state.

While here, remove several defers that do not gain us any readability,
and only hurt our performance.
2014-09-01 21:16:08 -05:00
Jonathan Gillham
47c887338f Made App Engine runtime compatible. 2014-08-30 15:10:29 -05:00
David Hill
24a92fd581 Add bloom filter Reload method. 2014-08-29 22:45:35 -04:00
David Hill
00f245b959 Fix formatting directives in tests.
Found by 'go vet'
2014-08-28 10:32:49 -04:00
Dave Collins
f6d6cd5d27 Update hdkeychain test coverage report. 2014-08-18 18:18:16 -05:00
Dave Collins
7bd19adb47 Test variable declaration consistency. 2014-08-18 18:17:58 -05:00
Dave Collins
f8ad0939a2 Add new function on extended keys to zero them.
This commit adds a new function named Zero on the hdkeychain.ExtendedKey
which can be used to manually clear the memory used for an extended key.
This is useful for enhanced security by allowing the caller to explicitly
clear the memory when they're done with a key.  Otherwise it might hang
around in memory for a while.

Once a key has been zeroed it is no longer usable.

This commit also contains tests to ensure everything works as expected
after a key has been zeroed.
2014-08-18 17:54:20 -05:00
Dave Collins
a36fbe9ade Correct DefaultWalletLayout example link. 2014-07-22 17:18:15 -05:00
Dave Collins
8f049a120c Correct example links in hdkeychain READEME.md. 2014-07-22 17:17:14 -05:00
Dave Collins
e6c5ca2a6a Implement hdkeychain BIP0032 API.
This commit adds a new sub-package named hdkeychain which can be used to
derive hierarchical deterministic key chains which form the foundation of
hd wallets.

- Support for private and public extended keys
- Convenient cryptographically secure seed generation
- Simple creation of master nodes
- Support for multi-layer derivation
- Easy serialization and deserialization for both private and public
  extended keys
- Support for custom networks by registering them with btcnet
- Obtaining the underlying EC pubkeys, EC privkeys, and associated bitcoin addresses
  ties in seamlessly with existing btcec and btcutil types which provide
  powerful tools for working with them to do things like sign transactions
  and generate payment scripts
- Makes use of the btcec package which is highly optimized for secp256k1
- Code examples including:
  - Generating a cryptographically secure random seed and deriving a
    master node from it
  - Default HD wallet layout as described by BIP0032
  - Audits use case as described by BIP0032
- Comprehensive test coverage including the BIP0032 test vectors
- Benchmarks
2014-07-22 17:11:46 -05:00
David Hill
4a3482182f update comment. 2014-07-10 11:10:44 -04:00
Dave Collins
6de97e738d Add TravisCI build status badge to subpackages. 2014-07-09 20:47:32 -05:00
Dave Collins
17dc3fb3b6 Really add READEME.md for bloom package. 2014-07-09 20:43:24 -05:00
Dave Collins
c78a40ab21 Add READEME.md for bloom package. 2014-07-09 20:41:22 -05:00
Dave Collins
bf92067b65 Use a more specific license adjective in README.md. 2014-07-09 20:39:11 -05:00
Dave Collins
3f83ab60af Add godoc reference badge to README.md files. 2014-07-09 20:36:13 -05:00
Dave Collins
1caa150b5c Add a testable example.
This commit creates and an example test file 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-07-09 20:25:28 -05:00
Dave Collins
bde2b44320 Add license header to all bloom package files. 2014-07-09 20:01:45 -05:00
Dave Collins
ad004c0534 Cleanup and finish BIP0037 bloom filter API.
This commit finishes the work started by @dajohi on bloom filters.

- Rename the package from bloomfilter to bloom
- Rename New function to NewFiler
- Rename Load function to LoadFilter
- Rename BloomFilter type to Filter
- Rename Contains to Matches
- Correct tx match handling to match all inputs and outputs instead of
  only the first one
- Optimize murmur hash function by using constants
- Optimize the merkle block creation and reduce num of memory allocations
  required
- Make MsgFilterLoad concurrent safe as intended
- Update various code consistency issues
- Add a lot of comments
- Improve tests
- Make the code golint clean
2014-07-09 13:28:58 -05:00
David Hill
9e3269e67c Initial work towards BIP0037 bloom filtering API. 2014-07-09 13:28:57 -05:00
Josh Rickmar
e0adcd5f70 Make amount constants untyped.
Since these constants can be useful for int64, Amount, and float64
math, it doesn't make sense to make them just one type, and require
type conversions for the rest.

ok @davecgh
2014-07-08 11:13:12 -05:00
Dave Collins
6c4b5928ab goimports -w . 2014-07-02 19:29:48 -05:00
Josh Rickmar
52be380fd1 Update test coverage report. 2014-06-24 18:46:12 -05:00
Josh Rickmar
b3e031c1f9 Add NewBlockFromReader and NewTxFromReader.
While here, remove the serializedTx field from Tx.  This field was
originally intended to be used to cache the bytes of the serialized
transaction, but it was never used and can effectively leak memory if
the Tx was created with a call to NewTxFromBytes.

ok @davecgh
2014-06-24 18:46:06 -05:00
Josh Rickmar
9a3f83d493 Switch bytes.Buffer to Reader where possible.
bytes.Reader is a little bit more efficient than a bytes.Buffer when
just reading, so in situations where only an io.Reader is needed (for
Block and Tx deserialization), switch to a bytes.Reader.

ok @davecgh
2014-06-23 21:39:04 -05:00
Josh Rickmar
c54649be41 Update test coverage report. 2014-06-23 12:05:49 -05:00
Josh Rickmar
2847c14f06 Add Amount.MulF64.
ok @davecgh, @jcvernaleo
2014-06-23 12:05:00 -05:00
Josh Rickmar
fb4c64910d Make Address a fmt.Stringer. 2014-06-12 20:11:36 -05:00
Josh Rickmar
5bcc7790a0 Update Address and WIF APIs to use btcnet.
This change removes all occurances of btcwire.BitcoinNet from exported
APIs, replacing each with *btcnet.Params.  This simplifies the logic
for verifying string encodings of addresses and WIF private keys which
use leading identifier numbers to differentiate between address types
and the network they are intended for.  It also allows the use of this
package for non-standard networks (not mainnet, regtest, or testnet3)
and future proofs it for the possible addition of future testnet
networks.

To update across this change, replace each btcwire.BitcoinNet
parameter with the associated *btcnet.Params.  For the standard
networks, these changes are:

  btcwire.MainNet  -> &btcnet.MainNetParams
  btcwire.TestNet  -> &btcnet.RegressionNetParams
  btcwire.TestNet3 -> &btcnet.TestNet3Params

ok @davecgh
2014-05-27 17:08:45 -05:00
Josh Rickmar
bff18e5a93 Introduce better WIF API.
The old functions DecodePrivateKey and EncodePrivateKey have been
removed in favor of the DecodeWIF function and the String method of
the new WIF type.

ok @davecgh
2014-05-21 17:49:37 -05:00
Owain G. Ainsworth
973174daa4 Add entrypoint to get the pubkey out AddressPubKey 2014-04-24 01:41:01 +01:00
Francis Lam
3e403ed6c0 Updated coinset interfaces to use btcutil.Amount for coin value 2014-04-23 20:04:03 -04:00
Josh Rickmar
bcb009075b Add method to access P2PKH and P2SH hash arrays.
This change adds the Hash160 methods to AddressPubKeyHash and
AddressScriptHash so the hash may be accessed as an array, rather than
a byte slice with the ScriptAddress method of the Address interface.
In situations where arrays are more appropiate than slices (such as
for map keys), accessing the array directly this way can significantly
improve performance by reducing copying into local arrays.
2014-04-20 18:18:34 -05:00
David Hill
190c86b2bf Preallocate space for the answer in Base58Encode.
Benchmarks show this makes Base58Encode twice as fast.
2014-04-16 20:43:01 -04:00
Josh Rickmar
e622fde7e7 Remove bounds check for NewAmount.
Amount should still be a usable type even if the monetary amount being
described is not an amount at a single instance in time, for example,
the total of all BTC received by an address.  Therefore, the bounds
checks that the amount is within the total amount of bitcoin ever
producable have been removed.

The checks for NaN and +-Infinity remain.
2014-04-12 16:20:11 -05:00
Josh Rickmar
7ec063aebc Fix issues found by golint. 2014-04-12 12:02:54 -05:00
Josh Rickmar
4465e71837 Remove dead code.
Found by go vet.
2014-04-12 11:57:52 -05:00
David Hill
9bd84d007a gofmt 2014-04-12 09:08:49 -04:00
Josh Rickmar
3a2bf60941 Rename AmountUnit constants.
Besides being shorter, using "BTC" rather than "Bitcoin" in the
AmountUnit constants is deemed to be better for these units as BTC is
already a recognized monetary unit.

AmountBaseBitcoin has likewise been renamed to AmountSatoshi as this
is consistant with how it is returned as a string.  The "standard"
part of the comment in the const block has been removed, as Satoshi is
technically not a standard term for this unit.

ok @davecgh
2014-04-11 23:23:27 -05:00
Josh Rickmar
80b1f232bc Make Amount a fmt.Stringer. 2014-04-11 23:16:41 -05:00
Josh Rickmar
fc6f0dee54 Add Amount type to represent a monetary value.
ok @davecgh
2014-04-11 22:43:47 -05:00