Commit graph

3480 commits

Author SHA1 Message Date
Conner Fromknecht
a9f23321d9
netsync/manager: prioritize higher height peers for sync peer
This commit modifies the sync peer selection to prefer peers with a
higher advertised height than our currently known best height. If no
peers are known with a higher height, we will fall back to selecting a
random peer with the same best height as our own.

The current algorithm currently selects a random peer from the union of
these two sets, while this approach will favor trying to make progress.
This will likely help in selecting a good peer once already at tip, such
as after a restart.

Backport of https://github.com/gcash/bchd/pull/96
2019-04-16 21:09:18 -07:00
Conner Fromknecht
0e073b8058
config: adds AgentWhitelist and AgentBlacklist to config 2019-04-15 17:46:08 -07:00
Conner Fromknecht
d3ecdc91a9
server: adds hybrid black/whitelist filtering to user agents 2019-04-15 17:46:08 -07:00
Roei Erez
9bfb2ca034 connmgr: check for canceled connection before connect
This will ensure cancelation is reliable for all cases.
2019-04-09 19:54:18 -07:00
Mawueli Kofi Adzoe
aa6e0f3570 docs: use go modules instead of glide
Fixes https://github.com/btcsuite/btcd/issues/1379
2019-03-15 13:16:42 -07:00
Olaoluwa Osuntokun
306aecffea
Merge pull request #1391 from Roasbeef/btcutil-filter-fix
build: update to latest version of btcutil
2019-02-12 18:52:34 -08:00
Olaoluwa Osuntokun
2bdd957fe1
build: update to latest version of btcutil
In this commit, we update to the latest version of `btcutil`. This version
contains a bug fix for the neutrino filter generation. The implementation
within `btcutil` didn't fully comply with the BIP specification as it
included some OP_RETURN outputs, rather than excluding them all. As a
result, any active `btcd` node on mainnet/testnet will need to _drop their
entire `cfindex`_ and re-index after this is merged in.
2019-02-12 18:36:55 -08:00
Olaoluwa Osuntokun
12ce2fc7d3
Merge pull request #1383 from wpaulino/addrmgr-service-bits
addrmgr: store address' supported service bits
2019-02-08 16:00:34 -08:00
Wilmer Paulino
bcd50ea838
addrmgr: store address' supported service bits
In this commit, we update the serialized version of the AddressManager
to also store each address' service bits. This allows an address'
service bits to be properly set when read from disk, which allows
external callers to reliably filter out addresses which do not support
their required services.

Since the service bits were not previously stored, the serialization
version needed to be bumped. A test has been added to test the behavior
of upgrading from version 1 to 2.
2019-02-06 13:33:18 -08:00
Wilmer Paulino
10f17a8bb0
addrmgr: add AddrManager serialization test 2019-02-06 13:33:11 -08:00
Wilmer Paulino
18a6867124
addrmgr/knownaddress: expose an address' service bits 2019-02-06 13:33:11 -08:00
Olaoluwa Osuntokun
ed77733ec0
Merge pull request #1359 from wpaulino/rescan-script-spends
txscript+rpcwebsocket: detect script spend within rescans
2019-01-14 17:39:29 -08:00
Wilmer Paulino
f6eae62a77
rpcwebsocket: detect and notify spend of script
In this commit, we modify the rescanBlock method to also determine
whether a script (encoded as an address in its rescanKeys) has been
spent. Upon detecting a spend, a btcjson.RedeemingTxNtfn is sent to the
client who requested it.
2019-01-11 18:30:42 -08:00
Wilmer Paulino
be2b6dc98a
rpcwebsocket: modify rescanKeys to take addresses as strings
In this commit, we modify the rescanKeys struct, which contains the
relevant keys that should be matched when rescanning the chain, to take
addresses in their string representation. This ends up simplifying a lot
of the logic as we no longer have to special-case specific script types.
2019-01-11 18:30:42 -08:00
Wilmer Paulino
0cec774a75
txscript: add support to re-derive output's PkScript from input
In this commit, we extend the txscript package to support re-deriving
the PkScript of an output by looking at the input's signature
script/witness attempting to spend it. As of this commit, the only
supported types are P2SH, v0 P2WSH, and v0 P2WPKH.

