Commit graph

21 commits

Author SHA1 Message Date
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
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
Dave Collins
2db41b1f56 Remove deprecated TxShas func from btcutil.Block.
This commit removes the previously deprecated TxShas function from
btcutil.Block.  The preferred method to access transaction hashes is via
the Sha function on each btcutil.Tx contained within the block.

For example, the following illustrates how convert the old TxShas approach
to the new method:

OLD:

for i, sha := range block.TxShas() {
	// use sha
}

NEW:

for i, tx := range block.Transactions() {
	// use tx.Sha()
}

This commit also updates the tests for the removed function.
2014-03-24 13:56:43 -05:00
Dave Collins
c8b172c394 Bring test coverage report up-to-date. 2014-03-24 13:55:09 -05:00
Francis Lam
02a1584784 Added CoinSelector interface and a few simple algos as a sub-package
This commit contains a basic definition for CoinSelector along with some
utility classes and some basic algos to make creating transactions from
a set of available unspent outpoints easier.

Thanks to @dajohi, @davec, @jrick for all the feedback and suggestions
regarding interfaces, organization, optimization, comments and
documentation.
2014-03-22 23:25:33 -04:00
Dave Collins
60d4bed78f Modify DecodeAddress to accept serialized pubkeys.
This commit modifies DecodeAddress to accept and decode pay-to-pubkey
addresses (raw serialized public keys).  Since the resulting Address
needs to have a network associated with it, and a raw serialized public
key does not encode the network with it, a new parameter has been added
which requires the caller to specify a default network to use when
decoding addresses.

In the case the address has a network encoded with it such as for
pay-to-pubkey-hash and pay-to-script-hash addresses, the network will be
decoded from the address and the resulting Address instance will have that
network associated with it.  When the address does NOT have a network
encoded with it, such as a pay-to-pubkey address, the provided default
network will be associated with the returned Address instance.

Also, the tests have been updated to test the new functionality.

ok @owainga and @jrick.
2014-03-18 20:41:54 -05:00
Dave Collins
02bd4b14b1 Add tests for new AddressPubKey type.
More tests are needed and will be completed in future commits.
2014-01-07 23:41:14 -06:00
Josh Rickmar
58bae71f61 Implement Address interface.
Address is a generic interface for any type of "address" a
transaction can be sent to, including but not limited to
pay-to-pubkey, pay-to-pubkey-hash, and pay-to-script-hash.

This change implements Address and concrete types for P2PKH and P2SH
addresses with 100% test coverage.  Pay-to-pubkey support will be
added in the future.

This API is intended to replace the old EncodeAddress/DecodeAddress
functions which are now deprecated.
2014-01-03 11:10:25 -05:00
Dave Collins
f3d39524ce Update test coverage report. 2014-01-02 11:39:32 -06:00
Dave Collins
aa81187165 Update test coverage report. 2013-11-11 10:54:32 -06:00
Dave Collins
29f1bf4ae1 Add tests for new Tx type.
This commit adds both positive and negative tests for the new Tx type to
bring its coverage to 100%.

This is part of the ongoing transaction hash optimization effort noted
in conformal/btcd#25.
2013-10-27 14:00:39 -05:00
Josh Rickmar
f72ab9cfce Update test coverage file 2013-10-08 13:14:04 -04:00
Josh Rickmar
e4925b4abe Add functions to encode and decode payment addresses. 2013-09-12 11:20:34 -04:00
John C. Vernaleo
5eda8b95af Add Base58Encode and Base58Decode functions. ok davec@ 2013-06-13 13:01:46 -04:00
Dave Collins
05d31cdc7a Add negative test for TxLoc. 2013-05-30 11:50:58 -05:00
Dave Collins
3ffe28e364 Add test for OutOfRangeError. 2013-05-30 11:12:29 -05:00
Dave Collins
a5bb254ac6 Add negative tests for TxSha. 2013-05-30 11:06:09 -05:00
Dave Collins
f8fc23a541 Add negative test for NewBlockFromBytes. 2013-05-30 10:45:38 -05:00
Dave Collins
b90727cc8a Add tests for TxLoc. 2013-05-30 10:30:04 -05:00
Dave Collins
ef6c01960f Initial implementation. 2013-05-28 18:21:26 -05:00