Commit graph

3509 commits

Author SHA1 Message Date
Dave Collins
6825e68c59 Use uint64 for the request ID instead of int64.
There is no reason for the request ID to be signed.  Pointed out by
@jrick.
2014-05-08 13:05:31 -05:00
Dave Collins
a4978ba4c8 Add tests for the new MsgReject message.
This commit adds a full suite tests for the new reject message added in
protocol version 70002 to bring the overall test coverage of btcwire back
up to 100%.

Closes #9.
2014-05-08 00:17:11 -05:00
Dave Collins
f38e5854c1 Bump protocol version to 70002. 2014-05-08 00:17:11 -05:00
Dave Collins
c2a1444a88 Add new reject command.
This commit adds the new reject protocol message added to recent versions
of the reference implementation.  This message is intended to be used in
response to messages from a remote peer when it is rejected for some
reason such as blocks being rejected due to not conforming to the chain
rules, transactions double spending inputs, and version messages sent
after they're already sent.

This is work toward issue #9.
2014-05-08 00:17:05 -05:00
Dave Collins
f8ec476691 Complete BIP0037 support started by dhill.
- Correct MsgFilterLoad max payload
- Enforce max flag bytes per merkle block
- Improve and finish tests to include testing all error paths
- Add fast paths for BloomUpdateType
- Convert all byte fields to use read/writeVarBytes
- Style and consistency updates
- README.md and doc.go updates

Closes #12.
2014-05-07 23:57:55 -05:00
David Hill
cf754d09bf Initial implementation of BIP0037.
Implement filteradd, filterclear, filterload, and merkleblock.
2014-05-07 23:41:39 -05:00
Dave Collins
a98f5ca38e Cleanup a few nitpicks with recent alert additions.
- Group the new read/writeVarBytes functions together to be consistent
  with the existing code
- Modify the comments on the new read/writeVarBytes to be a little more
  descriptive and consistent with existing code
- Use "test payload" for field name in the tests for the
  read/writeVarBytes functions which is more accurate
- Remove reserved param from NewAlert since there is no point is having
  the caller deal with a reserved param
- Various comment tweaks for clarity and consistency
- Use camel case for fuction params for consistency
- Move the NewAlert and NewAlertFromPayload functions after the receiver
  definitions for code layout consistency

Closes #11.
2014-05-07 19:41:04 -05:00
Dave Collins
47e65634a7 Use btcd pver instead of wire pver in RPC encoding.
Along the same lines as the previous commit, the RPCs that return
serialized data structures should use the max protocol version btcd
supports as opposed to the maximum protocol version etcwire supports.
2014-05-07 11:33:32 -05:00
Dave Collins
01183c4eca Update for recent notifyspent changes.
Closes #2.
2014-05-07 11:23:48 -05:00
Dave Collins
7c552136bc Move Disconnected next to Disconnect func. 2014-05-07 11:23:35 -05:00
Dave Collins
1122a8a9cb Remove leftover testing sleep. 2014-05-07 11:23:27 -05:00
Dave Collins
2f7cb64652 Add CONTRIBUTORS file. 2014-05-07 11:23:16 -05:00
GeertJohan
0cc22e1134 Make btcrpcclient use the new and consistent reply types. 2014-05-07 11:23:00 -05:00
Dave Collins
831d0aeb90 Add support for getwork submit. 2014-05-07 11:22:38 -05:00
Dave Collins
fa7f670160 Add link to examples in README.md. 2014-05-07 11:22:12 -05:00
Dave Collins
43ca7c0f3c Add a couple of examples. 2014-05-07 11:21:36 -05:00
Dave Collins
cf409a8d79 Disconnect client on shutdown. 2014-05-07 11:19:30 -05:00
Dave Collins
e3f130ade5 Initial commit. 2014-05-07 11:14:39 -05:00
Dave Collins
fd025a7368 Use btcd pver instead of wire pver in getinfo RPC.
The getinfo RPC should return the max protocol version btcd supports as
opposed to the maximum protocol version btcwire supports.  Currently they
are both the same value, so there is no issue.  However, they will not
always be the same.
2014-05-07 10:30:58 -05:00
Owain G. Ainsworth
6e2ba386dd Add an entypoint to sign and verify a transaction input.
This handles merging in of previous scripts, also. Add tests for the important
paths. ok @davecgh
2014-05-07 16:05:55 +01:00
Josh Rickmar
e12673df11 Switch notifyspent to take an array of outpoints.
This allows a wallet process to request spent notifications for many
outpoints at once, rather than creating separate requests for each.
2014-05-06 10:49:46 -05:00
Josh Rickmar
a20fd1ab2c Modify notifyspent handler to take multiple outpoints. 2014-05-06 08:30:36 -05:00
Dave Collins
b993af04b9 Correct misspelled contributor name. 2014-05-05 22:15:37 -05:00
Dave Collins
67abae0dbf Add CONTRIBUTORS file.
Since the github contributors list only lasts for a period of time, it's
better to also maintain a contributors list in the repository rather than
solely relying on github.
2014-05-05 18:29:31 -05:00
GeertJohan
9965019da0 Return pointers to structs
Update doc.go to use proper btcjson result type