This will serve useful to detect when a particular script has been spent
on-chain.

A set of test vectors has also been added for the supported script types
to ensure its correctness.
2019-01-11 18:30:42 -08:00
Shuai Qi
5bda5314ca netsync+blockchain: fix typos 2019-01-08 20:07:09 -08:00
Olaoluwa Osuntokun
cfcc5e0305
Merge pull request #1355 from cfromknecht/tidy-go-mod
build: tidy go modules
2019-01-08 20:02:48 -08:00
Conner Fromknecht
2ecf0619f2
build: tidy go modules 2018-11-30 13:52:58 -08:00
Olaoluwa Osuntokun
7d2daa5bfe
Merge pull request #1354 from cfromknecht/go-modules
build: Migrate to go modules
2018-11-29 17:59:35 -08:00
Conner Fromknecht
20388be196
README: require go1.11, document module installation 2018-11-29 17:53:41 -08:00
Conner Fromknecht
2f3be2e337
travis: remove glide, only build 1.11.x, use modules 2018-11-29 17:51:22 -08:00
Conner Fromknecht
2a9e4372c8
goclean: update for go modules 2018-11-29 17:45:40 -08:00
Conner Fromknecht
97c3fea94c
build: remove glide.lock and glide.yaml 2018-11-29 17:38:24 -08:00
Conner Fromknecht
852b39bd6d
build: add go.mod and go.sum for 1.11 modules 2018-11-29 17:34:23 -08:00
Olaoluwa Osuntokun
b6c71b40a8
Merge pull request #1352 from halseth/import-path-rpctest
integration/rpctest: make exec path compatible with modules
2018-11-29 14:56:06 -08:00
Johan T. Halseth
f5b60801a5
integration/rpctest: make exec path compatible with modules
With the use of go modules, the btcdPkgPath will no longer be `github.com/btcsuite/btcd`, but end with a version string (e.g. btcd@v0.0.0-20181129140220-beb77e89572a).

This trips up build.ImportDir, which will return a ImportPath of ".", since this package cannot be found in the go path.

There are probably several ways of fixing this, by clever string magic, but seems easiest to just hardcode the btcd package name.
2018-11-29 15:13:37 +01:00
junderw
3dcf298fed Fix one-off bug in signRFC6979 2018-11-23 13:02:23 -06:00
Olaoluwa Osuntokun
67e573d211
Merge pull request #1310 from sangaman/patch-1
sampleconfig: Remove floating grave accent
2018-10-12 17:44:28 -07:00
Olaoluwa Osuntokun
1c5c32a5e8
Merge pull request #1315 from halseth/msgcfilter-string
peer log: add MsgCFHeaders and MsgGetCFHeaders message summary
2018-10-12 17:43:50 -07:00
Olaoluwa Osuntokun
5f1bfdec9a
Merge pull request #1316 from halseth/connmgr-nil-addr
connmanager: check Addr for nil
2018-10-12 17:43:14 -07:00
Olaoluwa Osuntokun
d2b1a06d93
Merge pull request #1129 from gracenoah/fix-rescan
fix NewImportAddressCmd rescan wrong parameters
2018-10-12 17:34:25 -07:00
Olaoluwa Osuntokun
d2046eeb1b
Merge pull request #1256 from davecgh/server_onversion_use_local_for_net_addr
server: Use local addr var in version handler.
2018-10-12 17:27:28 -07:00
Johan T. Halseth
4b5ff8c687
connmanager: check Addr for nil 2018-10-01 13:55:43 +02:00
Johan T. Halseth
5e578f546f
peer log: add MsgCFHeaders and MsgGetCFHeaders string representation 2018-10-01 13:40:45 +02:00
Daniel McNally
93fa810723
sampleconfig: Remove floating grave accent 2018-09-27 12:41:34 -04:00
Olaoluwa Osuntokun
2a560b2036
Merge pull request #1301 from meyer9/fix-sig-dos
btcec/signature: fix DoS bug with signature parsing
2018-09-23 19:12:09 -07:00
Dave Collins
8c981e4ef2
server: Use local addr var in version handler.
This modifies the OnVersion handler for server peers to use a local
variable for the remote address of the peer in order to avoid grabbing
the mutex multiple times.

