Commit graph

2973 commits

Author SHA1 Message Date
Dario Nieuwenhuis
0190c349aa Add reverse order option to searchrawtransactions rpc 2015-10-08 16:31:39 +02: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
David Hill
ce22159fb2 txscript: Change makeScriptNum to take a length argument
While current existing numeric opcodes are limited to 4 bytes, new
opcodes may need different limits.

This mimics Bitcoin Core commit 99088d60d8a7747c6d1a7fd5d8cd388be1b3e138
2015-10-05 19:48:55 -04:00
Dave Collins
e4c053e504 rpcserver: Optimize JSON raw tx input list create.
This commit optimizes the createVinList function which is used to
generate the JSON list of transaction inputs.  It also makes it more
consistent with the createVinListPrevOut function.

In particular, it entails the following changes:
- Only do a single coinbase check and return right away instead of
  checking multiple times inside the loop over the inputs
- Use a pointer for populating the details of each entry to avoid
  multiple unnecessary array lookups and bounds checks
- Group all fields that populate the entry for better readability
2015-09-30 20:52:42 -05:00
David Hill
c9ee3d9c5e wire: Implement SFNodeBloom (BIP0111).
SFNodeBloom is a new service flag that a node is required to use to
indicate that it supports bloom filtering.  This includes a protocol
version bump to 70011 and a wire version bump to 0.3.0.

btcd:
The SFNodeBloom flag is set by default.  A new configuration option
--nopeerbloomfilters has been added to to disable bloom filtering.

Any node advertising a version greater than or equal to 70011 that
attempts to use bloom filtering will be disconnected if bloom
filtering is disabled.

This mimics Bitcoin Core commit afb0ccaf9c9e4e8fac7db3564c4e19c9218c6b03
2015-09-28 16:25:44 -04:00
Dave Collins
064cc8e7c3 txscript: Optimize DisasmString function.
This commit modifies the DisasmString function to use a bytes buffer for
constructing the disassembled string instead of naive string
concatenation.  This makes a huge difference when disassembling scripts
with large numbers of opcodes.
2015-09-28 12:57:53 -05:00
Dave Collins
79aac01b02 wire: Reject non-canonically encoded varints.
The Bitcoin wire protocol includes several fields with their lengths
encoded according to a variable length integer encoding scheme that does
not enforce a unique encoding for all numbers.

This can lead to a situation where deserializing and re-serializing the
same data can result in different bytes.  There are no currently known
issues due to this, but it is safer to reject such subtle differences as
they could potentially lead to exploits.

Consequently, this commit modifies the varint decoding function to error
when the value is not canonically encoded which effectively means that
all messages with varints that are not canonically encoded will now be
rejected.  This will not cause issues with old client versions in
regards to blocks and transactions since the data is deserialized into
memory and then reserialized before being relayed thereby effectively
erasing any non-canonical encodings.

Also, new tests have been added to ensure non-canonical encodings are
properly rejected and exercise the new code, and the default user agent
version for wire has been bumped to version 0.2.1 to differentiate the
new behavior.

The equivalent logic was implemented in Bitcoin Core by PR 2884.
2015-09-26 16:22:31 -05:00
Mawuli Adzoe
03d423cebf Review and fix docs. 2015-09-24 13:12:04 +00:00
Josh Rickmar
5983c9b98e Allow the session RPC for limited (read-only) clients. 2015-09-23 16:53:07 -04:00
Mawueli Kofi Adzoe
d06c232f04 Review and fix. Mostly typos. 2015-09-20 11:42:49 +00:00
Josh Rickmar
3c9d18d641 Add a websocket session RPC. 2015-09-17 12:18:15 -04:00
Josh Rickmar
6ac46f9e5f Remove mixed newlines in documentation. 2015-09-17 12:18:15 -04:00
Dave Collins
e6d5c163d5 Update TravisCI to test against golang 1.5.1.
Also, modify the goclean.sh script to quote the test command arguments
and update the vet test to exclude recent false positives.
2015-09-17 11:01:34 -05:00
Josh Rickmar
6f3bc8e57c Add support for the session extension RPC. 2015-09-17 11:32:17 -04:00
Dario Nieuwenhuis
1806557d14 Fix skip not being applied to mempool txns in searchrawtransactions 2015-09-08 15:17:43 +02:00
Dave Collins
0f9fc42a06 Output error to stderr if the limits can't be set. 2015-09-02 17:13:01 -05:00
David Hill
4e34a462eb Add new seed seed.bitcoin.jonasschnelli.ch.
Drop seed seeds.bitcoin.open-nodes.org.
2015-08-31 09:45:54 -04:00
Dave Collins
83bcfcb2ca Improve mru inventory map and test cov to 100%.
This commit improves the most-recently used inventory map human readable
string to only show the inventory vectors. and adds tests for the entire
structure to bring its coverage to 100%.