Return pointers to structs

Update doc.go to use proper btcjson result type
2014-05-05 17:18:22 -04:00
Javed Khan
bdec7f8abb Implemented alert message serialize/deserialize
* Introduced common methods readVarBytes, writeVarBytes.
* Added type Alert which knows how to deserialize
the serialized payload and also serialize itself back.
* Updated MsgAlert BtcEncode/BtcDecode methods to handle the
new Alert.
* Sane limits are placed on variable length fields like SetCancel
and SetSubVer
2014-05-05 23:12:28 +05:30
John C. Vernaleo
a5169bd880 Remove extraneous character that got added to comment. 2014-05-05 09:08:45 -04:00
Geert-Johan Riemer
94451d7a9c Changed strings.Contains(?, "{") to bytes.IndexOf(?, '{')>-1 2014-05-05 13:28:48 +02:00
Dave Collins
a4a79387cc Add support for getmininginfo RPC.
Closes #126.
2014-05-04 14:34:25 -05:00
GeertJohan
4fb5272063 Return pointer to TxRawResult and use bytes.IndexByte instead of Strings.Contains 2014-05-04 17:12:32 +02:00
Dave Collins
4202bf2e93 Make TestNet field name consistent.
The commit makes the TestNet field in GetMiningInfoResult consistent with
InfoResult.
2014-05-03 23:38:47 -05:00
Dave Collins
4178c36dc3 Populate connections field in getinfo RPC.
The JSON object returned from the getinfo RPC contains a connection count
field that was not being populated.
2014-05-03 14:07:08 -05:00
Dave Collins
d443b48994 Improve InfoResult.
This commit modifies InfoResult to remove all of the omitempty tags since
the fields should be present in the marshalled JSON regardless of them
being zero values or not.
2014-05-03 14:05:37 -05:00
Dave Collins
d0a2506a96 Improve GetMiningInfoResult.
This commit modifies the types of the GetMiningInfoResult to better match
their underlying types.  While the information was all available and
accurate, it's nicer to treat numeric values as proper types instead of
all float64s.

Also, a new networkhashps field has been added for compatibility with the
reference implementation.
2014-05-03 12:28:04 -05:00
Dave Collins
0a7543516c Update block manager chainstate for all sources.
This commit updates the block manager's local chain state when a block
processed by submitting it directly to the block manager as opposed to
only when it comes from the network.

Also, it modifies the submitblock RPC to use the concurrent safe block
manager process block instead of the unsafe btcchain version.