There are no functional changes.

Backported from Decred.
2018-09-20 22:32:59 -05:00
Dave Collins
c8b9fab820
server: Only advertise local addr when current.
This changes the server peers OnVersion handler to only advertise the
server as a viable target for inbound connections when the server
believes it is close the best known tip.

Backported from Decred.
2018-09-20 22:32:41 -05:00
Dave Collins
d2c7892aa4
server: Use local inbound var in version handler.
This modifies the OnVersion handler for server peers to use a local
variable for the inbound status of the peer in order to avoid grabbing
the mutex multiple times.

While here, it also does some light cleanup.  There are no functional
changes.

Backported from Decred.
2018-09-20 22:32:16 -05:00
Dave Collins
4b20d4f86a
server: Update addrmgr services on outbound conns.
This adds code to update the address manager services for a known
address to the services advertised by peers when they are connected to
via an outbound connection.  It is only done for outbound connections to
help prevent malicious behavior from inbound connections.

Backported from Decred.
2018-09-20 22:31:50 -05:00
Dave Collins
24e23525fb
addrmgr: Expose method to update services.
This exposes a new method named SetServices to the address manager which
can be used to update the services for a known address.  This will be
useful to keep known services up to date.

Backported from Decred.
2018-09-20 22:31:49 -05:00
Dave Collins
4d1e1db9ea
peer: Improve net address service adverts.
This modifies the peer code which deals with advertising service flags
via the net address fields of the version message as follows:

- For outgoing connections:
  - Set the local netaddress services to what the local peer supports
  - Set the remote netaddress services to 0 to indicate no services as
    they are still unknown
- For incoming connections:
  - Set the local netaddress services to what the local peer supports
  - Set the remote netaddress services to the what was advertised by the
    remote peer in its version message
2018-09-20 22:31:23 -05:00
Dave Collins
9151ebc90b
server: Reject outbound conns to non-full nodes.
This modifies the server connection code to reject outbound peers that
do not offer full node services.
2018-09-20 22:30:46 -05:00
Dave Collins
7b103e2434
peer: Allow OnVersion callback to reject peer.
This modifies the OnVersion callback to allow a reject message to be
returned in which case the message will be sent to the peer and the peer
will be disconnected.

Backported from Decred.
2018-09-20 22:29:27 -05:00
Dave Collins
118f55233b
peer: Rework version negotiation.
This modifies the negotiation logic to ensure the callback has the
opportunity to see the message before the peer is disconnected and
improves the error handling when reading the remote version message.

It also has the side effect of ensuring the protocol version is
negotiated before sending reject messages with the exception of the
first message not being a version message since negotiation is not
possible in that case.

This is being changed because it is useful for the server to see the
message regardless in order to have the opportunity to things such as
update the address manager and reject peers that don't have desired
services.

Backported from Decred.
2018-09-20 22:26:36 -05:00
Julian Meyer
66d33037ec btcec/signature: updated comment to reference constant instead of value 2018-09-20 20:24:03 -07:00
Julian Meyer
8965887ca4 btcec/signature: moved minimum signature length to a constant 2018-09-20 20:19:11 -07:00
Dave Collins
25dfda9bd3
peer: Add duplicate version message test.
This adds a test to ensure duplicate version messages are rejected.

Backported from Decred.
2018-09-20 22:18:36 -05:00
Olaoluwa Osuntokun
92494a5188
Merge pull request #1282 from qshuai/master
server: Fix struct name mismatch
2018-09-20 20:16:19 -07:00
Olaoluwa Osuntokun
934137b22a
Merge pull request #1217 from halseth/node-command-btcsuite
rpcclient: expose the Node command for RPC API.
2018-09-20 20:14:26 -07:00