Commit graph

2167 commits

Author SHA1 Message Date
Dave Collins
1ff465ae88 Remove RegisterCustomCmdGenerator.
This is no longer required since the RawCmd params now consist of a slice
of raw JSON messages which the registered parser can directly unmarshal.

ok @jcvernaleo
2014-04-11 09:38:15 -05:00
Dave Collins
fc07555ad3 Update for latest btcjson API changes.
This commit modifies the AllVerboseTxNtfn command to use a parser along
with the standard btcjson.RegisterCustomCmd instead of the now removed
RegisterCustomCmdGenerator function.  This is possible due to the recent
changes that defers the unmarshalling of the parameters of a RawCmd to the
parser.
2014-04-11 09:20:25 -05:00
Dave Collins
6f08ca8a8a Correct unmarshal for GetAddressBalanceCmd.
The unmarshaller for the GetAddressBalanceCmd was calling the wrong parse
function.  It wasn't caught by the tests because the error on
UnmarshalJSON was being ignored, so this commit also updates the tests to check the
error.
2014-04-11 09:04:53 -05:00
Dave Collins
0512ddd8f8 Correct ListTransactionsResult.
This commit tweaks the ListTransactions result a bit so it is compatible
with the reference implementation.
2014-04-11 08:45:01 -05:00
David Hill
75a237bc0d Add support for GetTransactionResult.
ok @jcvernaleo
2014-04-11 09:39:08 -04:00
Dave Collins
d211c4c6c8 Correct TxID JSON key of ListTransactionsResult. 2014-04-10 22:26:44 -05:00
Josh Rickmar
42061ebf87 Update for btcws API change. 2014-04-10 21:12:40 -05:00
Dave Collins
a0bfde8db0 Update btcctl for latest btcjson changes. 2014-04-10 21:12:40 -05:00
Dave Collins
bfcd7f6790 Update for latest btcjson.RawCmd changes.
This commit modifies all of the commands and notifications to work
properly with the latest btcjson.RawCmd Params field changes.

This new approach is superior to the old method of using a []interface{}
because it means that each parameter is now unmarshalled into the expected
concrete type directly instead of whatever it happens to be in the JSON.

Since it is now preferred to use full blown structs for individual
parameters, the RescanCmd type has been changed to use a new OutPoint
that can be used directly for marshalling and unmarshalling instead of a
*btcwire.OutPoint.

Also, all of the MarshalJSON functions now make use of the new
btcjson.NewRawCmd function rather than repeating the same common field
over and over and all of the MarshalJSON, UnmarshalJSON, and parseX
functions have been made more consistent.

ok @jrick
2014-04-10 21:10:16 -05:00
Dave Collins
016e69cd51 Convert RawCmd to use raw messages for params.
This commit modifies the RawCmd type to use a slice of json.RawMessages so
that unmarshalling each individual parameter can be deferred to the
handler for the command.

This is superior to the old method of using a []interface{} because it
means that each parameter is now unmarshalled into the expected concrete
type directly instead of whatever it happens to be in the JSON.  Due to
this, the old behavior where every number was unmarshlled as a float64 and
converted to the appropriate final type, which could lead to odd behavior
when going through marshal/unmarshal cycles, has been eliminated.  This
change also means each individual parameter can now be full blown structs
(JSON objects) that marshal and unmarshal themselves which greatly
simplifies complex parameters and removes the need for additional and
error prone code.

This commit contains a lot of changes because every command needed its
MarshalJSON and UnmarshalJSON methods updated to support the new
mechanism.  As a part of changing these functions, a new common creation
function for the the RawCmd struct was added to avoid the previous
duplication of the common fields.  Also, rather than repeating the method
string in each MarshJSON functon, it makes use of cmd.Method().

Finally, some of the error messages were incorrect and have been corrected
as well as made consistent.