In addition, removes the type assertion check in the Add function since
the internal inventory list is only managed by the type itself and the
tests would now catch any mistakes in the type of entries in the list.
2015-08-29 15:43:42 -05: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
danda
43774fe6bb adds optional prevOut section to vin for searchrawtransactions api. See https://github.com/btcsuite/btcd/issues/485 2015-08-23 09:58:03 -07:00
David Hill
2441120b55 Recognize the BIP0064 service bit.
This does not add BIP0064 (getutxos/utxos) support to btcd.
2015-08-22 09:11:05 -04:00
Dario Nieuwenhuis
9c039f5fe4 Fix longpoll getblocktemplate not getting notified if a block is pushed via submitblock 2015-08-21 16:46:06 +02:00
Dave Collins
0280fa0264 Convert block heights to int32.
This commit converts all block height references to int32 instead of
int64.  The current target block production rate is 10 mins per block
which means it will take roughly 40,800 years to reach the maximum
height an int32 affords.  Even if the target rate were lowered to one
block per minute, it would still take roughly another 4,080 years to
reach the maximum.

In the mean time, there is no reason to use a larger type which results
in higher memory and disk space usage.  However, for now, in order to
avoid having to reserialize a bunch of database information, the heights
are still serialized to the database as 8-byte uint64s.

This is being mainly being done in preparation for further upcoming
infrastructure changes which will use the smaller and more efficient
4-byte serialization in the database as well.
2015-08-11 11:13:17 -05:00
Jonathan Gillham
27f7f82355 txscript: Make error strings idiomatic. 2015-08-09 14:06:36 +01:00
David Hill
3331d6098b txscript: New function IsUnspendable
IsUnspendable takes a public key script and returns whether it is
spendable.

Additionally, hook this into the mempool isDust function, since
unspendable outputs can't be spent.

This mimics Bitcoin Core commit 0aad1f13b2430165062bf9436036c1222a8724da
2015-08-03 10:10:23 -04:00
Jonathan Gillham
b448a2b6bc Make PubKey variable names consistent. 2015-08-02 22:21:27 +01:00
Dave Collins
88b15e74f0 docs: Add info describing model commit messages. 2015-07-30 13:14:42 -05:00
Daniel Krawisz
2dc8687728 Fix incorrect ip connection attempt logic.
The comment says "only allow recent nodes (10mins) after we failed 30 times",
but the server actually did the opposite and allowed only recent nodes before
30 failed connection attempts. This corrects the server's behavior.
2015-07-30 08:30:31 -05:00
Dave Collins
506fc9fb94 rpcserver: Allow tx result creation without block.
This commit modifies the createTxRawResult code path along with callers
to work with block headers as opposed to btcutil.Blocks.  This in turn
allows the code in handleGetRawTransaction and
handleSearchRawTransactions to perform a much cheaper block header load
as opposed to a full block load.

While here, also very slightly optimize the createVinList function to
avoid creating a util.Tx wrapper and to take advantage of the
btcutil.Amount type added after the function was originally written
2015-07-28 18:44:30 -05:00
Dave Collins
f891391f7c peer: Optimize merkle block handling.
This commit updates the merkle block handling to for the latest changes
to the btcutil API and optimizes it along the way.

