Commit graph

138 commits

Author SHA1 Message Date
Dave Collins
b83f837ad2 Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2016-11-16 15:05:11 -06:00
John C. Vernaleo
5c3e647618 Add gofmt to metalinter.
Fix one issue it caught.

This depends on PR#97
2016-11-16 16:01:47 -05:00
John C. Vernaleo
441bb918ec Modify goclean to use gometalint like btcd 2016-11-16 15:00:41 -06:00
Olaoluwa Osuntokun
c6e1d711da review: fix typos 2016-11-09 11:13:10 -08:00
Olaoluwa Osuntokun
01050a2f82
add support for getblockchaininfo 2016-11-06 16:07:47 -08:00
Dave Collins
2b780d16b0 Improve HTTP error handling.
This modifies the code which handles failed server responses to attempt
to unmarshal the response bytes as a regular JSON-RPC response
regardless of the HTTP status code and, if that fails, return an error
that includes the status code as well as the raw response bytes.

This is being done because some JSON-RPC servers, such as Bitcoin Core,
don't follow the intended HTTP status code meanings.  For example, if
you request a block that doesn't exist, it returns a status code of 500
which is supposed to mean internal server error instead of a standard
200 status code (since the HTTP request itself was successful) along
with the JSON-RPC error response.

The result is that errors from Core will now show up as an actual
RPCError instead of an error with the raw JSON bytes.

This also has the benefit of returning the HTTP status code in the
error for real HTTP failure cases such as 401 authentication failures,
which previously would just be an empty error when used against Core
since it doesn't return the actual response along with the status code
as it should.
2016-09-16 14:52:50 -05:00
David Hill
6e5c0a7904 Fix GetBlockVerbose API.
This changes the GetBlockVersion API to not send a third parameter.
The third parameter is a boolean that expands the transaction data
structures as well.  However, Bitcore Core does not recognize this
feature.

GetBlockVerbose now only takes a hash value.

Users of the GetBlockVerbose(hash, true) must now use
GetBlockVerboseTx(hash).
2016-09-16 12:35:52 -04:00
Dave Collins
982229439a Return wire.MsgBlock from GetBlock(Async).
This modifies the return value of the GetBlock and GetBlockAsync
functions to a raw *wire.MsgBlock instead of *btcutil.Block.

This is being done because a btcutil.Block assumes there is a height
associated with the block and the block height is not part of a raw
serialized block as returned by the underlying non-verbose RPC API
getblock call and thus is not available to populate a btcutil.Block
correctly.

A raw wire.Block correctly matches what the underlying RPC call is
actually returning and thus avoids the confusion that could occur.
2016-09-15 14:06:36 -05:00
David Hill
96ed4cb5b0 Update installation section in README.md
Have users use -u along with go get to pull the latest
dependencies.
2016-09-15 14:25:23 -04:00
David Hill
8ff9623a8c Add API for getblockheader
GetBlockHeader returns the blockheader of the specified blockhash.
GetBlockHeaderVerbose returns the data structure with information about
the blockheader of the specified blockhash.