ok @jcvernaleo, @jrick, @owainga
2014-04-10 20:59:46 -05:00
Josh Rickmar
1fd5cd2742 Use btcws.GetBestBlockResult. 2014-04-10 20:03:54 -05:00
Josh Rickmar
b77de52d3d Move GetBestBlockResult struct from btcwallet. 2014-04-10 16:42:28 -05:00
David Hill
8a503c6148 Add addrlocal to GetPeerInfoResult.
ok @davecgh
2014-04-09 22:39:25 -04:00
Owain G. Ainsworth
03dd134305 adapt for btcec changes. 2014-04-09 19:30:59 +01:00
Owain G. Ainsworth
e841a2e999 Make ParsePubkey reutrn a *btcec.PublicKey
Provide a fucntion on public key to get the ecdsa type without knowing
internals.
2014-04-09 19:27:56 +01:00
David Hill
50473f6ed3 Add support for CreateMultiSigResult.
ok @jcvernaleo
2014-04-09 13:45:55 -04:00
Dave Collins
dd926bfdf9 Add support for ListTransactionsResult.
ok @jcvernaleo.
2014-04-09 09:07:53 -05:00
David Hill
805ce37d31 Use the stack for most known sizes.
By using the stack for known sizes, there is less pressure on the
garbage collector.
2014-04-08 15:55:21 -04:00
Dave Collins
7c39a02ed1 Correct ReadResultCmd for getaddednodeinfo.
The returned result was previously a []interface{} instead of a
[]GetAddedNodeInfoResult.  This commit resolves that issue.

ok @jcvernaleo
2014-04-08 07:57:31 -05:00
David Hill
384a535f49 addmultisigaddress support for btcctl 2014-04-07 14:45:42 -04:00
David Hill
b0242a8793 Add missing fields to ValidateAddressResult structure
ok @jrick
2014-04-07 14:07:38 -04:00
Dave Collins
f0581b565c Correct two more comments in block bytes breakdown. 2014-04-06 14:14:48 -05:00
Dave Collins
0e1f8fda6d Correct some comments in block bytes breakdown. 2014-04-05 21:00:28 -05:00
Dave Collins
4fce6d1476 Sync latest script tests to bitcoind test suite. 2014-04-03 23:18:52 -05:00
Dave Collins
f529a37123 Add tests for doing math on 5-byte ints.
This commit addes a couple of tests to ensure performing math operations
on a 5-byte integer, even if the result is a 4-byte integer, is considered
invalid.
2014-04-03 17:13:44 -05:00
David Hill
1b56cb291f add new dns seed, seed.bitnodes.io 2014-04-01 14:58:40 -04:00
Dave Collins
937374c95a Cleanup and finish relay transaction work.
- Coalesce the new bytes into the max message size constant to stay
  consistent
- Correct optional relay tx field handling
- Rename the relay transactions field to DisableRelayTx so the zero value
  of false has the correct default behavior
- Add tests for new bool fast paths in read/writeElement
- Stay consistent with version order in tests
- Add a single entry to TestVersionWire to test the new functionality
  instead of adding a whole new TextVersionRelayTx function.
- Use BIP0037 in tests instead of hard coding 70001
- Nuke XXX that 70001 is different since this is handled now
- Fix and cleanup some comments
- Update test coverage report
2014-03-31 11:35:36 -05:00
David Hill
e9a18fb14c Support RelayTx param in ver message for 70001+.
This commit adds support for the version message RelayTx parameter for
protocol version 70001+ as added by BIP0037.
2014-03-30 23:43:18 -05:00
Dave Collins
8721348051 Add tests for optional message fields.
Since fields of a version message after the AddrMe field are optional,
this commit adds a series of tests which ensure parsing version messages
which omit each of the optional fields works properly.
2014-03-30 23:39:28 -05:00
Dave Collins
c917899303 Allow optional fields in MsgVersion decode.
This commit modifies the MsgVersion.BtcDecode function to match the
behavior where fields after the first address field (AddrYou) are optional
and only read if the buffer contains remaining bytes.

Unfortunately this means the reader for MsgVersion.BtcDecode must be a
*bytes.Buffer or an error is returned.  This is not an issue for the vast
majority of cases since all of the message reading code which is the main
way messages are read is already using a *bytes.Buffer, however, this
change might affect external callers if they are doing something special
with custom readers.

Fixes #14.
2014-03-30 15:56:52 -05:00
Dave Collins
dfb2c149f6 Finish uncompleted comments in fixedIO_test.go. 2014-03-30 12:19:17 -05:00
Dave Collins
886281993a Use separate max protocol version.
This commit modifies peers to use a max protocol version that is specified
as a constant in the peer code as opposed to the btcwire.ProtocolVersion
constant.