Previously, the code was inefficiently reloading the transactions for
the matched hashes from the database instead of simply pulling them from
the full block that was used to create the merkle block.
2015-07-28 10:38:08 -05:00
Jonathan Gillham
f8167ab36f txscript: Remove unneeded signature hash copies
These copies were likely left over from when MsgTx had no deep copy
functionality.
2015-07-28 11:31:43 +01:00
Dave Collins
51fca61707 wire: Remove duplicate tx error path tests. 2015-07-26 13:05:09 -05:00
drazisil
b1606447b5 added getwalletinfo cmd 2015-07-24 13:56:24 -04:00
Dave Collins
5ab891177b docs: Remove outdated btcws link from README.md. 2015-07-24 09:24:32 -05:00
David Hill
a6c79c7a91 Implement getblockheader RPC.
This mimics Bitcoin Core commit 076badb60f33f0c32b035de220ca14c52a423a2a
2015-07-23 15:22:17 -04:00
David Hill
eb4ad09598 Implmement BlockHeader BtcEncode/BtcDecode.
At the current time, there is no difference between the wire encoding
at protocol version 0 and the stable long-term storage format.  These
methods are simply for consistency with the other types.
2015-07-22 11:34:18 -04:00
Dave Collins
3d89b56b27 wire: Update tests to force error in tx lock time.
This commit updates the wire tests for transactions which force
serialization and deserialization errors to force an error in the the
transaction lock time path.

This brings the wire test coverage back up to 100%.
2015-07-22 09:26:52 -05:00
Josh Rickmar
6f1272e767 btcjson: Add spendable to listunspent result. 2015-07-21 13:45:42 -04:00
David Hill
8a4a875e9d Ignore getheaders requests if not synced.
This mimics Bitcoin Core commit a1ba0778dd3c784046dea334e5d39f37eca264f7
2015-07-20 14:16:55 -04:00
Dave Collins
1ddf8e8edf Correct reconnect handling for persistent peers.
This commit correctly replaces persistent peers that are being retried in
the list of persistent peers so it will continue to be retried as
intended.

Also, limit the maximum retry interval for persistent peers to 5 minutes.

Fixes #463.
2015-07-20 12:35:44 -05:00
Dave Collins
7246b9b933 docs: Correct JSON-RPC API overview return links.
This commit corrects the JSON-RPC API doc return to overview links for
the Websocket Extension Method Details section.
2015-07-20 12:32:40 -05:00
Bruno
4335ce828c switch maxDataCarrierSize to public const 2015-07-20 14:26:05 +08:00
Jonathan Gillham
8fcea82a56 Fixed erroneous txscript.KeyClosure documentation. 2015-07-19 16:15:29 +01:00
David Hill
e13b4febec Document limitfreerelay and norelaypriority options. 2015-07-13 12:52:17 -04:00
David Hill
9ffd96bf51 Revert "Move IsFinalizedTransaction to txscript."
This reverts commit 17da2ba7fa.

This was done prematurely.  This will be revisited when a code
restructure is more urgent.
2015-06-29 11:12:35 -04:00
David Hill
17da2ba7fa Move IsFinalizedTransaction to txscript.
This change moves IsFinalizedTransaction to txscript and also changes
the first argument to take a wire.MsgTx instead of btcutil.Tx.  This
is needed for an upcoming diff in which txscript will require
IsFinalizedTransaction and we do not want to import the btcd/blockchain.
2015-06-28 09:43:14 -04:00
David Hill
bb8333a739 Use NewMsgInvSizeHint when we know the size.
When trickling inv's to peers, allocate for the number of inv's
in the queue instead of the default 1000.  This should save on
memory.
2015-06-27 11:07:36 -04:00
David Hill
527f585463 txscript: Move lockTimeThreshold to txscript
Move lockTimeThreshold to txscript and export it.  This is a
consensus value which txscript will need in an upcoming diff.
2015-06-26 10:55:22 -04:00
David Hill
7cfa843832 Support getmempoolinfo. 2015-06-24 20:34:56 -04: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