The combination of these two fixes ensure the internal block manager chain
state is properly synced with the actual btcchain state regardless of how
blocks are added.
2014-05-02 23:02:10 -05:00
Dave Collins
92ca0e92c0 Implement getwork RPC.
This commit adds full support for the getwork RPC which can be used to
support external mining through applications such as cgminer.

Closes #125.
2014-05-01 10:52:28 -05:00
Dave Collins
a38f93bf06 use fastsha256 in rpcwebsocket.go.
While this is not performance critical code, there is no need to import
another package into the final binary.
2014-05-01 10:36:41 -05:00
David Hill
76e8fa9766 Reduce OP_RETURN standard relay bytes to 40.
This matches commit 8175c790eb12f0b0ca3197895a6d1d479b340b67 of
the reference software.
2014-05-01 09:42:15 -04:00
David Hill
d72da506c5 Some UPNP devices require the protocol to be uppercase.
This matches what miniupnpc sends.
2014-04-26 14:46:17 -04:00
Josh Rickmar
bba0a0482d Include P2PK outputs for rescanned P2PKH addrs.
This change fixes rescan to include transactions that pay to the
pubkey for a rescanned pubkey hash address.  This behavior was lost
when the rescan was optimized for specific types of the
btcutil.Address interface.

ok @davecgh
2014-04-25 10:33:58 -05:00
Dave Collins
27082ace79 Correct error handling on createMarshalledReply.
This commit correctly sets the error in the marhsalled reply if it is
already a *btcjson.Error.  Previously it would only set the error if it
was not of that type which led to some RPC results showing no error when
they actually had one.
2014-04-25 02:51:57 -05:00
Josh Rickmar
3fd5904859 Always return unparsableCmds when possible.
This change overrides the cmd return value of custom registered
methods to always return an unparsableCmd if the marshaling as a
JSON-RPC request succeeded, but the request was an invalid structure
for the custom method.
2014-04-25 01:04:24 -05:00
Dave Collins
bdaa5f7f8d Set RPC content type to applicaton/json.
Closes #121.
2014-04-24 23:20:13 -05:00
David Hill
765dbb443d Fix a bug in fetching the XML URL.
In Discover, the reponse was lowercased for comparison.  However,
this caused a 404 - Not found when fetching the url provided by
the location header if the url contained uppercase.

ok @owainga
2014-04-23 19:10:53 -04:00
Dave Collins
4595c9d90d Add listreceivedbyaccount concrete result.
ok @jcvernaleo.
2014-04-23 15:47:25 -05:00
Owain G. Ainsworth
4d44eeb877 Move to protecting all peer stats by the same mutex.
In practise the races caused by not protecting these quite simply didn't
matter, they couldn't actually cause any damage whatsoever. However, I
am sick of hearing about these essentially false positivies whenever
someone runs the race detector (yes, i know that race detector has no
false positives but this was effectively harmess).

verified to shut the detector up by dhill.
2014-04-23 17:38:14 +01:00
Owain G. Ainsworth
88ea84cf12 Addrman: only shuffle as much as we need.
If we switch the knuth shuffle to the version that swaps the element
with an element between it and the end of the array, then once we have
gotten to the amount of elements we need they won't change later in the
algorithm. Terminating here means that we only do 23% of the length of
the array worth of random swaps at most.
2014-04-23 17:38:13 +01:00
Owain G. Ainsworth
ec8d0e582c Attempt to create less garbage for getaddr calls.
We make ka.na immutable in the address manager. Whenever we would update
the structure we replace it with a new copy. This beats making a copy of
all addresses once per getaddr command (max is just over 23000 we would
be copying, compared to at most 2000 copies on a new getaddr that has
all addresses we know with newer dates).
2014-04-23 17:38:13 +01:00
David Hill
08377c21e2 Lower maxKnownInventory from 20000 to 1000.
ok @davecgh
2014-04-23 07:48:52 -04:00
David Hill
8a322e4792 Bypass rate limiter for sendrawtransaction.
ok @davecgh
2014-04-23 07:45:56 -04:00