This allows btcwire to be updated to support new protocol versions without
causing peers to claim they support a protocol version which they actually
don't.
2014-03-28 17:42:59 -05:00
Dave Collins
444d05eafc Run go fmt. 2014-03-28 14:49:48 -05:00
Dave Collins
958ea38fdd Export CheckProofOfWork function. 2014-03-28 14:32:12 -05:00
Dave Collins
38a694e309 Correct maturity debug print.
This commit corrects the debug log print to use the hash of referenced
coinbase transaction instead of the hash of the current transation when a
coinbase maturity is not met.
2014-03-28 13:09:53 -05:00
Josh Rickmar
d702e37141 Update websocket clients with rescan progress.
This change periodically (about every 10 seconds) notifies the
connected websocket client of the height of the last processed block
as part of the rescan.  This enables clients to listen for the
notification and keep track of how much progress a rescan has made
even without any results being found.  If the websocket connection is
lost during the rescan, on reconnect, clients may safely start over at
the last notified height.
2014-03-28 11:27:29 -05:00
Josh Rickmar
97439fa822 Implement rescanprogress notification. 2014-03-28 11:25:32 -05:00
Owain G. Ainsworth
5932cd5385 comments - shorten, simplify and make 80cols. 2014-03-28 00:19:53 +00:00
Owain G. Ainsworth
b7622c4e6c Correct type capitalisation in comment. 2014-03-28 00:03:45 +00:00
Owain G. Ainsworth
613f61ec59 simplify comment and fit into 80 cols. 2014-03-28 00:02:57 +00:00
Owain G. Ainsworth
3a03a03a92 Kill duff newline. 2014-03-28 00:01:46 +00:00
Dave Collins
35936c1f01 Don't discuss internals in exported func comments.
This commit cleans up and moves a couple of comments in the recent pull
request which implements a rebroadcast handler (#114) in order to avoid
discussing internal state in the exported function comment.

How a function actually accomplishes the stated functionality is not
something that a caller is concerned with.  The details about the internal
state are better handled with comments inside the function body.
2014-03-27 14:09:34 -05:00
mydesktop
ab002c90cc Implement a rebroadcast handler.
This commit implements a rebroadcast handler which deals with
rebroadcasting inventory at a random time interval between 0 and 30
minutes.  It then uses the new rebroadcast logic to ensure transactions
which were submitted via the sendrawtransaction RPC are rebroadcast until
they make it into a block.

Closes #99.
2014-03-27 14:09:33 -05:00
Owain G. Ainsworth
d0a4086e29 Add an api to get a pubkey and privkey from a privkey byte string.
ok and some tweaks from @jrick.
2014-03-25 15:10:58 +00:00
David Hill
5fcdfb040a add importwallet to btcctl 2014-03-24 15:52:40 -04:00
Dave Collins
2ae7cb8ee2 Update handleGetBlock to not use deprecated func.
Rather than using the deprecated TxShas function on a btcutil.Block,
convert handleGetBlock to use the newer preferred method of ranging over
the Transactions to obtain the cached hash of each transaction.

This is a little more efficient since it can avoid creating and caching an
extra slice to keep the hashes in addition to having the hash cached with
each transaction.
2014-03-24 13:19:32 -05:00
Dave Collins
67ebfa0e80 Update checkBIP0030 to not use deprecated function.
Rather than using the deprecated TxShas function on a btcutil.Block,
convert the checkBIP0030 to use the newer preferred method of ranging over
the Transactions to obtain the cached hash of each transaction.

This is also a little more efficient since it can avoid creating and
caching an extra slice to keep the hashes in addition to having the hash
cached with each transaction.
2014-03-24 13:15:16 -05:00
mydesktop
a55ea104c7 Bugfix for issue #101. 2014-03-24 12:28:54 -05:00
Dave Collins
049a545427 Switch RPC server to use fastsha256 package. 2014-03-23 00:49:37 -05:00
Dave Collins
e98db34ef2 Add infrastructure for creating a block template.
This commit adds a new function named NewBlockTemplate along with
supporting infrastructure which is part of the core functionality needed
to support mining.

In particular the function creates a new block template which contains a
fully populated block with a zero nonce that is ready to be solved as well
as additional information regarding the fees and number of signature
operations for each transaction included in the block.  The specific
transaction selection logic mirrors the reference implementation.

Various cleanup, optimizations, and comment suggestions provided by
@owainga.  Also contains some naming suggestions and comment fixes from
@flammit.
2014-03-22 11:47:38 -05:00