Fixes #89
2016-09-15 13:39:27 -04:00
Dave Collins
b89c91b9d6 Refactor ntfnstate mutex. (#85)
This refactors the notification state mutex out of the state itself to
the client.  This is being done since the code makes a copy of the
notification state and accesses that copy immutably, and therefore there
is no need for it to have its own mutex.
2016-08-17 13:12:27 -05:00
David Hill
8c8d4453ad travis: Add golang 1.7 and drop golang 1.5 support. (#83) 2016-08-17 13:09:36 -05:00
Dave Collins
2de61b2d9a Manually copy relevant fields in ntfn state copy. (#84)
This makes vet happy by manually copying the notification state fields
during the deep copy instead of copying the entire struct which contains
an embedded mutex.
2016-08-17 12:39:34 -05:00
Waldir Pimenta
f584dbd2e5 add license title (#82)
background: https://github.com/btcsuite/btcd/pull/717
2016-08-11 20:44:30 -05:00
Dave Collins
c39e35318d Update for recent chainhash-related API changes. (#81)
This updates all code to make use of the new chainhash package since the
old wire.ShaHash type and related functions have been removed in favor
of the abstracted package.

Also, while here, rename all variables that included sha in their name
to include hash instead.
2016-08-08 14:16:04 -05:00
Calvin McAnarney
5f19113422 Allow RPC identifiers in E notation (#80) 2016-08-07 22:47:07 -05:00
Dave Collins
64922553b5 TravisCI: Update to latest configurations. (#76)
This updates the Go versions using when running the TravisCI integration
tests to reflect the latest supported Go versions.

Also, 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.

Finally, old tool path is no longer needed, so it has been removed.
2016-04-07 13:26:15 -05:00
Dave Collins
e6e3b66040 Improve error log avoidance on client disconnect.
The existing check to only log errors from websocket connections when
the error is not because the connection is being shutdown only detects
the single case where the remote client was shutdown.

This commit modifies that logic to include when the connection is being
forcibly shutdown via closing the quit channel and when it has been
shutdown from a client side close.
2016-03-10 22:36:52 -06:00
Mawuli Adzoe
73a9dd628d Bump up copyright date to reflect recent fix time. 2016-01-02 14:08:08 -07:00
Mawuli Adzoe
911a735e1f Clarify documentation. Fix typo. 2016-01-02 14:06:55 -07:00
Rune T. Aune
b81555beea Fix "Established connection" log message.
Don't log "Established connection" message on new when
DisableConnectOnNew is set and no connection was actually established.
Do log that same message when Connect() successfully connects.
2015-11-21 14:41:06 -06:00
danda
975536f20f add filteraddrs param to searchrawtransactions 2015-11-16 22:17:19 -08:00
David Hill
c56072017d Add optional locktime parameter to CreateRawTransaction APIs. 2015-10-30 19:34:34 -04:00
Dave Collins
29a2544887 Update SearchRawTransaction calls for latest API.
This commit modifies the SearchRawTransactions and
SearchRawTransactionsVerbose functions to work properly with the latest
searchrawtransactions API in btcd.

In particular, this involves adding a new parameter for the reverse
option which specifies whether or not to include the results in reverse
order.
2015-10-07 12:12:53 -05:00
Mawueli Kofi Adzoe
d06c232f04 Review and fix. Mostly typos. 2015-09-20 11:42:49 +00:00
Josh Rickmar
6f3bc8e57c Add support for the session extension RPC. 2015-09-17 11:32:17 -04:00
Dave Collins
34db203930 Update SearchRawTransaction calls for latest API.
This commit modifies the SearchRawTransactions and
SearchRawTransactionsVerbose functions to work properly with the latest
searchrawtransactions API in btcd.

In particular, this involves changing the return value from
[]*btcjson.TxRawResult to []*btcjson.SearchRawTransactionResult and
adding the additional optional parameter which specifies whether or not
to include information about the previous outputs.
2015-08-26 12:49:14 -05:00
John C. Vernaleo
7cb04ae6db Update example code.
Example code used old api for
OnBlockConnected and OnBlockDisconnected
2015-06-18 16:21:03 -04:00
Josh Rickmar
1831071905 Parse/notify times from block(dis)connected notifications. 2015-06-18 12:14:42 -04:00
Josh Rickmar
77baeb8d79 Fix data race.
This synchronizes access to the (*Client).disconnect channel, which
may change during reconnects.

Fixes #54.
2015-06-15 11:38:25 -04:00
Josh Rickmar
ee3a86c44b Make listsinceblock block hash optional.
Before, calling ListSinceBlock(Async) would create an empty string
from the nil block hash.
2015-06-01 14:41:23 -04:00
Alex Akselrod
9874580e5b Add Generate support in mining.go.
- Create FutureGenerateResult type with Receive() method

- Create GenerateAsync method for Client which returns a
  FutureGenerateResult

- Create Generate method for Client which calls GenerateAsync
  and then calls Receive() on the returned FutureGenerateResult
2015-05-05 16:52:53 -04:00
Dave Collins
b046f36c72 Relicense to the btcsuite developers. 2015-05-01 12:03:51 -05:00
Dave Collins
dd8dc87577 Run goimports -w . 2015-05-01 10:54:58 -05:00
Dave Collins
ce9e8aa264 Update btcjson path import paths to new location. 2015-05-01 10:42:52 -05:00
Albert Puigsech Galicia
b1d5c1b9f6 Add account param on GetNewAddress 2015-04-27 00:44:16 +02:00
Josh Rickmar
13b872259d Remove dependence on btcjson.NewOutPointFromWire. 2015-04-23 14:55:35 -04:00
Alex Akselrod
05f1d6c89a Change parseTxAcceptedNtfnParams to accept a float64 returned by btcd. 2015-04-17 14:20:39 -04:00
Dave Collins
34c87a7340 Add golint to TravisCI builds. 2015-04-05 23:00:36 -05:00
Dave Collins
774eb787a8 Rename HttpPostMode conn param to HTTPPostMode.
This rename is to make golint happy.
2015-04-05 23:00:33 -05:00
Dave Collins
c4bc5220bc Update for recent GetTxOut argument change. 2015-04-05 23:00:29 -05:00
Dave Collins
3daafd5617 Add SearchRawTransactions support. 2015-04-05 23:00:22 -05:00
Javed Khan
04a3ed28f5 Added ImportAddress and ImportPubKey support. 2015-04-05 22:56:54 -05:00
Dave Collins
9ca93b30ad Update to make use of latest version of btcjson.
This commit contains several changes needed to update the client to use
the latest version of btcjson.  In addition, it contains a couple of other
minor changes along the way.

While the underlying changes are quite large, the public API of this
package is still the same, so caller should generally not have to update
their code due to that.  However, the underlying btcjson package API has
changed significantly.  Since this package hides the vast majority of that
from callers, it should not afffect them very much.  However, one area in
particular to watch out for is that the old btcjson.Error is now
btcjson.RPCError, so any callers doing any type assertions there will need
to update.

The following is a summary of the changes:

- The underlying btcjson significantly changed how commands work, so the
  internals of this package have been reworked to be based off of requests
  instead of the now non-existant btcjson.Cmd interface
- Update all call sites of btcjson.New<Foo>Cmd since they can no longer
  error or take varargs
- The ids for each request are part of the request now instead of the
  command to match the new btcjson model and are strict uint64s so type
  assertions are no longer needed (slightly improved efficiency)
- Remove the old temporary workaround for the getbalance command with an
  account of "*" since btcwallet has since been fixed
- Change all instances of JSONToAmount to btcutil.NewAmount since that
  function was removed in favor of btcutil.Amount
- Change all btcws invocations to btcjson since they have been combined
2015-04-05 22:56:39 -05:00
Dave Collins
d45f4c47a2 Update btcws path import paths to new location. 2015-02-19 13:08:29 -06:00
Dave Collins
23ab2bf329 Update btcjson path import paths to new location. 2015-02-19 12:00:51 -06:00
Dave Collins
7d4e1e17f0 Update btcnet path import paths to new location. 2015-02-05 23:39:15 -06:00
Josh Rickmar
87ef953a63 Update Go versions for Travis. 2015-02-05 17:24:42 -05:00
Dave Collins
ed821410cb Update btcwire path import paths to new location. 2015-02-05 15:50:03 -06:00
Javed Khan
20ff0689d8 Added async version for CreateNewAccount, RenameAccount 2015-01-23 17:32:22 +05:30