Commit graph

56 commits

Author SHA1 Message Date
Olaoluwa Osuntokun 8b130ec4ea btcjson: update RPC calls to return segwit related data 2017-08-13 23:17:40 -05:00
Dave Collins 9918e2a561
multi: Update markdown files for GFM changes.
The github markdown interpreter has been changed such that it no longer
allows spaces in between the brackets and parenthesis of links and now
requires a newline in between anchors and other formatting.  This
updates all of the markdown files accordingly.

While here, it also corrects a couple of inconsistencies in some of the
README.md files.
2017-05-25 12:06:16 -05:00
esemplastic 2a01456189 Fix docs/README.md
Invalid tokens: github had made some changes the past months, the old style is not rendering at all, so I fixed that for you. 

Other contributors can do the same for all of the project's documents.

Thanks.
2017-05-07 22:04:30 -05:00
Alex 03a8bf2eb4 btcjson/docs: add rescanblocks command backported from dcrd 2017-01-27 15:32:15 -07:00
Alex 5c689c8b77 btcjson/docs: add loadtxfilter command backported from dcrd 2017-01-27 15:32:15 -07:00
David Hill ab0f30c00d mining: drop getwork support.
Since the Midstate is no longer needed, switch to using
crypto/sha256.
2017-01-11 13:51:57 -05:00
Alex 7c44b6472f Port getheaders JSON-RPC command from dcrd 2017-01-10 19:11:18 -07:00
Alex 9f962b60d6 Add version command to JSON-RPC API for API versioning 2016-12-22 14:48:53 -05:00
David de Kloet 34b9721494 docs: Clarify model commit message summary
Add a paragraph about prefixing commit message summaries with the
package/subsystem that they're changing to
code_contribution_guidelines.md.
2016-11-21 09:02:40 -06:00
Steven Roose 7cc630b335 docs: Change error in heading 2016-11-12 14:52:47 +01:00
Dave Collins e90b0c967f
docs: Add mempool entry to developer tools section. 2016-10-23 20:47:05 -05:00
Dave Collins b8df516b4b
docs: Add fullblocktests entry and make consistent. 2016-10-23 13:34:14 -05:00
Javed Khan bff2ba70fd connmgr: Refactor connection management into pkg
This commit introduces package connmgr which contains connection
management related functionality.

The following is an overview of the features the package provides:

- Maintain fixed number of outbound connections
- Optional connect-only mode
- Retry persistent connections with increasing back-off
- Source peers from DNS seeds
- Use Tor to resolve DNS
- Dynamic ban scores
- Test coverage

In addition, btcd has been refactored to make use of the new package by
extending the connection manager to work with the server to source and
maintain peer connections. The following is a broad overview of the
changes to integrate the package:

- Simplify peer state by removing pending, retry peers
- Refactor to remove retries which are now handled by connmgr
- Use callback to add addresses sourced from the  DNS seed

Finally the following connection-related things have been improved as a
part of this refactor:

- Fixes 100% cpu usage when network is down (#129)
- Fixes issues with max peers (#577)
- Simplify outbound peer connections management
2016-10-22 01:11:57 -05:00
Dave Collins f21410e47c
blockchain: Add block validation infrastructure.
This adds a full-blown testing infrastructure in order to test consensus
validation rules.  It is built around the idea of dynamically generating
full blocks that target specific rules linked together to form a block
chain.  In order to properly test the rules, each test instance starts
with a valid block that is then modified in the specific way needed to
test a specific rule.

Blocks which exercise following rules have been added for this initial
version.  These tests were largely ported from the original Java-based
'official' block acceptance tests as well as some additional tests
available in the Core python port.  It is expected that further tests
can be added over time as consensus rules change.

* Enough valid blocks to have a stable base of mature coinbases to spend
  for futher tests
* Basic forking and chain reorganization
* Double spends on forks
* Too much proof-of-work coinbase (extending main chain, in block that
  forces a reorg, and in a valid fork)
* Max and too many signature operations via various combinations of
  OP_CHECKSIG, OP_MULTISIG, OP_CHECKSIGVERIFY, and OP_MULTISIGVERIFY
* Too many and max signature operations with offending sigop after
  invalid data push
* Max and too many signature operations via pay-to-script-hash redeem
  scripts
* Attempt to spend tx created on a different fork
* Attempt to spend immature coinbase (on main chain and fork)
* Max size block and block that exceeds the max size
* Children of rejected blocks are either orphans or rejected
* Coinbase script too small and too large
* Max length coinbase script
* Attempt to spend tx in blocks that failed to connect
* Valid non-coinbase tx in place of coinbase
* Block with no transactions
* Invalid proof-of-work
* Block with a timestamp too far in the future
* Invalid merkle root
* Invalid proof-of-work limit (bits header field)
* Negative proof-of-work limit (bits header field)
* Two coinbase transactions
* Duplicate transactions
* Spend from transaction that does not exist
* Timestamp exactly at and one second after the median time
* Blocks with same hash via merkle root tricks
* Spend from transaction index that is out of range
* Transaction that spends more that its inputs provide
* Transaction with same hash as an existing tx that has not been
  fully spent (BIP0030)
* Non-final coinbase and non-coinbase txns
* Max size block with canonical encoding which exceeds max size with
  non-canonical encoding
* Spend from transaction earlier in same block
* Spend from transaction later in same block
* Double spend transaction from earlier in same block
* Coinbase that pays more than subsidy + fees
* Coinbase that includes subsidy + fees
* Invalid opcode in dead execution path
* Reorganization of txns with OP_RETURN outputs
* Spend of an OP_RETURN output
* Transaction with multiple OP_RETURN outputs
* Large max-sized block reorganization test (disabled by default since
  it takes a long time and a lot of memory to run)

Finally, the README.md files in the main and docs directories have been
updated to reflect the use of the new testing framework.
2016-10-17 12:16:53 -05:00
David Hill 05ab7141d3 travis: Add go 1.7 and drop go 1.5 support. (#740) 2016-08-18 11:06:26 -05:00
Janus Troelsen 4a5223266c docs: Add chainhash to README.md (#739) 2016-08-17 10:41:50 -05:00
Dave Collins bd4e64d1d4 chainhash: Abstract hash logic to new package. (#729)
This is mostly a backport of some of the same modifications made in
Decred along with a few additional things cleaned up.  In particular,
this updates the code to make use of the new chainhash package.

Also, since this required API changes anyways and the hash algorithm is
no longer tied specifically to SHA, all other functions throughout the
code base which had "Sha" in their name have been changed to Hash so
they are not incorrectly implying the hash algorithm.

The following is an overview of the changes:

- Remove the wire.ShaHash type
- Update all references to wire.ShaHash to the new chainhash.Hash type
- Rename the following functions and update all references:
  - wire.BlockHeader.BlockSha -> BlockHash
  - wire.MsgBlock.BlockSha -> BlockHash
  - wire.MsgBlock.TxShas -> TxHashes
  - wire.MsgTx.TxSha -> TxHash
  - blockchain.ShaHashToBig -> HashToBig
  - peer.ShaFunc -> peer.HashFunc
- Rename all variables that included sha in their name to include hash
  instead
- Update for function name changes in other dependent packages such as
  btcutil
- Update copyright dates on all modified files
- Update glide.lock file to use the required version of btcutil
2016-08-08 14:04:33 -05:00
Steven Roose 24e41c843b Update installation instructions using Glide (#698)
The main README.md file had newer installation that uses Glide, while these did not.
2016-05-21 17:30:26 -05:00
Dave Collins 37938375dc docs: Update READMEs with current details.
This commit updates the main README.md and docs/README.md files to
replace the references to the now dead btcgui project with the
Windows-only Paymetheus project.

While here, it also updates some information to make it more current and
accurately describe the current status.
2016-03-11 14:53:15 -06:00
Mawueli Kofi Adzoe ff0c787237 Fix inconsistent spacing.
guidelinestherin ---> guidelines therein.
2015-12-29 10:59:57 -07:00
Justus Ranvier 756f58b581
add installation instructions for Gentoo 2015-11-08 14:55:08 -06:00
David Hill 4b7206b54f btcjson: Add optional locktime to createrawtransaction
rpcserver:
If the locktime is given, the transaction inputs will be set to a
non-max value, activating the locktime.  The locktime for the
new transaction will be set to the given value.

This mimics Bitcoin Core commit 212bcca92089f406d9313dbe6d0e1d25143d61ff
2015-10-30 17:16:50 -04:00
Javed Khan 00bddf7540 peer: Refactor peer code into its own package.
This commit introduces package peer which contains peer related features
refactored from peer.go.

The following is an overview of the features the package provides:

- Provides a basic concurrent safe bitcoin peer for handling bitcoin
  communications via the peer-to-peer protocol
- Full duplex reading and writing of bitcoin protocol messages
- Automatic handling of the initial handshake process including protocol
  version negotiation
- Automatic periodic keep-alive pinging and pong responses
- Asynchronous message queueing of outbound messages with optional
  channel for notification when the message is actually sent
- Inventory message batching and send trickling with known inventory
  detection and avoidance
- Ability to wait for shutdown/disconnect
- Flexible peer configuration
  - Caller is responsible for creating outgoing connections and listening
    for incoming connections so they have flexibility to establish
    connections as they see fit (proxies, etc.)
  - User agent name and version
  - Bitcoin network
  - Service support signalling (full nodes, bloom filters, etc.)
  - Maximum supported protocol version
  - Ability to register callbacks for handling bitcoin protocol messages
- Proper handling of bloom filter related commands when the caller does
  not specify the related flag to signal support
  - Disconnects the peer when the protocol version is high enough
  - Does not invoke the related callbacks for older protocol versions
- Snapshottable peer statistics such as the total number of bytes read
  and written, the remote address, user agent, and negotiated protocol
  version
- Helper functions for pushing addresses, getblocks, getheaders, and
  reject messages
  - These could all be sent manually via the standard message output
    function, but the helpers provide additional nice functionality such
    as duplicate filtering and address randomization
- Full documentation with example usage
- Test coverage

In addition to the addition of the new package, btcd has been refactored
to make use of the new package by extending the basic peer it provides to
work with the blockmanager and server to act as a full node.  The
following is a broad overview of the changes to integrate the package:

- The server is responsible for all connection management including
  persistent peers and banning
- Callbacks for all messages that are required to implement a full node
  are registered
- Logic necessary to serve data and behave as a full node is now in the
  callback registered with the peer

Finally, the following peer-related things have been improved as a part
of this refactor:

- Don't log or send reject message due to peer disconnects
- Remove trace logs that aren't particularly helpful
- Finish an old TODO to switch the queue WaitGroup over to a channel
- Improve various comments and fix some code consistency cases
- Improve a few logging bits
- Implement a most-recently-used nonce tracking for detecting self
  connections and generate a unique nonce for each peer
2015-10-23 06:17:29 +05:30
Dario Nieuwenhuis 0190c349aa Add reverse order option to searchrawtransactions rpc 2015-10-08 16:31:39 +02: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
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
Dave Collins 88b15e74f0 docs: Add info describing model commit messages. 2015-07-30 13:14:42 -05: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
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
David Hill 7cfa843832 Support getmempoolinfo. 2015-06-24 20:34:56 -04:00
Josh Rickmar 09ce6f94d3 Add timestamps to block(dis)connected notifications. 2015-06-18 13:02:13 -04:00
Josh Rickmar 2ceb6418e7 Notify mined transactions before connected block.
This allows clients watching for both to know when all mined
transaction notifications for the block have been received.
Otherwise, clients would be aware that there is a new block, see the
exact same block hash/height in the next tx notifications, but never
know when all txs from the block have been received and processed.

This fixes a synchronization issue in btcwallet where the wallet would
mark itself synced to some block height before any of those blocks'
transactions were processed.  If the RPC connection is lost between
sending the blockconnected notification and receiving the last
transaction notification, the wallet would not know of this and
continue with missing transactions.
2015-06-17 22:37:55 -04:00
David Hill 007bee5ec8 Add new option --torisolation
Tor stream isolation randomizes proxy user credentials resulting in
Tor creating a new circuit for each connection.  This makes it more
difficult to correlate connections.

Idea from Wladimir J. van der Laan via Bitcoin Core.
2015-05-13 18:30:48 -04:00
David Hill aa34ec0925 Update docs for IRC move to freenode. 2015-05-12 14:01:58 -04:00
Federico Bond 717a9f25b5 Fix documentation example 2015-05-06 13:46:04 -03:00
Olaoluwa Osuntokun 6801c0000a Fix #122 by allowing clients to cancel websockets notifications.
This commit adds 4 new websockets JSON-RPC methods for canceling
notifications:
  * stopnotifyspent
  * stopnotifyreceived
  * stopnotifyblocks
  * stopnotifynewtransactions
2015-05-05 08:54:27 -07:00
Alex Akselrod d26aaffb2b Create generate RPC command to close #362
Create GenerateCmd in btcjson v2. Update tests to check GenerateCmd.

Update chaincfg/params.go with a new bool in Params, GenerateSupported,
with true values in SimNetParams and RegressionNetParams and false in
the others.

Create new flag, discreteMining, in CPUMiner struct.

Add GenerateNBlocks function to cpuminer.go and handleGenerate
function to rpcserver.go.

Update documentation for the RPC calls.
2015-05-04 21:04:25 -04:00
Dave Collins 9a658c2689 rpcserver: Omit empty getblock->nextblockhash.
This commit omits the nextblockhash field from the getblock RPC result
when there isn't one (i.e for current the tip).

Closes #416.
2015-05-04 10:38:40 -05:00
Dave Collins 6e402deb35 Relicense to the btcsuite developers.
This commit relicenses all code in this repository to the btcsuite
developers.
2015-05-01 12:00:56 -05:00
Olaoluwa Osuntokun 65b044eea2 Fix #79 by adding a new node JSON-RPC command
* Gives node operators full control of peer connectivity
* RPC adds ability to disconnect all matching non-persistent peers,
  remove persistent peers, and connect to peers making them either
  temporary or persistent.
2015-04-14 23:07:51 -07:00
Alex Akselrod 4a1445a032 Create limited RPC user.
The limited user is specified with the --rpclimituser and
--rpclimitpass options (or the equivalent in the config file).
The config struct and loadConfig() are updated to take the
new options into account. The limited user can have neither
the same username nor the same password as the admin user.

The package-level rpcLimit map in rpcserver.go specifies
the RPC commands accessible by limited users. This map
includes both HTTP/S and websocket commands.

The checkAuth function gets a new return parameter to
signify whether the user is authorized to change server
state. The result is passed to the jsonRPCRead function and
to the WebsocketHandler function in rpcwebsocket.go.

The wsClient struct is updated with an "isAdmin" field
signifying that the client is authorized to change server
state, written by WebsocketHandler and handleMessage.
The handleMessage function also checks the field to
allow or disallow an RPC call.

The following documentation files are updated:
- doc.go
- sample-btcd.conf
- docs/README.md
- docs/json_rpc_api.md
- docs/configure_rpc_server_listen_interfaces.md
2015-04-13 14:14:52 -04:00
Olaoluwa Osuntokun 1bf564d963 Fix #138 by dynamically updating heights of peers
In order to avoid prior situations of stalled syncs due to
outdated peer height data, we now update block heights up peers in
real-time as we learn of their announced
blocks.

Updates happen when:
   * A peer sends us an orphan block. We update based on
     the height embedded in the scriptSig for the coinbase tx
   * When a peer sends us an inv for a block we already know
     of
   * When peers announce new blocks. Subsequent
     announcements that lost the announcement race are
     recognized and peer heights are updated accordingly

Additionally, the `getpeerinfo` command has been modified
to include both the starting height, and current height of
connected peers.

Docs have been updated with `getpeerinfo` extension.
2015-04-01 17:22:45 -07:00
Josh Rickmar 63c1172aa8 Automatically register for tx notifications after a rescan.
This changes the behavior of the rescan RPC to automatically set the
client up for transaction notifications for transactions paying to any
rescanned address and spending outputs in the final rescan UTXO set
after a rescanned is performed through the best block in the chain.
2015-02-24 10:42:28 -05:00
Olaoluwa Osuntokun bc6be3ba69 Correct documentation for searchrawtransactions
`searchrawtransactions` can return multiple transactions. Previously the documentation erroneously had return examples showing only a single tx for each case. 
  * The documentation previously presented the output for the `non-verbose` case as a single json string, instead of an array of json strings. 
  * Similarly, for the `verbose` mode, the documentation detailed the output as a single json object, instead of an array of json objects.
2015-02-23 09:57:56 -08:00
Dave Collins 1185b8632a Fix a couple of links in main README.md. 2015-02-08 12:09:49 -06:00
Dave Collins 2e5bb96eea Correct a few instances of missed pkg name changes. 2015-02-05 17:54:04 -06:00
Olaoluwa Osuntokun ecdffda748 Add support for an optional address-based transaction index.
* Address index is built up concurrently with the `--addrindex` flag.
* Entire index can be deleted with `--dropaddrindex`.
* New RPC call: `searchrawtransaction`
  * Returns all transacitons related to a particular address
  * Includes mempool transactions
  * Requires `--addrindex` to be activated and fully caught up.
* New `blockLogger` struct has been added to factor our common logging
  code
* Wiki and docs updated with new features.
2015-02-05 14:48:19 -08:00
Dave Collins 03433dad6a Update btcwire path import paths to new location. 2015-02-05 15:16:39 -06:00