Commit graph

16890 commits

Author SHA1 Message Date
Russell Yanofsky 0d94e60625 refactor: Use DatabaseStatus and DatabaseOptions types
No changes in behavior. Just replaces arguments and return types
2020-09-03 12:24:32 -04:00
Russell Yanofsky b5b414151a wallet: Add MakeDatabase function
New function is not currently called but will be called in upcoming commits. It
moves database path checking, and existence checking, and already-loaded
checking, and verification into a single function so this logic does not need
to be repeated all over higher level wallet code, and so higher level code does
not need to change when SQLite support is added in
https://github.com/bitcoin/bitcoin/pull/19077. This also lets higher level
wallet code make fewer assumptions about the contents of wallet directories.

This commit just adds the new function and does not change behavior in any way.
2020-09-03 12:24:32 -04:00
Russell Yanofsky 288b4ffb6b Remove WalletLocation class
This removes a source of complexity and indirection that makes it harder to
understand path checking code. Path checks will be simplified in upcoming
commits.

There is no change in behavior in this commit other than a slightly more
descriptive error message in `loadwallet` if the default "" wallet can't be
found. (The error message is improved more in upcoming commit "wallet: Remove
path checking code from loadwallet RPC".)
2020-09-03 12:24:32 -04:00
Wladimir J. van der Laan bd60a9a8ed
Merge #19818: p2p: change CInv::type from int to uint32_t, fix UBSan warning
7984c39be1 test framework: serialize/deserialize inv type as unsigned int (Jon Atack)
407175e0c2 p2p: change CInv::type from int to uint32_t (Jon Atack)

Pull request description:

  Fixes UBSan implicit-integer-sign-change issue per https://github.com/bitcoin/bitcoin/pull/19610#issuecomment-680686460.

  Credit to Crypt-iQ for finding and reporting the issue and to vasild for the original review suggestion in https://github.com/bitcoin/bitcoin/pull/19590#pullrequestreview-455788826.

  Closes #19678.

ACKs for top commit:
  laanwj:
    ACK 7984c39be1
  MarcoFalke:
    ACK 7984c39be1 🌻
  vasild:
    ACK 7984c39be

Tree-SHA512: 59f3a75f40ce066ca6f0bb1927197254238302b4073af1574bdbfe6ed580876437be804be4e47d51467d604f0d9e3a5875159f7f2edbb2351fdb2bb9465100b5
2020-09-03 17:23:52 +02:00
Wladimir J. van der Laan 69a13eb246
Merge #19670: Protect localhost and block-relay-only peers from eviction
752e6ad533 Protect localhost and block-relay-only peers from eviction (Suhas Daftuar)

Pull request description:

  Onion peers are disadvantaged under our eviction criteria, so prevent eventual
  eviction of them in the presence of contention for inbound slots by reserving
  some slots for localhost peers (sorted by longest uptime).

  Block-relay-only connections exist as a protection against eclipse attacks, by
  creating a path for block propagation that may be unknown to adversaries.
  Protect against inbound peer connection slot attacks from disconnecting such
  peers by attempting to protect up to 8 peers that are not relaying transactions
  but have provided us with blocks.

  Thanks to gmaxwell for suggesting these strategies.

ACKs for top commit:
  laanwj:
    Code review ACK 752e6ad533

Tree-SHA512: dbf089c77c1f747aa1dbbbc2e9c2799c628028b0918d0c336d8d0e5338acedd573b530eb3b689c7f603a17221e557268a9f5c3f585f204bfb12e5d2e76de39a3
2020-09-03 17:20:47 +02:00
Wladimir J. van der Laan 620ac8c475
Merge #19724: [net] Cleanup connection types- followups
eb1c5d090f [doc] Follow developer notes, add comment about missing default. (Amiti Uttarwar)
d5a57cef62 [doc] Describe connection types in more depth. (Amiti Uttarwar)
4829b6fcc6 [refactor] Simplify connection type logic in ThreadOpenConnections (Amiti Uttarwar)
1e563aed78 [refactor] Simplify check for block-relay-only connection. (Amiti Uttarwar)
da3a0be61b [test] Add explicit tests that connection types get set correctly (Amiti Uttarwar)
1d74fc7df6 [trivial] Small style updates (Amiti Uttarwar)
ff6b9081ad [doc] Explain address handling logic in process messages (Amiti Uttarwar)
dff16b184b [refactor] Restructure logic to check for addr relay. (Amiti Uttarwar)
a6ab1e81f9 [net] Remove unnecessary default args on OpenNetworkConnection (Amiti Uttarwar)
8d6ff46f55 scripted-diff: Rename `OUTBOUND` ConnectionType to `OUTBOUND_FULL_RELAY` (Amiti Uttarwar)

Pull request description:

  This PR addresses outstanding review comments from #19316. It further simplifies `net.cpp` complexity and adds documentation about design goals about different connection types.

ACKs for top commit:
  naumenkogs:
    ACK eb1c5d090f
  laanwj:
    Code review ACK eb1c5d090f

Tree-SHA512: 2fe14e428404c95661e5518c8c90db07ab5b9ebb1bac921b3bdf82b181f444fae379f8fc0a2b619e6b4693f01c55bd246fbd8c8eedadd96849a30de3161afee5
2020-09-03 13:28:30 +02:00
fanquake 68f0ab26bc
Merge #19805: wallet: Avoid deserializing unused records when salvaging
0bbe26a1af wallet: filter for keys only before record deser in salvage (Andrew Chow)
544e12a4e8 walletdb: Add KeyFilterFn to ReadKeyValue (Andrew Chow)

Pull request description:

  When salvaging a wallet, the only things that matter are the private keys. It is not necessary to attempt to deserialize any other records, especially if those records are corrupted too.

  This PR adds a `KeyFilterFn` function callback to `ReadKeyValue` that salvage uses to filter for only the records that it wants. Of course doing it this way also lets us do other filters in the future from other places should we so desire.

ACKs for top commit:
  ryanofsky:
    Code review ACK 0bbe26a1af. Looks great! This should make the recovery code more robust. Normally it'd be good to have a test case for the problem this fixes, but Marco already wrote one in #19078, so I think we're covered
  laanwj:
    Code review ACK 0bbe26a1af

Tree-SHA512: 8e3ee283a22a79273915711c4fb751f3c9b02ce94e6bf08dc468f1cfdf9fac35c693bbfd2435ce43c3a06c601b9b0a67e209621f6814bedfe3bc7a7ccc37bb01
2020-09-03 12:47:01 +08:00
fanquake 9876ab8c74
Merge #19844: remove usage of boost::bind
e36f802fa4 lint: add C++ code linter (fanquake)
c4be50fea3 remove usage of boost::bind (fanquake)

Pull request description:

  `boost::bind` usage was removed in #13743. However a new usage snuck in as
  part of 2bc4c3eaf9 (#15225).

ACKs for top commit:
  hebasto:
    ACK e36f802fa4
  practicalswift:
    ACK e36f802fa4 -- patch looks correct

Tree-SHA512: 2b0387c5443c184bcbf7df4849db1ed1296ff82c7b4ff0aff18334a400e56a472a972d18234d3866531a088d7a8da64688e58dc9f15daaad4048697c759d55ce
2020-09-03 11:43:10 +08:00
Amiti Uttarwar eb1c5d090f [doc] Follow developer notes, add comment about missing default. 2020-09-02 17:18:22 -07:00
Amiti Uttarwar d5a57cef62 [doc] Describe connection types in more depth. 2020-09-02 17:18:22 -07:00
Amiti Uttarwar 4829b6fcc6 [refactor] Simplify connection type logic in ThreadOpenConnections
Consolidate the logic to determine connection type into one conditional to
clarify how they are chosen.
2020-09-02 17:18:22 -07:00
Amiti Uttarwar 1e563aed78 [refactor] Simplify check for block-relay-only connection.
Previously we deduced it was a block-relay-only based on presence of the
m_tx_relay structure. Now we have the ability to identify it directly via a
connection type accessor function.
2020-09-02 17:18:22 -07:00
Amiti Uttarwar da3a0be61b [test] Add explicit tests that connection types get set correctly 2020-09-02 17:18:22 -07:00
Amiti Uttarwar 1d74fc7df6 [trivial] Small style updates 2020-09-02 17:18:21 -07:00
Amiti Uttarwar ff6b9081ad [doc] Explain address handling logic in process messages
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2020-09-02 17:18:21 -07:00
Amiti Uttarwar dff16b184b [refactor] Restructure logic to check for addr relay.
We previously identified if we relay addresses to the connection by checking
for the existence of the m_addr_known data structure. With this commit, we
answer this question based on the connection type.

IsAddrRelayPeer() checked for the existence of the m_addr_known
2020-09-02 17:18:21 -07:00
Amiti Uttarwar a6ab1e81f9 [net] Remove unnecessary default args on OpenNetworkConnection 2020-09-02 13:36:29 -07:00
Amiti Uttarwar 8d6ff46f55 scripted-diff: Rename OUTBOUND ConnectionType to OUTBOUND_FULL_RELAY
-BEGIN VERIFY SCRIPT-
sed -i 's/OUTBOUND, /OUTBOUND_FULL_RELAY, /g' src/net.h
sed -i 's/ConnectionType::OUTBOUND/ConnectionType::OUTBOUND_FULL_RELAY/g' src/test/net_tests.cpp src/test/fuzz/process_message.cpp src/test/fuzz/process_messages.cpp src/net.cpp src/test/denialofservice_tests.cpp src/net.h src/test/fuzz/net.cpp
-END VERIFY SCRIPT-
2020-09-02 13:34:58 -07:00
Jon Atack bf1f913c44
cli -netinfo: display multiple levels of details 2020-09-02 16:24:23 +02:00
Suhas Daftuar 752e6ad533 Protect localhost and block-relay-only peers from eviction
Onion peers are disadvantaged under our eviction criteria, so prevent eventual
eviction of them in the presence of contention for inbound slots by reserving
some slots for localhost peers (sorted by longest uptime).

Block-relay-only connections exist as a protection against eclipse attacks, by
creating a path for block propagation that may be unknown to adversaries.
Protect against inbound peer connection slot attacks from disconnecting such
peers by attempting to protect up to 8 peers that are not relaying transactions
but appear to be full-nodes, sorted by recency of last delivered block.

Thanks to gmaxwell for suggesting these strategies.
2020-09-02 09:21:33 -04:00
Wladimir J. van der Laan c157a50694
Merge #19840: Avoid callback when -blocknotify is empty
413e0d1d31 Avoid callback when -blocknotify is empty (João Barbosa)

Pull request description:

ACKs for top commit:
  MarcoFalke:
    ACK 413e0d1d31
  practicalswift:
    ACK 413e0d1d31 -- patch looks correct
  laanwj:
    Code review ACK 413e0d1d31

Tree-SHA512: 915e796666b4e74dbb029ba5436e5573a4b881aad9e118f737bcff4024528b7ff3b00dd035138f63d30963cfd66195f6e53a2dbe429ee28cb6f0b9cc47218ecf
2020-09-02 15:14:34 +02:00
fanquake c17a003758
Merge #19857: net: improve nLastBlockTime and nLastTXTime documentation
d780293e1e net: improve nLastBlockTime and nLastTXTime documentation (Jon Atack)

Pull request description:

  Follow-up to #19731 to help alleviate confusion around `nLastBlockTime` and `nLastTXTime`, now also provided by the JSON-RPC API as `last_block` and `last_transaction` in `getpeerinfo` output.

  Thanks to John Newbery, credited in the commit, and to Dave Harding and Adam Jonas during discussions on how to best explain these in this week's Optech newsletter.

ACKs for top commit:
  practicalswift:
    ACK d780293e1e
  MarcoFalke:
    ACK d780293e1e
  harding:
    ACK d780293e1e .  The added documentation matches my reading of the code and answers a question I had after seeing #19731
  0xB10C:
    ACK d780293e1e

Tree-SHA512: 72d47cf50a099913c7e4753cb80e11785b26fb66fa3a8b6c382fde4ea725116f3d215f93d32a567246d269768e66159f8dcf017a1bbc6d5f2489a35f81c316fa
2020-09-02 20:35:25 +08:00
Wladimir J. van der Laan 505b39e72b
Merge #19610: p2p: refactor AlreadyHave(), CInv::type, INV/TX processing
fb56d37612 p2p: ensure inv is GenMsgTx before ToGenTxid in inv processing (John Newbery)
aa3621385e test: use CInv::MSG_WITNESS_TX flag in p2p_segwit (Jon Atack)
24ee4f01ea p2p: make gtxid(.hash) and fAlreadyHave localvars const (Jon Atack)
b1c855453b p2p: use CInv block message helpers in net_processing.cpp (Jon Atack)
acd6642167 [net processing] Change AlreadyHaveTx() to take a GenTxid (John Newbery)
5fdfb80b86 [net processing] Change AlreadyHaveBlock() to take block_hash argument (John Newbery)
430e183b89 [net processing] Remove mempool argument from AlreadyHaveBlock() (John Newbery)
42ca5618ca [net processing] Split AlreadyHave() into separate block and tx functions (John Newbery)
39f1dc9445 p2p: remove nFetchFlags from NetMsgType TX and INV processing (Jon Atack)
471714e1f0 p2p: add CInv block message helper methods (Jon Atack)

Pull request description:

  Building on #19590 and the recent `wtxid` and `GenTxid` changes, this is a refactoring and cleanup PR to simplify and improve some of the net processing code.

  Some of the diffs are best reviewed with `-w` to ignore spacing.

  Co-authored by John Newbery.

ACKs for top commit:
  laanwj:
    Code review ACK fb56d37612
  jnewbery:
    utACK fb56d37612
  vasild:
    ACK fb56d3761

Tree-SHA512: ba39b58e6aaf850880a842fe5f6295e9f1870906ef690206acfc17140aae2ac854981e1066dbcd4238062478762fbd040ef772fdc2c50eea6869997c583e6a6d
2020-09-02 13:45:40 +02:00
Gleb Naumenko 83ad65f31b Address nits in ADDR caching 2020-09-02 10:33:17 +03:00
Jonas Schnelli 3a3e21dafb
Merge #14687: zmq: enable tcp keepalive
c276df7759 zmq: enable tcp keepalive (mruddy)

Pull request description:

  This addresses https://github.com/bitcoin/bitcoin/issues/12754.

  These changes enable node operators to address the silent dropping (by network middle boxes) of long-lived low-activity ZMQ TCP connections via further operating system level TCP keepalive configuration. For example, ZMQ sockets that publish block hashes can be affected in this way due to the length of time it sometimes takes between finding blocks (e.g.- sometimes more than an hour).

  Prior to this patch, operating system level TCP keepalive configurations would not take effect since the SO_KEEPALIVE option was not enabled on the underlying socket.

  There are additional ZMQ socket options related to TCP keepalive that can be set. However, I decided not to implement those options in this changeset because doing so would require adding additional bitcoin node configuration options, and would not yield a better outcome. I preferred a small, easily reviewable patch that doesn't add a bunch of new config options, with the tradeoff that the fine tuning would have to be done via well-documented operating system specific configurations.

  I tested this patch by running a node with:
  `./src/qt/bitcoin-qt -regtest -txindex -datadir=/tmp/node -zmqpubhashblock=tcp://127.0.0.1:28332 &`
  and connecting to it with:
  `python3 ./contrib/zmq/zmq_sub.py`

  Without these changes, `ss -panto | grep 28332 | grep ESTAB | grep bitcoin` will report no keepalive timer information. With these changes, the output from the prior command will show keepalive timer information consistent with the configuration at the time of connection establishment, e.g.-: `timer:(keepalive,119min,0)`.

  I also tested with a non-TCP transport and did not witness any adverse effects:
  `./src/qt/bitcoin-qt -regtest -txindex -datadir=/tmp/node -zmqpubhashblock=ipc:///tmp/bitcoin.block &`

ACKs for top commit:
  adamjonas:
    Just to summarize for those looking to review - as of c276df7759 there are 3 tACKs (n-thumann, Haaroon, and dlogemann), 1 "looks good to me" (laanwj) with no NACKs or any show-stopping concerns raised.
  jonasschnelli:
    utACK c276df7759

Tree-SHA512: b884c2c9814e97e666546a7188c48f9de9541499a11a934bd48dd16169a900c900fa519feb3b1cb7e9915fc7539aac2829c7806b5937b4e1409b4805f3ef6cd1
2020-09-02 09:09:18 +02:00
Andrew Chow f1ee37319a wallet: Reload previously loaded wallets on GUI startup
Enable the GUI to also use the load_on_startup feature.
Wallets loaded in the GUI always have load_on_startup=true.
When they are unloaded from the GUI, load_on_startup=false.

To facilitate this change, UpdateWalletSetting is moved into the wallet
module and called from within LoadWallet, RemoveWallet, and
Createwallet. This change does not actually touch the GUI code but
rather the wallet functions that are shared between the GUI and RPC.
2020-09-01 12:13:50 -04:00
Jon Atack d780293e1e
net: improve nLastBlockTime and nLastTXTime documentation
Co-authored-by: John Newbery <john@johnnewbery.com>
2020-09-01 17:46:28 +02:00
Hennadii Stepanov 020f0519ec
refactor: CTxMemPool::IsUnbroadcastTx() requires CTxMemPool::cs lock
No change in behavior, the lock is already held at call sites.
2020-09-01 12:36:27 +03:00
Hennadii Stepanov 7c4bd0387a
refactor: CTxMemPool::GetTotalTxSize() requires CTxMemPool::cs lock
No change in behavior, the lock is already held at call sites.
2020-09-01 12:34:39 +03:00
Hennadii Stepanov fa5fcb032b
refactor: CTxMemPool::ClearPrioritisation() requires CTxMemPool::cs lock
No change in behavior, the lock is already held at call sites.
Also `const uint256` refactored to `const uint256&`.
2020-09-01 12:34:29 +03:00
Hennadii Stepanov 7140b31b90
refactor: CTxMemPool::ApplyDelta() requires CTxMemPool::cs lock
No change in behavior, the lock is already held at call sites.
Also `const uint256` refactored to `const uint256&`.
2020-09-01 12:34:29 +03:00
Hennadii Stepanov 66e47e5e50
refactor: CTxMemPool::UpdateChild() requires CTxMemPool::cs lock
No change in behavior, the lock is already held at call sites.
2020-09-01 12:34:19 +03:00
Hennadii Stepanov 939807768a
refactor: CTxMemPool::UpdateParent() requires CTxMemPool::cs lock
No change in behavior, the lock is already held at call sites.
2020-09-01 12:34:11 +03:00
MarcoFalke bab4cce1b0
Merge #19668: Do not hide compile-time thread safety warnings
ea74e10acf doc: Add best practice for annotating/asserting locks (Hennadii Stepanov)
2ee7743fe7 sync.h: Make runtime lock checks require compile-time lock checks (Anthony Towns)
23d71d171e Do not hide compile-time thread safety warnings (Hennadii Stepanov)
3ddc150857 Add missed thread safety annotations (Hennadii Stepanov)
af9ea55a72 Use LockAssertion utility class instead of AssertLockHeld() (Hennadii Stepanov)

Pull request description:

  On the way of transit from `RecursiveMutex` to `Mutex` (see #19303) it is crucial to have run-time `AssertLockHeld()` assertion that does _not_ hide compile-time Clang Thread Safety Analysis warnings.

  On master (65e4ecabd5) using `AssertLockHeld()` could hide Clang Thread Safety Analysis warnings, e.g., with the following patch applied:
  ```diff
  --- a/src/txmempool.h
  +++ b/src/txmempool.h
  @@ -607,7 +607,7 @@ public:
       void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);

       void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
  -    void removeForReorg(const CCoinsViewCache* pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
  +    void removeForReorg(const CCoinsViewCache* pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
       void removeConflicts(const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
       void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);

  ```
  Clang compiles the code without any thread safety warnings.

  See "Add missed thread safety annotations" commit for the actual thread safety warnings that are fixed in this PR.

ACKs for top commit:
  MarcoFalke:
    ACK ea74e10acf 🎙
  jnewbery:
    ACK ea74e10acf
  ajtowns:
    ACK ea74e10acf

Tree-SHA512: 8cba996e526751a1cb0e613c0cc1b10f027a3e9945fbfb4bd30f6355fd36b9f9c2e1e95ed3183fc254b42df7c30223278e18e5bdb5e1ef85db7fef067595d447
2020-09-01 08:18:26 +02:00
fanquake a1d14f522c
Merge #19671: wallet: Remove -zapwallettxes
3340dbadd3 Remove -zapwallettxes (Andrew Chow)

Pull request description:

  It's not clear what use there is to keeping `-zapwallettxes` given that it's intended usage has been superseded by `abandontransaction`. So this removes it outright.

  Alternative to #19700

ACKs for top commit:
  meshcollider:
    utACK 3340dbadd3
  fanquake:
    ACK 3340dbadd3 - remaining manpage references will get cleaned up pre-release.

Tree-SHA512: 3e58e1ef6f4f94894d012b93e88baba3fb9c2ad75b8349403f9ce95b80b50b0b4f443cb623cf76c355930db109f491b3442be3aa02972e841450ce52cf545fc8
2020-09-01 09:26:28 +08:00
Andrew Chow 3340dbadd3 Remove -zapwallettxes
-zapwallettxes is made a hidden option to inform users that it is
removed and they should be using abandontransaction to do the stuck
transaction thing.
2020-08-31 12:39:19 -04:00
MarcoFalke fa6bb0ce5d
Assert that RPCArg names are equal to CRPCCommand ones (rawtransaction) 2020-08-31 18:29:57 +02:00
MarcoFalke fa80c81487
Assert that RPCArg names are equal to CRPCCommand ones (blockchain) 2020-08-31 18:29:55 +02:00
MarcoFalke 89a8299a14
Merge #19717: rpc: Assert that RPCArg names are equal to CRPCCommand ones (mining,zmq,rpcdump)
fa3d9ce325 rpc: Assert that RPCArg names are equal to CRPCCommand ones (rpcdump) (MarcoFalke)
fa32c1d5ec rpc: Assert that RPCArg names are equal to CRPCCommand ones (zmq) (MarcoFalke)
faaa46dc20 rpc: Assert that RPCArg names are equal to CRPCCommand ones (mining) (MarcoFalke)
fa93bc14c7 rpc: Remove unused return type from appendCommand (MarcoFalke)

Pull request description:

  This is split out from #18531 to just touch the RPC methods in misc. Description from the main pr:

  ### Motivation

  RPCArg names in the rpc help are currently only used for documentation. However, in the future they could be used to teach the server the named arguments. Named arguments are currently registered by the `CRPCCommand`s and duplicate the RPCArg names from the documentation. This redundancy is fragile, and has lead to errors in the past (despite having linters to catch those kind of errors). See section "bugs found" for a list of bugs that have been found as a result of the changes here.

  ### Changes

  The changes here add an assert in the `CRPCCommand` constructor that the RPCArg names are identical to the ones in the `CRPCCommand`.

  ### Future work

  > Here or follow up, makes sense to also assert type of returned UniValue?

  Sure, but let's not get ahead of ourselves. I am going to submit any further works as follow-ups, including:

  * Removing the CRPCCommand arguments, now that they are asserted to be equal and thus redundant
  * Removing all python regex linters on the args, now that RPCMan can be used to generate any output, including the cli.cpp table
  * Auto-formatting and sanity checking the RPCExamples with RPCMan
  * Checking passed-in json in self-check. Removing redundant checks
  * Checking returned json against documentation to avoid regressions or false documentation
  * Compile the RPC documentation at compile-time to ensure it doesn't change at runtime and is completely static

  ### Bugs found

  * The assert identified issue #18607
  * The changes itself fixed bug #19250

ACKs for top commit:
  fjahr:
    tested ACK fa3d9ce325
  promag:
    Code review ACK fa3d9ce325.

Tree-SHA512: 068ade4b55cc195868d53b7f9a27151d45b440857bb069e261a49d102a49a38fdba5d68868516a1d66a54a73ba34681362f934ded7349e894042bde873b75719
2020-08-31 17:43:35 +02:00
Jon Atack 077b3ac928
cli: change -netinfo optional arg from bool to int 2020-08-31 16:13:29 +02:00
Jon Atack 4e2f2ddd64
cli: add getpeerinfo last_{block,transaction} to -netinfo 2020-08-31 16:13:26 +02:00
Jon Atack 644be659ab
cli: add -netinfo server version check and error message 2020-08-31 16:13:17 +02:00
Jon Atack ce57bf6cc0
cli: create peer connections report sorted by dir, minping 2020-08-31 16:12:44 +02:00
Jon Atack f5edd66e5d
cli: create vector of Peer structs for peers data 2020-08-31 16:12:36 +02:00
Jon Atack 3a0ab93e1c
cli: add NetType enum struct and NetTypeEnumToString() 2020-08-31 16:12:04 +02:00
Jon Atack c227100919
cli: create local addresses, ports, and scores report 2020-08-31 16:12:01 +02:00
Jon Atack d3f77b736e
cli: create inbound/outbound peer connections report 2020-08-31 16:11:59 +02:00
Jon Atack 19377b2fd2
cli: start dashboard report with chain and version header 2020-08-31 16:11:51 +02:00
Jon Atack a3653c159e
cli: tally peer connections by type 2020-08-31 16:11:09 +02:00
fanquake c4be50fea3
remove usage of boost::bind
boost::bind usage was removed in #13743. However a new usage snuck in as
part of 2bc4c3eaf9 (#15225).
2020-08-31 19:34:57 +08:00
Samuel Dobson f98872f127
Merge #18244: rpc: fundrawtransaction and walletcreatefundedpsbt also lock manually selected coins
6d1f51343c [rpc] fundrawtransaction, walletcreatefundedpsbt lock manually selected coins (Sjors Provoost)

Pull request description:

  When using `fundrawtransaction` and `walletcreatefundedpsbt` with `lockUnspents`, it would only lock automatically selected coins, not manually selected coins. That doesn't make much sense to me if the goal is to prevent accidentally double-spending yourself before you broadcast a transaction.

  Note that when  creating a transaction, manually selected coins are automatic "unlocked" (or more accurately: the lock is ignored). Earlier versions of this PR introduced an error when a locked coin is manually selected, but this idea was abandoned after some discussion. An application that uses this RPC should either rely on automatic coin selection (with `lockUnspents`) or handle lock concurrency itself with manual coin selection. In particular it needs to make sure to avoid/pause calls with automatic coin selection between calling `lockunspent` and the subsequent spending RPC.

  See #7518 for historical background.

ACKs for top commit:
  meshcollider:
    Code review ACK 6d1f51343c
  fjahr:
    Code review ACK 6d1f51343c

Tree-SHA512: 8773c788d92f2656952e1beac147ba9956b8c5132d474e0880e4c89ff53642928b4cbfcd1cb3d17798b9284f02618a8830c93a9f7a4733e5bded96adff1d5d4d
2020-08-31 23:30:53 +12:00
Samuel Dobson 7721b31809
Merge #19773: wallet: Avoid recursive lock in IsTrusted
772ea4844c wallet: Avoid recursive lock in IsTrusted (João Barbosa)
819f10f671 wallet, refactor: Immutable CWalletTx::pwallet (João Barbosa)

Pull request description:

  This change moves `CWalletTx::IsTrusted` to `CWallet` in order to have TSAN. So now `CWallet::IsTrusted` requires `cs_wallet` and the recursive lock no longer happens.

  Motivated by https://github.com/bitcoin/bitcoin/pull/19289/files#r473308226.

ACKs for top commit:
  meshcollider:
    utACK 772ea4844c
  hebasto:
    ACK 772ea4844c, reviewed and tested on Linux Mint 20 (x86_64).

Tree-SHA512: 702ffd928b2f42a8b90de398790649a5fd04e1ac3877558da928e94cdeb19134883f06c3a73a6826c11c912facf199173375a70200737e164ccaea1bec515b2a
2020-08-31 22:45:27 +12:00
MarcoFalke 61b8c04d78
Merge #19379: tests: Add fuzzing harness for SigHasLowR(...) and ecdsa_signature_parse_der_lax(...)
46fcac1e4b tests: Add fuzzing harness for ec_seckey_import_der(...) and ec_seckey_export_der(...) (practicalswift)
b667a90389 tests: Add fuzzing harness for SigHasLowR(...) and ecdsa_signature_parse_der_lax(...) (practicalswift)

Pull request description:

  Add fuzzing harness for `SigHasLowR(...)` and `ecdsa_signature_parse_der_lax(...)`.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

ACKs for top commit:
  Crypt-iQ:
    ACK 46fcac1e4b

Tree-SHA512: 11a4856a1efd9a04030a8c8aee2413fd5be1ea248147e649a48a55bacdf732bb48a19ee1ce2761d47d4dd61c9598aec53061b961b319ad824d539dda11a8ccf4
2020-08-31 10:56:34 +02:00
MarcoFalke 269a7ccb27
Merge #19099: refactor: Move wallet methods out of chain.h and node.h
24bf17602c gui refactor: Inline SplashScreen::ConnectWallet (Russell Yanofsky)
e4f4350471 refactor: Move wallet methods out of chain.h and node.h (Russell Yanofsky)
b266b3e0bf refactor: Create interfaces earlier during initialization (Russell Yanofsky)

Pull request description:

  Add WalletClient interface so node interface is cleaner and don't need wallet-specific methods.

  The new NodeContext::wallet_client pointer will also be needed to eliminate global wallet variables like ::vpwallets in #19101, because createWallet(), loadWallet(), getWallets(), etc methods called by the GUI need a way to get a reference to the list of open wallets if it is no longer a global variable.

ACKs for top commit:
  promag:
    Code review ACK 24bf17602c.
  MarcoFalke:
    ACK 24bf17602c 🐚

Tree-SHA512: a70d3776cd6723093db8912028c50075ec5fa0a48b961cb1a945f922658f5363754f8380dbb8378ed128c8c858913024f8264740905b8121a35c0d63bfaed7cf
2020-08-31 10:10:57 +02:00
MarcoFalke afffbb1bc6
Merge #19710: bench: Prevent thread oversubscription and decreases the variance of result values
3edc4e34fe bench: Prevent thread oversubscription (Hennadii Stepanov)
ce3e6a7cb2 bench: Allow skip benchmark (Hennadii Stepanov)

Pull request description:

  Split out from #18710.

  Some results (borrowed from #18710):
  ![89121718-a3329800-d4c1-11ea-8bd1-66da20619696](https://user-images.githubusercontent.com/32963518/90146614-ecb89800-dd89-11ea-80fe-bac0e46e735e.png)

ACKs for top commit:
  fjahr:
    Code review ACK 3edc4e34fe

Tree-SHA512: df7413ec9ea326564a8e8de54752c9d1444ff7de34edb03e1e0c2120fc333e4640767fdbe3e87eab6a7b389a4863c02e22ad2ae0dbf139fad6a9b85e00f563b4
2020-08-31 08:29:27 +02:00
MarcoFalke 5c910a6b7a
Merge #19826: Pass mempool reference to chainstate constructor
fa0572d0f3 Pass mempool reference to chainstate constructor (MarcoFalke)

Pull request description:

  Next step toward #19556

  Instead of relying on the mempool global, each chainstate is given a reference to a mempool to keep up to date with the tip (block connections, disconnections, reorgs, ...)

ACKs for top commit:
  promag:
    Code review ACK fa0572d0f3.
  darosior:
    ACK fa0572d0f3
  hebasto:
    ACK fa0572d0f3, reviewed and tested on Linux Mint 20 (x86_64).

Tree-SHA512: 12184d33ae5797438d03efd012a07ba3e4ffa0d817c7a0877743f3d7a7656fe279280c751554fc035ccd0058166153b6c6c308a98b2d6b13998922617ad95c4c
2020-08-31 07:21:27 +02:00
fanquake 0adb80fe63
Merge #19803: Bugfix: Define and use HAVE_FDATASYNC correctly outside LevelDB
c4b85ba704 Bugfix: Define and use HAVE_FDATASYNC correctly outside LevelDB (Luke Dashjr)

Pull request description:

  Fixes a bug introduced in #19614

  The LevelDB-specific fdatasync check was only using `AC_SUBST`, which works for Makefiles, but doesn't define anything for C++. Furthermore, the #define is typically 0 or 1, never undefined.

  This fixes both issues by defining it and checking its value instead of whether it is merely defined.

  Pulled out of #14501 by fanquake's request

ACKs for top commit:
  fanquake:
    ACK c4b85ba704 - thanks for catching and fixing my mistake.
  laanwj:
     Code review ACK c4b85ba704

Tree-SHA512: 91d5d426ba000b4f3ee7e2315635e24bbb23ceff16269ddf4f65a63d25fc9e9cf94a3b236eed2f8031cc36ddcf78aeb5916efcb244f415943a8a12f907ede8f9
2020-08-31 13:07:24 +08:00
fanquake 21eda43cde
Merge #19828: wallet, refactor: Remove duplicate map lookups in GetAddressBalances
b35e74ba37 wallet, refactor: Remove duplicate map lookups in GetAddressBalances (João Barbosa)

Pull request description:

  Now just one lookup in `balances` instead of three.

ACKs for top commit:
  achow101:
    ACK b35e74ba37
  theStack:
    ACK b35e74ba37
  practicalswift:
    ACK b35e74ba37

Tree-SHA512: a73c1b336406a569e3bb10290618c5950b944db58ed0b05ff202d097684bb3ba3a5942c8d30443960052aa16438c054e2d02977b67aa901cce665c4df0ee5602
2020-08-31 10:24:18 +08:00
Jon Atack 54799b66b4
cli: add ipv6 and onion address type detection helpers 2020-08-30 22:37:45 +02:00
Jon Atack 12242b17a5
cli: create initial -netinfo option, NetinfoRequestHandler class 2020-08-30 22:37:06 +02:00
João Barbosa 413e0d1d31 Avoid callback when -blocknotify is empty 2020-08-30 17:38:27 +01:00
Anthony Towns 2ee7743fe7
sync.h: Make runtime lock checks require compile-time lock checks 2020-08-29 20:46:47 +03:00
Hennadii Stepanov 23d71d171e
Do not hide compile-time thread safety warnings 2020-08-29 20:46:23 +03:00
Hennadii Stepanov 3ddc150857
Add missed thread safety annotations
This is needed for upcoming commit "sync.h: Make runtime lock checks
require compile-time lock checks" to pass.
2020-08-29 20:46:23 +03:00
Hennadii Stepanov af9ea55a72
Use LockAssertion utility class instead of AssertLockHeld()
This change prepares for upcoming commit "Do not hide compile-time
thread safety warnings" by replacing AssertLockHeld() with
LockAssertion() where needed.
2020-08-29 20:43:23 +03:00
MarcoFalke baf9cedee8
Merge #18817: doc: Document differences in bitcoind and bitcoin-qt locale handling
ca185cf5a1 doc: Document differences in bitcoind and bitcoin-qt locale handling (practicalswift)

Pull request description:

  Document differences in `bitcoind` and `bitcoin-qt` locale handling.

  Since this seems to be the root cause to the locale dependency issues we've seen over the years I thought it was worth documenting :)

  Note that 1.) `QLocale` (used by Qt), 2.) C locale (used by locale-sensitive C standard library functions/POSIX functions and some parts of the C++ standard library such as `std::to_string`) and 3.) C++ locale (used by the C++ input/output library) are three separate things. This comment is about the perhaps surprising interference with the C locale (2) that takes place as part of the Qt initialization.

ACKs for top commit:
  hebasto:
    re-ACK ca185cf5a1

Tree-SHA512: e51c32f3072c506b0029a001d8b108125e1acb4f2b6a48a6be721ddadda9da0ae77a9b39ff33f9d9eebabe2244c1db09e8502e3e7012d7a5d40d98e96da0dc44
2020-08-29 10:03:45 +02:00
practicalswift ca185cf5a1 doc: Document differences in bitcoind and bitcoin-qt locale handling 2020-08-29 01:55:27 +00:00
Wladimir J. van der Laan 1cf73fb8eb
Merge #19607: [p2p] Add Peer struct for per-peer data in net processing
8e35bf5906 scripted-diff: rename misbehavior members (John Newbery)
1f96d2e673 [net processing] Move misbehavior tracking state to Peer (John Newbery)
7cd4159ac8 [net processing] Add Peer (John Newbery)
aba03359a6 [net processing] Remove CNodeState.name (John Newbery)

Pull request description:

  We currently have two structures for per-peer data:

  - `CNode` in net, which should just contain connection layer data (eg socket, send/recv buffers, etc), but currently also contains some application layer data (eg tx/block inventory).
  - `CNodeState` in net processing, which contains p2p application layer data, but requires cs_main to be locked for access.

  This PR adds a third struct `Peer`, which is for p2p application layer data, and doesn't require cs_main. Eventually all application layer data from `CNode` should be moved to `Peer`, and any data that doesn't strictly require cs_main should be moved from `CNodeState` to `Peer` (probably all of `CNodeState` eventually).

  `Peer` objects are stored as shared pointers in a net processing global map `g_peer_map`, which is protected by `g_peer_mutex`. To use a `Peer` object, `g_peer_mutex` is locked, a copy of the shared pointer is taken, and the lock is released. Individual members of `Peer` are protected by different mutexes that guard related data. The lifetime of the `Peer` object is managed by the shared_ptr refcount.

  This PR adds the `Peer` object and moves the misbehaving data from `CNodeState` to `Peer`. This allows us to immediately remove 15 `LOCK(cs_main)` instances.

  For more motivation see #19398

ACKs for top commit:
  laanwj:
    Code review ACK 8e35bf5906
  troygiorshev:
    reACK 8e35bf5906 via `git range-diff master 9510938 8e35bf5`
  theuni:
    ACK 8e35bf5906.
  jonatack:
    ACK 8e35bf5906 keeping in mind Cory's comment (https://github.com/bitcoin/bitcoin/pull/19607#discussion_r470173964) for the follow-up

Tree-SHA512: ad84a92b78fb34c9f43813ca3dfbc7282c887d55300ea2ce0994d134da3e0c7dbc44d54380e00b13bb75a57c28857ac3236bea9135467075d78026767a19e4b1
2020-08-28 20:29:16 +02:00
João Barbosa b35e74ba37 wallet, refactor: Remove duplicate map lookups in GetAddressBalances 2020-08-28 17:01:06 +01:00
MarcoFalke ca30d34cf9
Merge bitcoin-core/gui#39: Add visual accenting for the 'Create new receiving address' button
4ec49f8d1e qt: Leverage the default "Create new receiving address" button (Hennadii Stepanov)
4227a8e1f3 qt: Make "Create new receiving address" default unconditionally (Hennadii Stepanov)

Pull request description:

  Fix #24

  The first commit:
  - visual improvement with no behavior change

  The second commit:
  - removes a bunch of LOCs
  - slightly change behavior and makes it standard

  With this PR:
  ![DeepinScreenshot_select-area_20200721213040](https://user-images.githubusercontent.com/32963518/88093294-7b2a6700-cb9a-11ea-89a2-a0e2678056a7.png)

ACKs for top commit:
  Saibato:
    Concept tACK  4227a8e1f3 4ec49f8d1e
  promag:
    Tested ACK 4ec49f8d1e on macos.

Tree-SHA512: 3403d5ee96ec139491c7e23b24a24d9239fe55c58d99cbd4cd13bc877f76f992ed011c09e2af35b2a63be1a2371b95f6ac719325396dcc8333cf3eb7fa2e3d2c
2020-08-28 17:54:05 +02:00
MarcoFalke 5edef20a65
Merge #19797: net: Remove old check for 3-byte shifted IP addresses from pre-0.2.9 nodes
7b6d0f10a7 Remove old check for 3-byte shifted IP addresses from pre-0.2.9 node messages (Raúl Martínez (RME))

Pull request description:

  The change removes an old check for IPv6 addresses in range ::ff:ff00:0:0:0/72 that were created due to a bug in size field of addr messages for 0.2.8 nodes and before.

  This check is no longer needed as they are no more pre 0.2.9 nodes on the network (as per bitnodes network snapshot).

  Credits for discovering this go to sipa in https://github.com/bitcoin/bitcoin/pull/19628#discussion_r475907453

  Thanks for the attention!

ACKs for top commit:
  sipa:
    utACK 7b6d0f10a7
  vasild:
    ACK 7b6d0f1

Tree-SHA512: c5fab59dda2acafe143f607a4c5b636a54ac76fba651cad1ad1b09c94e88ab39503a31c2244c8f2664da68456c2a870c601d8894139c55cde9ece8161913ed2e
2020-08-28 17:51:37 +02:00
Wladimir J. van der Laan 9632b7edc7
Merge #19739: refactor: remove c-string interfaces for DecodeBase58{Check}
d3e8adfada util: remove c-string interfaces for DecodeBase58{Check} (Sebastian Falbesoner)

Pull request description:

  This micro-PR gets rid of base58 function interfaces that are redundant in terms of c-string / std::string variants; the c-string interface for `DecodeBase58Check` is completely unused outside the base58 module, while the c-string interface for `DecodeBase58` is only used in unit tests, where an implicit conversion to std::string is not problematic.

ACKs for top commit:
  practicalswift:
    ACK d3e8adfada -- patch looks correct
  laanwj:
    Code review ACK d3e8adfada

Tree-SHA512: 006a4a1e23b11385f60820c188b8e6b1634a182ca36e29a6580f72150214c65a3fdb273ec439165f26ba88a42d2bf5bab1cf3666a9eaee222fb4e1c00aeba433
2020-08-28 16:50:57 +02:00
Wladimir J. van der Laan 22acd36d53
Merge #19646: doc: Updated outdated help command for getblocktemplate
c91b241b48 Updated outdated help command for getblocktemplate (fixes #19625) (Jake Leventhal)

Pull request description:

  **Summary of Changes**
  * Removed coinbasetxn from the help outputs
  * Added the missing name for transactions in the help outputs
  * Added help outputs for longpollid and default_witness_commitment
  * Added more clarity to capabilities, rules, and coinbaseaux

  **Rationale**
  The outputs from the help command for `getblocktemplate` are outdated and don't reflect the actual results from `getblocktemplate` (see #19625 for more details)

  Fixes #19625.

ACKs for top commit:
  laanwj:
    ACK c91b241b48
  fjahr:
    utACK c91b241b48

Tree-SHA512: ee443af4bc3b2838dfd92e2705f344256ee785ae720e505fffea9b0ec5b75930e3b1374bae59b36d5da57c85c9aefe4d62504b028b893d6f2914dccf1e34c658
2020-08-28 15:24:16 +02:00
fanquake 1dac4dcf08
Merge #19758: Drop deprecated and unused GUARDED_VAR and PT_GUARDED_VAR annotations
9034f6e30e Drop deprecated and unused GUARDED_VAR and PT_GUARDED_VAR annotations (Hennadii Stepanov)

Pull request description:

  https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#guarded-var-and-pt-guarded-var:
  > `GUARDED_VAR` and `PT_GUARDED_VAR`
  > Use of these attributes has been deprecated.

ACKs for top commit:
  MarcoFalke:
    ACK 9034f6e30e They seem to be deprecated for a long time already https://releases.llvm.org/4.0.0/tools/clang/docs/ThreadSafetyAnalysis.html#guarded-var-and-pt-guarded-var

Tree-SHA512: d86f55fe57c28d91eda4a0ad727e36a5b35ba4b50a557c59b83cf0c5291cc5ad37b6f4ba6daeba3c1aba143faadaea6bb21c723f4d221856d6e6c42d228e8aa2
2020-08-28 20:36:40 +08:00
Raúl Martínez (RME) 7b6d0f10a7 Remove old check for 3-byte shifted IP addresses from pre-0.2.9 node messages
The change removes an old check for IPv6 addresses in range ::ff:ff00:0:0:0/72 that were created due to a bug in size field of addr messages for 0.2.8 nodes and before.

This check is no longer needed as they are no more pre 0.2.9 nodes on the network (as per bitnodes network snapshot).

Credits for discovering this go to sipa.
2020-08-28 14:17:28 +02:00
fanquake 4326515f01
Merge #19822: chain: Fix CChain comparison UB by removing it (it was unused)
df536883d2 chain: Remove UB CChain comparison (Carl Dong)

Pull request description:

  Comparing two empty `CChain`s is currently undefined behaviour, and resulted in false assertion failures when comparing identical empty `CChain`s in local testing.

  Let's just remove this comparison operator since it doesn't seem to be used anywhere.

ACKs for top commit:
  practicalswift:
    ACK df536883d2 -- patch is guaranteed to be correct :)
  MarcoFalke:
    cr ACK df536883d2

Tree-SHA512: db10bac364fc965b56abf7a5bac48018786b14806ffe107e3e8eb24d5004a29331f3387dfe3409a3452a6750d3329e3f354265d787ebb3abfccabe77b28a54d5
2020-08-28 19:44:47 +08:00
João Barbosa 772ea4844c wallet: Avoid recursive lock in IsTrusted 2020-08-28 10:42:18 +01:00
João Barbosa 819f10f671 wallet, refactor: Immutable CWalletTx::pwallet 2020-08-28 10:42:18 +01:00
MarcoFalke fa0572d0f3
Pass mempool reference to chainstate constructor 2020-08-28 10:42:04 +02:00
MarcoFalke 862fde88be
Merge #19067: tests: Add fuzzing harness for CNode
cc26fab48d tests: Add fuzzing harness for CNode (practicalswift)

Pull request description:

  Add fuzzing harness for `CNode`.

  See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md) for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the [Bitcoin Core fuzzing corpus repo](https://github.com/bitcoin-core/qa-assets).

  Happy fuzzing :)

Top commit has no ACKs.

Tree-SHA512: e6330e5de5b2eb44d3bd91a885e69ebb625bfd1cb2499338aeb3997ff0268848434e651126fe68a8cadd7235c391e61a40d6408ee26e457faf73572e0c375f6b
2020-08-28 08:30:57 +02:00
Carl Dong df536883d2
chain: Remove UB CChain comparison
It was unused, and had UB
2020-08-27 20:07:27 -04:00
MarcoFalke 15886b08aa
Merge bitcoin-core/gui#40: Clarify block height label
b6dcc6d741 gui: Clarify block height label (Hennadii Stepanov)

Pull request description:

  Prefer "block height" instead of "number of blocks".

  This was done while testing https://github.com/bitcoin/bitcoin/pull/16981.

ACKs for top commit:
  michaelfolkson:
    ACK b6dcc6d741. I don't think there are any other obvious examples in the GUI where "block height" should replace "number of blocks" except for translations.
  MarcoFalke:
    cr ACK b6dcc6d741

Tree-SHA512: ec3b48c1af5d613ed657ad51f2caddea774376736ecc02343d54518986e35ec37f1745b059814b5be92b5e5c2bb2970d17159b24c6e88b9316803d4de5327c31
2020-08-27 20:33:00 +02:00
Russell Yanofsky 24bf17602c gui refactor: Inline SplashScreen::ConnectWallet
Suggested https://github.com/bitcoin/bitcoin/pull/19099#discussion_r450522201
2020-08-27 14:33:00 -04:00
Russell Yanofsky e4f4350471 refactor: Move wallet methods out of chain.h and node.h
Add WalletClient interface so node interface is cleaner and don't need
wallet-specific methods.

The new NodeContext::wallet_client pointer will also be needed to eliminate
global wallet variables like ::vpwallets, because createWallet(), loadWallet(),
getWallets(), etc methods called by the GUI need a way to get a reference to
the list of open wallets if it is no longer a global variable.

Also tweaks splash screen registration for load wallet events to be delayed
until after wallet client is created.
2020-08-27 14:33:00 -04:00
Russell Yanofsky b266b3e0bf refactor: Create interfaces earlier during initialization
Add AppInitInterfaces function so wallet chain and chain client interfaces are
created earlier during initialization. This is needed in the next commit to
allow the gui splash screen to be able to register for wallet events through a
dedicated WalletClient interface instead managing wallets indirectly through
the Node interface. This only works if the wallet client interface is created
before the splash screen needs to use it.
2020-08-27 14:33:00 -04:00
MarcoFalke b987e657cd
Merge #19169: rpc: Validate provided keys for query_options parameter in listunspent
a99a3c0bd6 rpc: Validate provided keys for query_options parameter in listunspent (pasta)

Pull request description:

  At Dash, one of our developers was working with the `listunspent` RPC command, but instead of saying "minimumAmount" he said "minimmumAmount" as such the RPC wasn't working as expected.

  In https://github.com/dashpay/dash/pull/3507 we implemented a check so that `listunspent` returns an error if an unrecognized option is given. I figured I might as well adapt the code and throw up a PR here.

  Cheers!

ACKs for top commit:
  adaminsky:
    ACK `a99a3c0bd`
  meshcollider:
    Seems fine to me. utACK a99a3c0bd6

Tree-SHA512: 9fccf14979849879a51b352afa3e1932ce4a6cfc2ee97b8d405ec6e65673fe94e302795e3ec0b440e6d252f13acda620e1f6a0e86c3fa918883c3fb4600a372c
2020-08-27 20:17:25 +02:00
practicalswift cc26fab48d tests: Add fuzzing harness for CNode 2020-08-27 17:50:39 +00:00
Wladimir J. van der Laan 91af7ef831
Merge #19289: wallet: GetWalletTx and IsMine require cs_wallet lock
b8405b833a wallet: IsChange requires cs_wallet lock (João Barbosa)
d8441f30ff wallet: IsMine overloads require cs_wallet lock (João Barbosa)
a13cafc6c6 wallet: GetWalletTx requires cs_wallet lock (João Barbosa)

Pull request description:

  This change removes some unlock/lock and lock/lock cases regarding `GetWalletTx` and `IsMine` overloads.

ACKs for top commit:
  laanwj:
    Code review ACK b8405b833a
  ryanofsky:
    Code review ACK b8405b833a. Just new commit since last review changing IsChange GetChange locks and adding annotations

Tree-SHA512: 40d37c4fe5d10a1407f57d899d5822bb285633d8dbfad8afcf15a9b41b428ed9971a9a7b1aae84318371155132df3002699a15dab56e004527d50c889829187d
2020-08-27 16:21:37 +02:00
Jon Atack 407175e0c2
p2p: change CInv::type from int to uint32_t
fixes issue #19678 UBSan implicit-integer-sign-change

Credit to Eugene (Crypt-iQ) for finding and reporting the issue
and to Vasil Dimov (vasild) for the original suggestion
2020-08-27 10:57:20 +02:00
Gleb Naumenko 81b00f8780 Add indexing ADDR cache by local socket addr 2020-08-27 10:51:56 +03:00
Gleb Naumenko 42ec558542 Justify the choice of ADDR cache lifetime 2020-08-27 10:51:56 +03:00
Hennadii Stepanov 3edc4e34fe
bench: Prevent thread oversubscription
This change decreases the variance of benchmark results.
2020-08-26 13:00:00 +03:00
John Newbery fb56d37612
p2p: ensure inv is GenMsgTx before ToGenTxid in inv processing
and otherwise log that an unknown INV type was received.

In INV processing, when handling transaction type inv messages,
ToGenTxid() expects that we constructed the CInv ourselves or
that we verified that it is for a transaction type CInv.

Therefore, change this `else` branch into an `else if (inv.GenMsgTx())`
to make this safer and log any INVs that fall through.
2020-08-26 11:57:30 +02:00
Jon Atack 24ee4f01ea
p2p: make gtxid(.hash) and fAlreadyHave localvars const 2020-08-26 11:57:23 +02:00
Jon Atack b1c855453b
p2p: use CInv block message helpers in net_processing.cpp 2020-08-26 11:57:19 +02:00
John Newbery acd6642167
[net processing] Change AlreadyHaveTx() to take a GenTxid 2020-08-26 11:57:15 +02:00
John Newbery 5fdfb80b86
[net processing] Change AlreadyHaveBlock() to take block_hash argument 2020-08-26 11:57:11 +02:00
John Newbery 430e183b89
[net processing] Remove mempool argument from AlreadyHaveBlock() 2020-08-26 11:57:07 +02:00
John Newbery 42ca5618ca
[net processing] Split AlreadyHave() into separate block and tx functions 2020-08-26 11:57:03 +02:00
Jon Atack 39f1dc9445
p2p: remove nFetchFlags from NetMsgType TX and INV processing
The nFetchFlags code can be removed here because GetFetchFlags() can only add
the MSG_WITNESS_FLAG, which is added to the CInv::type field. That CInv is only
passed to AlreadyHave() or ToGenTxid(), and neither of those functions do
anything different depending on whether the CInv type is MSG_TX or
MSG_WITNESS_TX.

Co-authored by: John Newbery <john@johnnewbery.com>
2020-08-26 11:56:59 +02:00
Jon Atack 471714e1f0
p2p: add CInv block message helper methods 2020-08-26 11:56:55 +02:00
Russell Yanofsky 519cae8fd6 gui: Delay interfaces::Node initialization
This is needed to allow bitcoin-gui to connect to existing node process with
-ipcconnect instead of spawning a new process. It's possible to spawn a new
bitcoin-node process without knowing the current data dir or network, but
connecting to an existing bitcoin-node requires knowing the datadir and network
first.
2020-08-26 05:52:31 -04:00
Russell Yanofsky 102abff9eb gui: Replace interface::Node references with pointers
No change in behavior. Replacing references with pointers allows Node interface
creation to be delayed until later during gui startup next commit to support
implementing -ipcconnect option
2020-08-26 05:52:31 -04:00
Russell Yanofsky 91aced7c7e gui: Remove unused interfaces::Node references
Remove Node references no longer needed after previous commit
2020-08-26 05:52:31 -04:00
Russell Yanofsky e133631625 gui: Partially revert #10244 gArgs and Params changes
Change gui code to use gArgs, Params() functions directly instead of going
through interfaces::Node.

Remotely accessing bitcoin-node ArgsManager from bitcoin-gui works fine in
https://github.com/bitcoin/bitcoin/pull/10102, when bitcoin-gui spawns a new
bitcoin-node process and controls its startup, but for bitcoin-gui to support
-ipcconnect option in https://github.com/bitcoin/bitcoin/pull/19461 and connect
to an existing bitcoin-node process, it needs ability to parse arguments itself
before connecting out.

This change also simplifies https://github.com/bitcoin/bitcoin/pull/10102 a
bit, by making the bitcoin-gui -> bitcoin-node startup sequence more similar to
the bitcoin-node -> bitcoin-wallet startup sequence where the parent process
parses arguments and passes them to the child process instead of the parent
process using the child process to parse arguments.
2020-08-26 05:52:31 -04:00
MarcoFalke a12d9e5fd2
Merge #19687: refactor: make EncodeBase{32,64} consume Spans
e2aa1a585a util: make EncodeBase64 consume Spans (Sebastian Falbesoner)
2bc207190e util: make EncodeBase32 consume Spans (Sebastian Falbesoner)

Pull request description:

  To simplify the interface of the Base32/Base64 encoding functions for raw data, this PR changes them from taking two arguments (pointer and length) to just one Span. Most calls to `EncodeBase64` pass data from `CDataStream` instances, which unfortunately internally work with `char*` pointers rather than `unsigned char*`, but thanks to the recently introduced `MakeUCharSpan` helper, converting them is quite easy.

ACKs for top commit:
  MarcoFalke:
    ACK e2aa1a585a 🐮
  vasild:
    ACK e2aa1a585

Tree-SHA512: 43bd3bd2ee8e3be2474db0a81dae9d9e88fac2464b96d1b042147106ed7433799dcba3000c69990511ecfc697b0c7306ce85f2ecb2293e2e44fd356c9694b150
2020-08-26 11:52:31 +02:00
fanquake 6a2ba62685
Merge #19779: Remove gArgs global from init
fa9d5902f7 scripted-diff: gArgs -> args (MarcoFalke)
fa33bc2dab init: Capture copy of blocknotify setting for BlockNotifyCallback (MarcoFalke)
fa40017706 init: Pass reference to ArgsManager around instead of relying on global (MarcoFalke)

Pull request description:

  The gArgs global has several issues:

  * gArgs is used by each process (bitcoind, bitcoin-qt, bitcoin-wallet, bitcoin-cli, bitcoin-tx, ...), but it is hard to determine which arguments are actually used by each process. For example arguments that have never been registered, but are still used, will always return the fallback value.
  * Tests may run several sub-tests, which need different settings. So globals will have to be overwritten, but that is fragile on its own: e.g. https://github.com/bitcoin/bitcoin/pull/19704#issuecomment-678259092 or #19511

  The goal is to remove gArgs, but as a first step in that direction this pull will change gArgs in init to use a passed-in reference instead.

ACKs for top commit:
  ryanofsky:
    Code review ACK fa9d5902f7. Looks good. Nice day to remove some globals, and add some lambdas 👍
  fanquake:
    ACK fa9d5902f7 - I'm not as familiar with the settings & argument handling code, but this make sense, and is a step in the right direction towards a reduction in the usage of globals. Not a huge fan of the clang-formatting in the scripted diff.
  jonasschnelli:
    Concept ACK fa9d5902f7

Tree-SHA512: ed00db5f826566c7e3b4d0b3d2ee0fc1a49a6e748e04e5c93bdd694ac7da5598749e73937047d5fce86150d764a067d2ca344ba4ae3eb2704cc5c4fa0d20940f
2020-08-26 15:18:38 +08:00
fanquake 92735e45ba
Merge #19775: test: Activate segwit in TestChain100Setup
fad84b7e14 test: Activate segwit in TestChain100Setup (MarcoFalke)
fa11ff2980 test: Pass empty tx pool to block assembler (MarcoFalke)
fa96574b0d test: Move doxygen comment to header (MarcoFalke)

Pull request description:

  This fixes not only a TODO in the code, but also prevents a never ending source of uninitialized reads. E.g.

  * #18376
  * https://github.com/bitcoin/bitcoin/pull/19704#issuecomment-678259092
  * ...

ACKs for top commit:
  jnewbery:
    utACK fad84b7e14

Tree-SHA512: 64cf16a59656d49e022b603f3b06441ceae35a33a4253b4382bc8a89a56e08ad5412c8fa734d0fc7b58586f40ea6d57b348a3b4838bc6890a41ae2ec3902e378
2020-08-26 13:17:35 +08:00
Andrew Chow 0bbe26a1af wallet: filter for keys only before record deser in salvage
When salvaging a wallet, avoid deserializing any records that we don't
care about, i.e. filter for keys only before the deserialization.
2020-08-25 13:23:40 -04:00
Andrew Chow 544e12a4e8 walletdb: Add KeyFilterFn to ReadKeyValue
Add a KeyFilterFn callback to ReadKeyValue which allows the caller to
specify which types to actually deserialize. A KeyFilterFn takes the
type as the parameter and returns a bool indicating whether
deserialization should continue.
2020-08-25 13:23:40 -04:00
Sebastian Falbesoner e2aa1a585a util: make EncodeBase64 consume Spans 2020-08-25 18:52:57 +02:00
Sebastian Falbesoner 2bc207190e util: make EncodeBase32 consume Spans 2020-08-25 18:52:51 +02:00
Luke Dashjr c4b85ba704 Bugfix: Define and use HAVE_FDATASYNC correctly outside LevelDB 2020-08-25 16:46:00 +00:00
MarcoFalke 8d6224fefe
Merge #19628: net: change CNetAddr::ip to have flexible size
102867c587 net: change CNetAddr::ip to have flexible size (Vasil Dimov)
1ea57ad674 net: don't accept non-left-contiguous netmasks (Vasil Dimov)

Pull request description:

  (chopped off from #19031 to ease review)

  Before this change `CNetAddr::ip` was a fixed-size array of 16 bytes,
  not being able to store larger addresses (e.g. TORv3) and encoded
  smaller ones as 16-byte IPv6 addresses.

  Change its type to `prevector`, so that it can hold larger addresses and
  do not disguise non-IPv6 addresses as IPv6. So the IPv4 address
  `1.2.3.4` is now encoded as `01020304` instead of
  `00000000000000000000FFFF01020304`.

  Rename `CNetAddr::ip` to `CNetAddr::m_addr` because it is not an "IP" or
  "IP address" (TOR addresses are not IP addresses).

  In order to preserve backward compatibility with serialization (where
  e.g. `1.2.3.4` is serialized as `00000000000000000000FFFF01020304`)
  introduce `CNetAddr` dedicated legacy serialize/unserialize methods.

  Adjust `CSubNet` accordingly. Still use `CSubNet::netmask[]` of fixed 16
  bytes, but use the first 4 for IPv4 (not the last 4). Do not accept
  invalid netmasks that have 0-bits followed by 1-bits and only allow
  subnetting for IPv4 and IPv6.

  Co-authored-by: Carl Dong <contact@carldong.me>

ACKs for top commit:
  sipa:
    utACK 102867c587
  MarcoFalke:
    Concept ACK 102867c587
  ryanofsky:
    Code review ACK 102867c587. Just many suggested updates since last review. Thanks for following up on everything!
  jonatack:
    re-ACK 102867c587 diff review, code review, build/tests/running bitcoind with ipv4/ipv6/onion peers
  kallewoof:
    ACK 102867c587

Tree-SHA512: d60bf716cecf8d3e8146d2f90f897ebe956befb16f711a24cfe680024c5afc758fb9e4a0a22066b42f7630d52cf916318bedbcbc069ae07092d5250a11e8f762
2020-08-25 18:10:25 +02:00
fanquake f8462a6d27
Merge #19601: Refactoring CHashWriter & Get{Prevouts,Sequence,Outputs}Hash to SHA256 (Alternative to #18071)
9ab4cafabd Refactor Get{Prevout,Sequence,Outputs}Hash to Get{Prevouts,Sequences,Outputs}SHA256. (Jeremy Rubin)
6510d0ff41 Add SHA256Uint256 helper functions (Jeremy Rubin)
b475d7d0fa Add single sha256 call to CHashWriter (Jeremy Rubin)

Pull request description:

  Opened as an alternative to #18071 to be more similar to #17977.

  I'm fine with either, deferring to others.

  cc jnewbery Sjors

ACKs for top commit:
  jnewbery:
    Code review ACK 9ab4cafabd
  jonatack:
    Tested ACK 9ab4caf
  fjahr:
    tested ACK 9ab4cafabd
  instagibbs:
    reACK 9ab4cafabd

Tree-SHA512: 93a7a47697f1657f027b18407bdcce16963f6b23d12372e7ac8fd4ee96769b3e2639369f9956fee669cc881b6338641cddfeeef1516c7104cb50ef4b880bb0a7
2020-08-25 20:18:40 +08:00
fanquake 8e0f341779
Merge #15704: Move Win32 defines to configure.ac to ensure they are globally defined
1ccb9f30c0 Move Win32 defines to configure.ac to ensure they are globally defined (Luke Dashjr)

Pull request description:

  #9245 no longer needs this, since the main `_WIN32_WINNT` got bumped by something else.

  So rather than just lose it, might as well get it merged in independently.

  I'm not aware of any practical effects, but it seems safer to use the same API versions everywhere.

ACKs for top commit:
  fanquake:
    ACK 1ccb9f30c0 - checked that the binaries produced are the same.

Tree-SHA512: 273e9186579197be01b443b6968e26b9a8031d356fabc5b73aa967fcdb837df195b7ce0fc4e4529c85d9b86da6f2d7ff1bf56a3ff0cbbcd8cee8a9c2bf70a244
2020-08-25 11:52:52 +08:00
Vasil Dimov 102867c587
net: change CNetAddr::ip to have flexible size
Before this change `CNetAddr::ip` was a fixed-size array of 16 bytes,
not being able to store larger addresses (e.g. TORv3) and encoded
smaller ones as 16-byte IPv6 addresses.

Change its type to `prevector`, so that it can hold larger addresses and
do not disguise non-IPv6 addresses as IPv6. So the IPv4 address
`1.2.3.4` is now encoded as `01020304` instead of
`00000000000000000000FFFF01020304`.

Rename `CNetAddr::ip` to `CNetAddr::m_addr` because it is not an "IP" or
"IP address" (TOR addresses are not IP addresses).

In order to preserve backward compatibility with serialization (where
e.g. `1.2.3.4` is serialized as `00000000000000000000FFFF01020304`)
introduce `CNetAddr` dedicated legacy serialize/unserialize methods.

Adjust `CSubNet` accordingly. Still use `CSubNet::netmask[]` of fixed 16
bytes, but use the first 4 for IPv4 (not the last 4). Only allow
subnetting for IPv4 and IPv6.

Co-authored-by: Carl Dong <contact@carldong.me>
2020-08-24 21:50:59 +02:00
Vasil Dimov 1ea57ad674
net: don't accept non-left-contiguous netmasks
A netmask that contains 1-bits after 0-bits (the 1-bits are not
contiguous on the left side) is invalid [1] [2].

The code before this PR used to parse and accept such
non-left-contiguous netmasks. However, a coming change that will alter
`CNetAddr::ip` to have flexible size would make juggling with such
netmasks more difficult, thus drop support for those.

[1] https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#Subnet_masks
[2] https://tools.ietf.org/html/rfc4632#section-5.1
2020-08-24 21:50:59 +02:00
Jon Atack 581b343d5b
Add in/out connections to cli -getinfo 2020-08-24 18:41:24 +02:00
Jon Atack d9cc13e88d
UNIX_EPOCH_TIME fixup in rpc getnettotals 2020-08-24 18:41:22 +02:00
Jon Atack 1ab49b81cf
Add in/out connections to rpc getnetworkinfo 2020-08-24 18:41:14 +02:00
Wladimir J. van der Laan 7f609f68d8
Merge #19731: net, rpc: expose nLastBlockTime/nLastTXTime as last block/last_transaction in getpeerinfo
5da96210fc doc: release note for getpeerinfo last_block/last_transaction (Jon Atack)
cfef5a2c98 test: rpc_net.py logging and test naming improvements (Jon Atack)
21c57bacda test: getpeerinfo last_block and last_transaction tests (Jon Atack)
8a560a7d57 rpc: expose nLastBlockTime/TXTime as getpeerinfo last_block/transaction (Jon Atack)
02fbe3ae0b net: add nLastBlockTime/TXTime to CNodeStats, CNode::copyStats (Jon Atack)

Pull request description:

  This PR adds inbound peer eviction criteria `nLastBlockTime` and `nLastTXTime` to `CNodeStats` and `CNode::copyStats`, which then allows exposing them in the next commit as `last_transaction` and `last_block` Unix Epoch Time fields in RPC `getpeerinfo`.

  This may be useful for writing missing eviction tests. I'd also like to add `lasttx` and `lastblk` columns to the `-netinfo` dashboard as described in https://github.com/bitcoin/bitcoin/pull/19643#issuecomment-671093420.

  Relevant discussion at the p2p irc meeting http://www.erisian.com.au/bitcoin-core-dev/log-2020-08-11.html#l-549:
  ```text
  <jonatack> i was specifically trying to observe and figure out how to test https://github.com/bitcoin/bitcoin/issues/19500
  <jonatack> which made me realise that i didn't know what was going on with my peer conns in enough detail
  <jonatack> i'm running bitcoin locally with nLastBlockTime and nLastTXTime added to getpeerinfo for my peer connections dashboard
  <jonatack> sipa: is there a good reason why that (eviction criteria) data is not exposed through getpeerinfo currently?
  <sipa> jonatack: nope; i suspect just nobody ever added it
  <jonatack> sipa: thanks. will propose.
  ```

  The last commit is optional, but I think it would be good to have logging in `rpc_net.py`.

ACKs for top commit:
  jnewbery:
    Code review ACK 5da96210fc
  theStack:
    Code Review ACK 5da96210fc
  darosior:
    ACK 5da96210fc

Tree-SHA512: 2db164bc979c014837a676e890869a128beb7cf40114853239e7280f57e768bcb43bff6c1ea76a61556212135281863b5290b50ff9d24fce16c5b89b55d4cd70
2020-08-24 17:03:07 +02:00
fanquake 4fefd80f08
Merge #19704: Net processing: move ProcessMessage() to PeerLogicValidation
daed542a12 [net_processing] Move ProcessMessage to PeerLogicValidation (John Newbery)
c556770b5e [net_processing] Change PeerLogicValidation to hold a connman reference (John Newbery)

Pull request description:

  Rather than ProcessMessage() being a static function in net_processing.cpp, make it a private member function of PeerLogicValidation. This is the start of moving static functions and global variables into PeerLogicValidation to make it better encapsulated.

ACKs for top commit:
  jonatack:
    ACK daed542a12 code review and debug tested
  promag:
    Code review ACK daed542a12.
  MarcoFalke:
    re-ACK daed542a12, only change is removing second commit 🎴
  theStack:
    Code Review ACK daed542a12

Tree-SHA512: ddebf410d114d9ad5a9e536950018ff333a347c035d74fcc101fb4a3f20a281782c7eac2b7d1bd1c8f6bc7e59f5b5630fb52c2e1b4c32df454fa584673bd021e
2020-08-24 21:50:37 +08:00
MarcoFalke fa9d5902f7
scripted-diff: gArgs -> args
-BEGIN VERIFY SCRIPT-
 # Replace gArgs with args
 sed -i 's/\<gArgs\>/args/g' src/init.cpp src/bitcoind.cpp
 sed -i 's/&args;/\&gArgs;/g' src/init.cpp

 # Format changed lines
 git diff -U0 | clang-format-diff -p1 -i -v
-END VERIFY SCRIPT-
2020-08-24 07:52:17 +02:00
MarcoFalke fa33bc2dab
init: Capture copy of blocknotify setting for BlockNotifyCallback
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2020-08-24 07:51:48 +02:00
MarcoFalke fa40017706
init: Pass reference to ArgsManager around instead of relying on global 2020-08-24 07:45:17 +02:00
MarcoFalke fad84b7e14
test: Activate segwit in TestChain100Setup 2020-08-21 18:44:52 +02:00
MarcoFalke fa11ff2980
test: Pass empty tx pool to block assembler 2020-08-21 18:44:50 +02:00
MarcoFalke fa96574b0d
test: Move doxygen comment to header
Also, unrelated formatting fixups.

Can be reviewed with --word-diff-regex=.
2020-08-21 18:44:27 +02:00
Nadav Ivgi 4148f55dd0
docs: Correct description for getblockstats's txs field
It does count the coinbase transaction.

Refs #19766
2020-08-21 17:41:02 +03:00
John Newbery daed542a12 [net_processing] Move ProcessMessage to PeerLogicValidation 2020-08-21 13:10:41 +01:00
fanquake 0d9e14a646
Merge #19733: Move comment about BaseIndex::DB from TxIndex::DB
8ed2f1ed78 Remove unused includes (Marcin Jachymiak)
cf095a53fc Move comment about BaseIndex::DB from TxIndex::DB (Marcin Jachymiak)

Pull request description:

  Moves a comment about the `BaseIndex::DB` from the `TxIndex::DB` into the correct place. Originally part of https://github.com/bitcoin/bitcoin/pull/14053.

ACKs for top commit:
  fanquake:
    ACK 8ed2f1ed78

Tree-SHA512: cb4e2b916c7ab996961cc2e1d910bc4b8a1700eb32b70fc1657ca720117a7a84f7337fe5e4fb30e047aa92c31eaa976eaaa5cb8f861877f2ff6f4a59bb94f4e9
2020-08-21 12:48:46 +08:00
João Barbosa b8405b833a wallet: IsChange requires cs_wallet lock 2020-08-21 00:28:10 +01:00
Luke Dashjr 916d3596c4 help: Generate checkpoint height from chainparams 2020-08-20 18:20:27 +00:00
Luke Dashjr 1ccb9f30c0 Move Win32 defines to configure.ac to ensure they are globally defined
common.vcxproj used for MSVC builds
2020-08-20 17:55:06 +00:00
Wladimir J. van der Laan 27eeb0337b
Merge #19550: rpc: Add getindexinfo RPC
124e1ee134 doc: Add release notes for getindexinfo RPC (Fabian Jahr)
c447b09458 test: Add tests for getindexinfo RPC (Fabian Jahr)
667bc7a7f7 rpc: Add getindexinfo RPC (Fabian Jahr)

Pull request description:

  As I was playing with indices a I was missing an RPC that gives information about the active indices in the node. I think this can be helpful for many users, especially since there are some new index candidates coming up (#14053, #18000) that can give a quick overview without the user having to parse the logs.

  Feature summary:
  - Adds new RPC `listindices` (placed in Util section)
  - That RPC only lists the actively running indices
  - For each index it gives the name, whether it is synced and up to which block height it is synced

ACKs for top commit:
  laanwj:
    Re-ACK 124e1ee134
  jonatack:
    Code review re-ACK 124e1ee per `git range-diff a57af89 47a5372 124e1ee` no change since my last re-ACK, rebase only

Tree-SHA512: 3b7174c87951e6457fef099f530337803906baf32fb64261410b8def2c0917853d6a1bf3059cd590b1cc1523608f8916dafb327a431d27ecbf8d7454406b5b35
2020-08-20 16:00:22 +02:00
fanquake 44f66d2f10
Merge #19765: doc: Fix getmempoolancestors RPC result doc
333329dbda doc: Fix getmempoolancestor RPC result doc (MarcoFalke)

Pull request description:

ACKs for top commit:
  laanwj:
    ACK 333329dbda

Tree-SHA512: 30a7568ec15d1af0c484b4d479e14ec3609a01b76f17f8285688b0c5e5b0480926bbf6f651da91193b66fd752e83e9707e4b08c52b69f8c670c430da84713359
2020-08-20 08:56:37 +08:00
Wladimir J. van der Laan e9b3012654
Merge #19750: refactor: remove unused c-string variant of atoi64()
71e0f07e9c util: remove unused c-string variant of atoi64() (Sebastian Falbesoner)

Pull request description:

  This is another micro-PR "removing old cruft with potentially sharp edges" (quote by practicalswift, see #19739). Gets rid of the c-string variant of the function `atoi64()`, which is only used in fuzzers and on one place with `wallet/wallet.h` (where it is originally a `std::string` anyways and uses `.c_str()` -- this method call can simply be removed.)

ACKs for top commit:
  practicalswift:
    ACK 71e0f07e9c -- diff looks correct
  laanwj:
    ACK 71e0f07e9c

Tree-SHA512: 4d1d28e2f5274fdbe0652e7a0f83dd416f4d19c1e1a49979927960a3ad40b0990eeaa4374656bf2c6998a965a14d62c1bc78303b7d583d3307c17828030a8e3b
2020-08-19 15:04:34 +02:00
Wladimir J. van der Laan 44ddcd887d
Merge #19706: refactor: make EncodeBase58{Check} consume Spans
356988e200 util: make EncodeBase58Check consume Spans (Sebastian Falbesoner)
f0fce0675d util: make EncodeBase58 consume Spans (Sebastian Falbesoner)

Pull request description:

  This PR improves the interfaces for the functions `EncodeBase58{Check}` by using Spans, in a similar fashion to e.g. PRs #19660, #19687. Note that on the master branch there are currently two versions of `EncodeBase58`: one that takes two pointers (marking begin and end) and another one that takes a `std::vector<unsigned char>` const-ref. The PR branch only leaves one generic Span-interface, both simplifying the interface and allowing more generic containers to be passed. The same is done for `EncodeBase58Check`, where only one interface existed but it's more generic now (e.g. a std::array can be directly passed, as done in the benchmarks).

ACKs for top commit:
  laanwj:
    Code review ACK 356988e200

Tree-SHA512: 47cfccdd7f3a2d4694bb8785e6e5fd756daee04ce1652ee59a7822e7e833b4a441ae9362b9bd67ea020d2b5b7d927629c9addb6abaa9881d8564fd3b1257f512
2020-08-19 14:20:15 +02:00
MarcoFalke 333329dbda
doc: Fix getmempoolancestor RPC result doc 2020-08-19 10:41:27 +02:00
Marcin Jachymiak 8ed2f1ed78 Remove unused includes 2020-08-18 21:47:59 -04:00
Marcin Jachymiak cf095a53fc Move comment about BaseIndex::DB from TxIndex::DB 2020-08-18 21:47:59 -04:00
practicalswift 46fcac1e4b tests: Add fuzzing harness for ec_seckey_import_der(...) and ec_seckey_export_der(...) 2020-08-18 18:03:57 +00:00
practicalswift b667a90389 tests: Add fuzzing harness for SigHasLowR(...) and ecdsa_signature_parse_der_lax(...) 2020-08-18 18:03:56 +00:00
Karl-Johan Alm 7e31ea9fa0
-maxapsfee: follow-up fixes
Co-authored-by: Jon Atack <jon@atack.com>
Co-authored-by: Samuel Dobson <dobsonsa68@gmail.com>
2020-08-18 19:24:39 +09:00
Hennadii Stepanov 9034f6e30e
Drop deprecated and unused GUARDED_VAR and PT_GUARDED_VAR annotations 2020-08-18 10:46:53 +03:00
fanquake f2d1b9881f
Merge #19721: p2p: comment out unused MSG_FILTERED_WITNESS_BLOCK
4792cad88c doc: comment out and add annotation to unused MSG_FILTERED_WITNESS_BLOCK (Adam Jonas)

Pull request description:

  Commenting out and adding a note to unused `MSG_FILTERED_WITNESS_BLOCK` [defined in BIP144](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki#relay).

  There was an attempt to make use of this in https://github.com/bitcoin/bitcoin/pull/10350, but it was closed due to lack of support. (h/t sdaftuar for pointing to the PR and jnewbery for the idea)

ACKs for top commit:
  jnewbery:
    Obvious ACK 4792cad88c
  theStack:
    ACK 4792cad88c 📜
  MarcoFalke:
    cr ACK 4792cad88c good to keep it around in a comment to avoid accidental future re-assignment
  practicalswift:
    ACK 4792cad88c

Tree-SHA512: 22327ddded643ae50fdb529e4529a9b464f74e90620d0d2079a11070eaa8afe8363f6e14cca52f3bec2c9f87ee13e318edc6c5193761c94b8ae77be353a8da1f
2020-08-18 12:15:48 +08:00
fanquake 53dac67a97
Merge #19719: build: Add Werror=range-loop-analysis
fa55c1d5fd build: Add Werror=range-loop-analysis (MarcoFalke)

Pull request description:

  The warning is implicitly enabled for Bitcoin Core. Also explicitly since commit d92204c900.

  To avoid "fix range loop" follow-up refactors, we have two options:

  * Disable the warning, so that issues never appear
  * Enable it as an error, so that issues are either caught locally or by ci

ACKs for top commit:
  fanquake:
    ACK fa55c1d5fd
  practicalswift:
    ACK fa55c1d5fd -- pre-review fix-up is better than post-review fix-up
  hebasto:
    re-ACK fa55c1d5fd

Tree-SHA512: 019aa133f254af8882c1d5d10c420d9882305db0fc2aa9dad7d285168e2556306c3eedcc03bd30e63f11eae4cc82b648d83fb6e9179d6a6364651fb602d70134
2020-08-18 11:33:34 +08:00
Sebastian Falbesoner 71e0f07e9c util: remove unused c-string variant of atoi64() 2020-08-17 17:56:59 +02:00
Sebastian Falbesoner d3e8adfada util: remove c-string interfaces for DecodeBase58{Check} 2020-08-17 13:16:09 +02:00
MarcoFalke 1bc8e8eae2
Merge #19734: Move CDiskTxPos to its own file
7668db3b08 Move only: Move CDiskTxPos to its own file (Marcin Jachymiak)

Pull request description:

  Moves `CDiskTxPos` it its own file so it can be used without the `txindex.h` include elsewhere. Originally part of #14053.

ACKs for top commit:
  jnewbery:
    utACK 7668db3b08
  promag:
    ACK 7668db3b08.

Tree-SHA512: b108e980ad04e43d1323410c3683a82bed70aee7795f5d8a2afbaf32a07ba598571f00b047bdde15048124b17178bcbd10654c48461beac988e9643cb2df664c
2020-08-17 12:47:11 +02:00
Samuel Dobson c831e105c5
Merge #14582: wallet: always do avoid partial spends if fees are within a specified range
7f13dfb587 test: test the implicit avoid partial spends functionality (Karl-Johan Alm)
b82067bf69 wallet: try -avoidpartialspends mode and use its result if fees are below threshold (Karl-Johan Alm)

Pull request description:

  The `-avoidpartialspends` feature is normally disabled, as it may affect the optimal fee for payments. This PR introduces a new parameter `-maxapsfee` (max avoid partial spends fee) which acts on the following values:
  * -1: disable partial spend avoidance completely (do not even try it)
  * 0: only do partial spend avoidance if fees are the same or better as the regular coin selection
  * 1..∞: use APS variant if the absolute fee difference is less than or equal to the max APS fee

  For values other than -1, the code will now try partial spend avoidance once, and if that gives a value within the accepted range, it will use that.

  Example: -maxapsfee=0.00001000 means the wallet will do regular coin select, APS coin select, and then pick AKS iff the absolute fee difference is <= 1000 satoshi.

  Edit: updated this to reflect the fact we are now using a max fee.

ACKs for top commit:
  fjahr:
    tested ACK 7f13dfb587
  achow101:
    ACK 7f13dfb587
  jonatack:
    ACK 7f13dfb58, code review, debug build, verified the test fails with `AssertionError: not(2 == 1)` for the number of vouts when `-maxapsfee=0.0001` is changed to 0, and verified the new logging with an added assertion.
  meshcollider:
    Code review ACK 7f13dfb587

Tree-SHA512: 475929df57f6191bb4e36bfbcad5a280a64bb0ecd8767b76cb2e44e2301235d0eb294a3f2fac5bbf15d35d7ecfba47acb2285feadb883c9ce31c08377e3afb3c
2020-08-17 16:18:28 +12:00
João Barbosa d8441f30ff wallet: IsMine overloads require cs_wallet lock 2020-08-17 00:06:03 +01:00
João Barbosa a13cafc6c6 wallet: GetWalletTx requires cs_wallet lock 2020-08-17 00:06:02 +01:00
Wladimir J. van der Laan ffad348167
Merge #19705: Shrink CAddress from 48 to 40 bytes on x64
767073fb96 Shrink CAddress from 48 to 40 bytes on x64 (Vasil Dimov)

Pull request description:

  `CAddress` inherits `CService` which is 28 bytes (on 64 bit machines).
  `CAddress` then adds two member variables - one that requires 4 byte
  alignment (`nTime`) and one that requires 8 byte alignment
  (`nServices`).

  Declare the smaller one first so that it fits in bytes 29..32.

  On 32 bit machines this change has no effect and `CAddress` remains 40
  bytes.

ACKs for top commit:
  laanwj:
    ACK 767073fb96
  theStack:
    ACK 767073fb96

Tree-SHA512: 73d6a4fcfa2687b4076950801871252e369510ecf09f820576dbeca9ee3ee94d14672e7d5596cb45fedd9e4b973dd0716a2ea3f13fc3058b4b697d036a7c9db0
2020-08-16 18:56:25 +02:00
Fabian Jahr 667bc7a7f7
rpc: Add getindexinfo RPC 2020-08-16 11:15:49 +02:00
Marcin Jachymiak 7668db3b08 Move only: Move CDiskTxPos to its own file 2020-08-15 18:23:55 -04:00
Jake Leventhal c91b241b48 Updated outdated help command for getblocktemplate (fixes #19625)
* Removed coinbasetxn from the getblocktemplate help outputs
* Added the missing name for transactions in the help outputs
* Added getblocktemplate help outputs for longpollid and default_witness_commitment
* Added more clarity to capabilities, rules, and coinbaseaux for getblocktemplate help (credit to luke-jr)

Co-authored-by: Luke Dashjr <luke+github_public@dashjr.org>
2020-08-15 13:06:03 -07:00
Jon Atack 8a560a7d57
rpc: expose nLastBlockTime/TXTime as getpeerinfo last_block/transaction 2020-08-15 14:34:37 +02:00
Jon Atack 02fbe3ae0b
net: add nLastBlockTime/TXTime to CNodeStats, CNode::copyStats 2020-08-15 12:03:16 +02:00
Pieter Wuille 86d4cf42d9 Increase the ip address relay branching factor for unreachable networks
Onion addresses propagate very badly among the IPv4/IPv6 network, resulting
in difficulty for those to find each other.

The branching factor 1 is probably so low that propagations die out before
they reach another onion peer. Increase it to 1.5 on average.
2020-08-14 23:02:42 -07:00
fanquake 4cde97374d
Merge #19718: build: Add missed gcov files to 'make clean'
6cb8771173 build: Add missed gcov files to 'make clean' (Hennadii Stepanov)

Pull request description:

  On master (b4d0366b47):
  ```
  $ ./autogen.sh
  $ ./configure --enable-lcov
  $ make && make cov
  $ make clean
  $ find . -name '*.gcno'
  ./src/rpc/libbitcoin_server_a-blockchain.gcno
  ./src/rpc/libbitcoin_common_a-util.gcno
  ./src/rpc/libbitcoin_common_a-rawtransaction_util.gcno
  ./src/rpc/libbitcoin_server_a-rawtransaction.gcno
  ./src/rpc/libbitcoin_util_a-request.gcno
  ./src/rpc/libbitcoin_server_a-net.gcno
  ./src/rpc/libbitcoin_server_a-server.gcno
  ./src/rpc/libbitcoin_server_a-mining.gcno
  ./src/rpc/libbitcoin_server_a-misc.gcno
  ./src/rpc/libbitcoin_cli_a-client.gcno
  ./src/node/libbitcoin_server_a-coinstats.gcno
  ./src/node/libbitcoin_server_a-transaction.gcno
  ./src/node/libbitcoin_server_a-context.gcno
  ./src/node/libbitcoin_server_a-psbt.gcno
  ./src/node/libbitcoin_server_a-ui_interface.gcno
  ./src/node/libbitcoin_server_a-coin.gcno
  ./src/test/util/libtest_util_a-setup_common.gcno
  ./src/test/util/libtest_util_a-net.gcno
  ./src/test/util/libtest_util_a-blockfilter.gcno
  ./src/test/util/libtest_util_a-mining.gcno
  ./src/test/util/libtest_util_a-transaction_utils.gcno
  ./src/test/util/libtest_util_a-wallet.gcno
  ./src/test/util/libtest_util_a-str.gcno
  ./src/test/util/libtest_util_a-logging.gcno
  ./src/index/libbitcoin_server_a-txindex.gcno
  ./src/index/libbitcoin_server_a-base.gcno
  ./src/index/libbitcoin_server_a-blockfilterindex.gcno
  ./src/util/libbitcoin_util_a-error.gcno
  ./src/util/libbitcoin_util_a-rbf.gcno
  ./src/util/libbitcoin_util_a-message.gcno
  ./src/util/libbitcoin_util_a-time.gcno
  ./src/util/libbitcoin_util_a-moneystr.gcno
  ./src/util/libbitcoin_util_a-url.gcno
  ./src/util/libbitcoin_consensus_a-strencodings.gcno
  ./src/util/libbitcoin_util_a-settings.gcno
  ./src/util/libbitcoin_util_a-system.gcno
  ./src/util/libbitcoin_util_a-threadnames.gcno
  ./src/util/libbitcoin_util_a-fees.gcno
  ./src/util/libbitcoin_util_a-asmap.gcno
  ./src/util/libbitcoin_util_a-strencodings.gcno
  ./src/util/libbitcoin_util_a-string.gcno
  ./src/util/libbitcoin_util_a-bytevectorhash.gcno
  ./src/util/libbitcoin_util_a-bip32.gcno
  ./src/util/libbitcoin_util_a-spanparsing.gcno
  ./src/util/libbitcoinconsensus_la-strencodings.gcno
  ./src/interfaces/libbitcoin_wallet_a-wallet.gcno
  ./src/interfaces/libbitcoin_util_a-handler.gcno
  ./src/interfaces/libbitcoin_server_a-chain.gcno
  ./src/interfaces/libbitcoin_server_a-node.gcno
  ./src/crc32c/src/libcrc32c_a-crc32c_portable.gcno
  ./src/crc32c/src/libcrc32c_a-crc32c.gcno
  ./src/crc32c/src/libcrc32c_sse42_a-crc32c_sse42.gcno
  ```

  This PR fixes this issue.

ACKs for top commit:
  practicalswift:
    ACK 6cb8771173 -- patch looks correct

Tree-SHA512: d331b8fa18f2e0cb2c107de747a39a018f73bcc20b05ed403aa38cf316b5be30b3229e92fb6c85469747571d0048a34b2846432994d0911c8234d207d4e32f1a
2020-08-15 10:15:42 +08:00
fanquake d052f5e6b7
Merge #16841: Replace GetScriptForWitness with GetScriptForDestination
7966aa424a Add variables for repeated scripts (MeshCollider)
fec8336ad9 Remove GetScriptForWitness function (MeshCollider)
b887060d06 Replace usage of GetScriptForWitness with GetScriptForDestination (MeshCollider)

Pull request description:

  As per this TODO in the code:

  > TODO: replace calls to GetScriptForWitness with GetScriptForDestination using the various witness-specific CTxDestination subtypes.

  The commit "Add additional check for P2SH before adding extra wrapper" also adds an additional check that the scriptPubKey is a P2SH before auto-wrapping the witness script. We shouldn't wrap the witness script if not. Note: #16251 is even better than this check, please review that.

ACKs for top commit:
  instagibbs:
    ACK 7966aa424a
  jonatack:
    Code review re-ACK 7966aa4 per `git range-diff b4d0366 ed266f7 7966aa4`
  achow101:
    re-ACK 7966aa424a only changes since last is rebase.

Tree-SHA512: 3449e0e83bd842acc7c94544a85367da97ac20d859eefc1a618caef0c98204398c266fe8fb9600b78326df5175402e1ae4a132eb766e2c4485e7cda6a2a95c43
2020-08-15 08:54:45 +08:00
Samuel Dobson a0e75bd31d
Merge #15937: Add loadwallet and createwallet load_on_startup options
642ad31b41 Add loadwallet and createwallet RPC load_on_startup options (Russell Yanofsky)

Pull request description:

  This maintains a persistent list of wallets stored in settings that will automatically be loaded on startup. Being able to load a wallet automatically on startup will be more useful in the GUI, but it's reasonable to expose this feature by RPC as well.

ACKs for top commit:
  achow101:
    re-ACK 642ad31b41 Only change is the test
  meshcollider:
    re-utACK 642ad31b41

Tree-SHA512: cca0b71bf1a83ad071830e6c459f1cd979b4add7144e899ec560da72b5910dd9bf9426e5c7d125ae96fad8990fbf81a76bc83c0459486c16086ada6cbde5eaa3
2020-08-15 12:19:48 +12:00
Samuel Dobson f269165edc
Merge #17458: Refactor OutputGroup effective value calculations and filtering to occur within the struct
9adc2f80fc Refactor OutputGroups to handle effective values, fees, and filtering (Andrew Chow)
7d07e864b8 Use real value when calculating OutputGroup value (Andrew Chow)

Pull request description:

  Currently, the effective values and filtering for positive effective values is done outside of the OutputGroup. We should instead have functions in Outputgroup to do this and call those for each OutputGroup. So this PR does that.

  This makes future changes for effective values in coin selection much easier.

ACKs for top commit:
  instagibbs:
    reACK 9adc2f80fc
  fjahr:
    re-ACK 9adc2f80fc
  meshcollider:
    Light code review ACK 9adc2f80fc

Tree-SHA512: 7445c94b7295b45bcd83a6f8a5c8f6961a89453fcc856335192d4b4a66aec7724513616b04e5111588ab208c89b311055399d6279cd9c4ce452aefb85f04b64a
2020-08-15 11:44:30 +12:00
Adam Jonas 4792cad88c doc: comment out and add annotation to unused MSG_FILTERED_WITNESS_BLOCK 2020-08-14 09:58:34 -04:00
MarcoFalke fa55c1d5fd
build: Add Werror=range-loop-analysis 2020-08-14 15:27:38 +02:00
MarcoFalke 30dd562fd2
Merge #19457: wallet: Cleanup wallettool salvage and walletdb extraneous declarations
0e279fe489 walletdb: Remove unused static functions from walletdb.h (Andrew Chow)
9f536d4fe9 wallettool: Have RecoverDatabaseFile return errors and warnings (Andrew Chow)
06e263a4e3 Call RecoverDatabaseFile directly from wallettool (Andrew Chow)

Pull request description:

  Followup to #19324 addressing some comments.

  Removes the `SalvageWallet` function in wallettool and instead directly calls `RecoverDatabaseFile` as suggested in https://github.com/bitcoin/bitcoin/pull/19324#discussion_r450379596

  Removes the `LogPrintf`s and `tfm::format`s in `RecoverDatabaseFile` as noted in https://github.com/bitcoin/bitcoin/pull/19324#discussion_r448027237

  Removes the declarations of `VerifyEnvironment` and `VerifyDatabaseFile` that were forgotten in `walletdb.h` as noted in https://github.com/bitcoin/bitcoin/pull/19324#issuecomment-654389079

ACKs for top commit:
  meshcollider:
    Code review ACK 0e279fe489
  ryanofsky:
    Code review ACK 0e279fe489, just dropped last commit

Tree-SHA512: ffd01f30536c2eab4bf40ba363c3ea916ecef3c8f0c5262040b40498776ffb00f95240204a40e38415d6931800851d0a3fa63ee91efc1d329b60ac317da0363d
2020-08-14 15:12:44 +02:00
MarcoFalke 1a43cd3f74
Merge #19709: test: Fix 'make cov' with clang
35cd2da623 test: Fix 'make cov' with clang (Hennadii Stepanov)

Pull request description:

  This is a follow up of #19688.

  With this PR it is possible to do the following:
  ```
  $ ./autogen.sh
  $ ./configure --enable-lcov CC=clang CXX=clang++
  $ make
  $ make cov
  ```

  Currently, on master (8a85377cd0), `make cov` fails to `Processing src/test/test_bitcoin-util_tests.gcda`.

ACKs for top commit:
  vasild:
    ACK 35cd2da
  Crypt-iQ:
    ACK 35cd2da

Tree-SHA512: aaf56118e2644064e9738a8279889c617db5805c5c804c904469b24c496bd609f9c5fc2aebcf1a422f8a5ed2eb38bd6e76b484680310b55c36d922b73a4c33cf
2020-08-14 14:57:49 +02:00
Hennadii Stepanov ce3e6a7cb2
bench: Allow skip benchmark
Co-authored-by: Martin Ankerl <Martin.Ankerl@gmail.com>
2020-08-14 14:56:18 +03:00
Hennadii Stepanov 6cb8771173
build: Add missed gcov files to 'make clean' 2020-08-14 14:38:28 +03:00
MarcoFalke fa3d9ce325
rpc: Assert that RPCArg names are equal to CRPCCommand ones (rpcdump) 2020-08-14 12:38:03 +02:00
MarcoFalke fa32c1d5ec
rpc: Assert that RPCArg names are equal to CRPCCommand ones (zmq) 2020-08-14 12:37:51 +02:00
MarcoFalke faaa46dc20
rpc: Assert that RPCArg names are equal to CRPCCommand ones (mining) 2020-08-14 12:37:19 +02:00
MarcoFalke fa93bc14c7
rpc: Remove unused return type from appendCommand 2020-08-14 12:37:06 +02:00
Wladimir J. van der Laan 4d4bd5ed74
Merge #17204: wallet: Do not turn OP_1NEGATE in scriptSig into 0x0181 in signing code (sipa)
dca28634d7 test: ensure OP_1NEGATE satisfies BIP62 minimal push rule (Jon Atack)
e629d07199 Do not turn OP_1NEGATE in scriptSig into 0x0181 in signing code (Pieter Wuille)

Pull request description:

  A rebase of #13084 which additionally modifies the test code (unaddressed in the original, assuming sipa is too busy to deal with this at the moment).

  Relatively simple bugfix so it'd be good to have merged soon.

  Turning OP_1NEGATE into 0x0181 results in a larger-than-necessary data push instead of just actually using the OP_1NEGATE opcode (0x4f). This fails the minimal push rule of BIP 62 and makes the result non-standard.

ACKs for top commit:
  fjahr:
    Code review ACK dca28634d7
  luke-jr:
    ACK dca28634d7
  jonatack:
    ACK dca28634d7

Tree-SHA512: 706d9a2ef20c809dea923e477a873e2fd60db8d0ae64289e510b766a38005c1f31ab0b5883f16b9c7863ff0d3f705e8e413f6121320028ac196b79c3184a4113
2020-08-14 11:53:47 +02:00
Wladimir J. van der Laan dabab06a1a
Merge #19455: rpc generate: print useful help and error message
f0aa8aeea5 test: add rpc_generate functional test (Jon Atack)
92d94ffb8d rpc: print useful help and error message for generate (Jon Atack)
8d32d2011d test: consider generate covered in _get_uncovered_rpc_commands() (Jon Atack)

Pull request description:

  This was a requested follow-up to #19133 and #17700 to alleviate confusion and head-scratching by people following tutorials that use `generate`. See https://github.com/bitcoin/bitcoin/pull/19455#issuecomment-668172916 below, https://github.com/bitcoin/bitcoin/pull/19133#issuecomment-636860943 and https://github.com/bitcoin/bitcoin/pull/17700#issuecomment-566159096.

  before
  ```
  $ bitcoin-cli help generate
  help: unknown command: generate

  $ bitcoin-cli generate
  error code: -32601
  error message:
  Method not found
  ```

  after
  ```
  $ bitcoin-cli help generate
  generate ( nblocks maxtries ) has been replaced by the -generate cli option. Refer to -help for more information.

  $ bitcoin-cli generate
  error code: -32601
  error message:
  generate ( nblocks maxtries ) has been replaced by the -generate cli option. Refer to -help for more information.
  ```

  In the general help it remains hidden, as requested by laanwj.
  ```
  $ bitcoin-cli help

  == Generating ==
  generateblock "output" ["rawtx/txid",...]
  generatetoaddress nblocks "address" ( maxtries )
  generatetodescriptor num_blocks "descriptor" ( maxtries )
  ```

ACKs for top commit:
  adamjonas:
    utACK f0aa8aeea5
  pinheadmz:
    ACK f0aa8aeea5

Tree-SHA512: d083652589ad3e8228c733455245001db22397559c3946e7e573cf9bd01c46e9e88b72d934728ec7f4361436ae4c74adb8f579670b09f479011924357e729af5
2020-08-14 11:29:05 +02:00
Hennadii Stepanov 35cd2da623
test: Fix 'make cov' with clang 2020-08-14 12:18:47 +03:00
fanquake c0b1706964
Merge #19568: Wallet should not override signing errors
e7448d6680 wallet: Don't override signing errors (Fabian Jahr)

Pull request description:

  While reviewing #17204 I noticed that the errors in `input_errors` from `::SignTransaction` where being overridden by `CWallet::SignTransaction`. For example, a Script related error led to incomplete signature data which led to `CWallet::SignTransaction` reporting that keys were missing, which was a less precise error than the original one.

  Additionally, the error `"Input not found or already spent"` is [duplicated in `sign.cpp`](c7b4968552/src/script/sign.cpp (L481)), so the error here is redundant at the moment. So technically the whole error block could be removed, I think. However, this code is affected by the ongoing work on the wallet so there might be a reason why these errors are here. But even if there is a reason to keep them, I don't think existing, potentially more precise errors should be overridden here unless we want to hide them from the users. I am looking for feedback if this is a work in progress state where these errors could be more useful in the future or if they can be removed.

  On testing: even though [the errors in `CWallet` are covered](https://marcofalke.github.io/btc_cov/total.coverage/src/wallet/wallet.cpp.gcov.html), all tests still pass after removing them. I am not sure if there is a desire to cover these specific error messages, tests in `test/functional/rpc_signrawtransaction.py` seem to aim for a more generic approach.

ACKs for top commit:
  achow101:
    ACK e7448d6680
  meshcollider:
    Code review ACK e7448d6680

Tree-SHA512: 3e2bc11d05379d2aef87b093a383d1b044787efc70e35955b2f8ecd028b6acef02f386180566af6a1a63193635f5d685466e2f6141c96326c49ffc5c81ca3e23
2020-08-14 16:04:31 +08:00
MarcoFalke 31760bb7c9
Merge #19528: rpc: Assert that RPCArg names are equal to CRPCCommand ones (misc)
fa77de2baa rpc: Assert that RPCArg names are equal to CRPCCommand ones (misc) (MarcoFalke)
fa50bdc755 rpc: Limit echo to 10 args (MarcoFalke)
fa89ca9b5b refactor: Use C++11 range based for loops to simplify rpc code (MarcoFalke)
fa459bdc87 rpc: Treat all args after a hidden arg as hidden as well (MarcoFalke)

Pull request description:

  This is split out from #18531 to just touch the RPC methods in misc. Description from the main pr:

  ### Motivation

  RPCArg names in the rpc help are currently only used for documentation. However, in the future they could be used to teach the server the named arguments. Named arguments are currently registered by the `CRPCCommand`s and duplicate the RPCArg names from the documentation. This redundancy is fragile, and has lead to errors in the past (despite having linters to catch those kind of errors). See section "bugs found" for a list of bugs that have been found as a result of the changes here.

  ### Changes

  The changes here add an assert in the `CRPCCommand` constructor that the RPCArg names are identical to the ones in the `CRPCCommand`.

  ### Future work

  > Here or follow up, makes sense to also assert type of returned UniValue?

  Sure, but let's not get ahead of ourselves. I am going to submit any further works as follow-ups, including:

  * Removing the CRPCCommand arguments, now that they are asserted to be equal and thus redundant
  * Removing all python regex linters on the args, now that RPCMan can be used to generate any output, including the cli.cpp table
  * Auto-formatting and sanity checking the RPCExamples with RPCMan
  * Checking passed-in json in self-check. Removing redundant checks
  * Checking returned json against documentation to avoid regressions or false documentation
  * Compile the RPC documentation at compile-time to ensure it doesn't change at runtime and is completely static

  ### Bugs found

  * The assert identified issue #18607
  * The changes itself fixed bug #19250

ACKs for top commit:
  laanwj:
    Code review ACK fa77de2baa
  fjahr:
    tested ACK fa77de2baa
  theStack:
    ACK fa77de2baa
  ryanofsky:
    Code review ACK fa77de2baa. Pretty straightfoward changes

Tree-SHA512: badae1606518c0b55ce2c0bb9025d14f05556532375eb20fd6f3bfadae1e5e6568860bff8599d037e655bf1d23f1f464ca17f4db10a6ab3d502b6e9e61c7b3d3
2020-08-14 09:26:37 +02:00
Samuel Dobson 609ce2d0da
Merge #19644: rpc: document returned error fields as optional if applicable
f110b7c722 rpc: document returned error fields as optional if applicable (Sebastian Falbesoner)

Pull request description:

  The following RPCs return error fields (named `"error"` or `"errors"`) that are optional, but don't show up as optional in the help text yet:
  * `analyzepsbt`
  * `estimatesmartfee`
  * `signrawtransactionwithkey`
  * `signrawtransactionwithwallet`

  The following RPC has the errors field already marked as optional, but doesn't match the usual format in the description (like `"if there are any"` in parantheses):
  * `estimaterawfee`

  This PR adds the missing optional flags and adapts the description strings. Inspired by a recent PR #19634 by justinmoon.

  The instances were found via `git grep "RPCResult.*\"error"`. Note that there is one RPC so far where the return error is not optional (i.e. in case of no error, the field is included in the result, but is just empty), namely `bumpfee`.

ACKs for top commit:
  adaminsky:
    ACK `f110b7c`
  laanwj:
    ACK f110b7c722, new documentation looks consistent with actual behavior
  achow101:
    ACK f110b7c722
  meshcollider:
    utACK f110b7c722

Tree-SHA512: 30c00f78a575b60e32b4536496af986d53a25f33e6ebbf553adcdcf825ad21a44f90267f3d1ea53326dac83bcfa9983fdb3dad6d3126e20f97f3c08ce286e188
2020-08-14 09:57:58 +12:00
MeshCollider 7966aa424a Add variables for repeated scripts 2020-08-14 08:47:19 +12:00
MeshCollider fec8336ad9 Remove GetScriptForWitness function 2020-08-14 08:47:19 +12:00
MeshCollider b887060d06 Replace usage of GetScriptForWitness with GetScriptForDestination 2020-08-14 08:44:42 +12:00
Russell Yanofsky 642ad31b41 Add loadwallet and createwallet RPC load_on_startup options
This maintains a persistent list of wallets stored in settings that will
automatically be loaded on startup. Being able to load a wallet automatically
on startup will be more useful in the GUI when the option to create wallets is
added in #15006, but it's reasonable to expose this feature by RPC as well.
2020-08-13 09:44:48 -04:00
Wladimir J. van der Laan b4d0366b47
Merge #19070: p2p: Signal support for compact block filters with NODE_COMPACT_FILTERS
f5c003d3ea [test] Add test for NODE_COMPACT_FILTER. (Jim Posen)
132b30d9c8 [net] Signal NODE_COMPACT_FILTERS if we're serving compact filters. (Jim Posen)
b3fbc94d4f Apply cfilters review fixups (John Newbery)

Pull request description:

  If -peerblockfilters is configured, signal the `NODE_COMPACT_FILTERS` service bit to indicate that we are able to serve compact block filters, headers and checkpoints.

ACKs for top commit:
  MarcoFalke:
    re-review and Concept ACK f5c003d3ea
  fjahr:
    Code review ACK f5c003d3ea
  clarkmoody:
    Concept ACK f5c003d3ea
  ariard:
    Concept and Code Review ACK f5c003d
  jonatack:
    ACK f5c003d3e

Tree-SHA512: 34d1c153530a0e55d09046fe548c9dc37344b5d6d50e00af1b4e1de1e7b49de770fca8471346a17c151de9fe164776296bb3dd5af331977f0c3ef1e6fc906f85
2020-08-13 15:44:48 +02:00
Hennadii Stepanov ead771bf6f
qt: Rename qt-init thread before logging start 2020-08-13 16:40:03 +03:00
Hennadii Stepanov ad5f614bf3
qt: Name ClientModel timer QThread 2020-08-13 16:37:05 +03:00
Hennadii Stepanov 2c7f5d8c2e
qt: Name WalletController worker QThread 2020-08-13 16:37:05 +03:00
Hennadii Stepanov 27dcc37d42
qt: Name RPCConsole executor QThread 2020-08-13 16:36:53 +03:00
Wladimir J. van der Laan 6757b3ac8f
Merge #19655: rpc: Catch listsinceblock target_confirmations exceeding block count
c133cdcdc3 Cap listsinceblock target_confirmations param (Adam Stein)

Pull request description:

  This addresses an issue brought up in #19587.

  Currently, the `target_confirmations` parameter to `listsinceblock` is not checked for being too large. When `target_confirmations` is greater than one more than the current number of blocks, `listsinceblock` fails with error code -1. In comparison, when `target_confirmations` is less than 1,  a -8 "Invalid parameter" error code is thrown.

  This PR fixes the issue by returning a -8 "Invalid parameter" error if the `target_confirmations` value corresponds to a block with more confirmations than the genesis block. This happens if `target_confirmations` exceeds one more than the number of blocks.

ACKs for top commit:
  laanwj:
    Code review ACK c133cdcdc3
  ryanofsky:
    Code review ACK c133cdcdc3. Just suggested changes since last review. Thanks!

Tree-SHA512: 02680f4cb937d2c24d5019abd0ebfa188b8a50679a1e64e9c26bfe5c17eef6aea906832e6e2d492ba8a2ea160041bf185d66795ee691e340f6793db03c21b89a
2020-08-13 12:12:33 +02:00
Jonas Schnelli 1052b09031
Merge #19011: Reduce cs_main lock accumulation during GUI startup
386ec192a5 Reduce cs_main lock accumulation during GUI startup (Jonas Schnelli)
d42cb79068 Optionally populate BlockAndHeaderTipInfo during AppInitMain (Jonas Schnelli)
b354a1480a Add BlockAndHeaderTipInfo to the node interface/appInit (Jonas Schnelli)
25e1d0bf41 RPCConsole, take initial chaintip data as parameter (Jonas Schnelli)

Pull request description:

  During the GUI startup, there is currently an accumulation of cs_main locks due to setting initial chain state values at multiple locations (in the GUI main thread).

  This PR tries to cache the initial chain state (tip height, tip time, best header, etc.) short after loading the blockindex.

  The cached values are then used instead of fetching them again (and thus locking `cs_main`) during setting the client model.

  This should fix the initial GUI blocking often experienced during or short after the splashscreen.
  On mac, best tested together with #19007.

ACKs for top commit:
  promag:
    Code review ACK 386ec192a5.
  ryanofsky:
    Code review ACK 386ec192a5. Just rebased since last review due to conflicts

Tree-SHA512: caccca05360e6dc0c3aade5e7ed24be513607821a8bd6612d0337259304ab772799fb2d707a0d7c7e50fbff4bd394354643fd0aeaa3bb55960ccc28562f4763d
2020-08-13 10:37:46 +02:00
Samuel Dobson 8a85377cd0
Merge #18654: rpc: separate bumpfee's psbt creation function into psbtbumpfee
79d6332e9e moveonly: Fix indentation in bumpfee RPC (Andrew Chow)
431071c28a Hide bumpfee's psbt creation behavior behind -deprecatedrpc (Andrew Chow)
4638224f64 Add psbtbumpfee RPC (Andrew Chow)

Pull request description:

  Adds a new RPC `psbtbumpfee` which always creates a psbt. `bumpfee` will then only be able to create and broadcast fee bumping transactions instead of changing its behavior based on `IsWalletSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)`.

  Split from #18627

ACKs for top commit:
  Sjors:
    re-utACK 79d6332
  meshcollider:
    utACK 79d6332e9e
  fjahr:
    Code review ACK 79d6332e9e

Tree-SHA512: 1c92c4b4461bb30e78be3ee73165f624398ef33996ce36043b61a8931be667030d0fca12fd0b30097b78c56e4e9092c69582b237cbdac51d56f6be23d8c0f1bb
2020-08-13 12:21:11 +12:00
Adam Stein c133cdcdc3
Cap listsinceblock target_confirmations param
Previously, listsinceblock would fail with error code -1 when the
target_confirmations exceeded the number of confirmations of the genesis
block. This commit allows target_confirmations to refer to a lastblock
hash with more confirmations than exist in the chain by setting the
lastblock hash to the genesis hash in this case. This allows for
`listsinceblock "" 6` to not fail if the block count is less than 5
which may happen on regtest.

Includes update to the functional test for listsinceblock to test for
this case.
2020-08-12 15:16:22 -07:00
Wladimir J. van der Laan 13c4635a3e
Merge #19696: rpc: Fix addnode remove command error
a51d0ad2de rpc: Improve addnode remove command error message (Fabian Jahr)

Pull request description:

  The `addnode` RPC with the `remove` command parameter is used to remove a node from the "added nodes". It did not have test coverage and in case of failure to remove the node it responded with the confusing message "Error: Node has not been added.".

  This PR adds test coverage and introduces a new error code as well as changes the error message to something that makes sense.

ACKs for top commit:
  laanwj:
    Code review ACK a51d0ad2de
  theStack:
    Tested ACK https://github.com/bitcoin/bitcoin/commit/a51d0ad2de

Tree-SHA512: 033ef5de0d4d49d58ef4df3759b838c9d19ee9dfb0aff9f814a3a63d124ca231a442c930efa7d343fe1f65727c4b59fc23dd5e26fe6ea69f9e84fda48b5c5cc2
2020-08-12 19:29:14 +02:00
Jonas Schnelli 386ec192a5 Reduce cs_main lock accumulation during GUI startup 2020-08-12 16:44:09 +02:00
Jonas Schnelli d42cb79068 Optionally populate BlockAndHeaderTipInfo during AppInitMain 2020-08-12 16:44:09 +02:00
Jonas Schnelli b354a1480a Add BlockAndHeaderTipInfo to the node interface/appInit 2020-08-12 16:44:06 +02:00
Jonas Schnelli 25e1d0bf41 RPCConsole, take initial chaintip data as parameter 2020-08-12 16:31:23 +02:00
Sebastian Falbesoner 356988e200 util: make EncodeBase58Check consume Spans 2020-08-12 16:25:50 +02:00
Sebastian Falbesoner f0fce0675d util: make EncodeBase58 consume Spans 2020-08-12 16:25:50 +02:00
Vasil Dimov 767073fb96
Shrink CAddress from 48 to 40 bytes on x64
`CAddress` inherits `CService` which is 28 bytes (on 64 bit machines).
`CAddress` then adds two member variables - one that requires 4 byte
alignment (`nTime`) and one that requires 8 byte alignment
(`nServices`).

Declare the smaller one first so that it fits in bytes 29..32.

On 32 bit machines this change has no effect and `CAddress` remains 40
bytes.
2020-08-12 16:00:11 +02:00
John Newbery c556770b5e [net_processing] Change PeerLogicValidation to hold a connman reference
Hold a reference to connman rather than a pointer because:

- PeerLogicValidation can't run without a connman
- The pointer never gets reseated

The alternative is to always assert that the pointer is non-null before
dereferencing.

Change the name from connman to m_connman at the same time to conform
with current style guidelines.
2020-08-12 14:25:28 +01:00
Wladimir J. van der Laan bd00d3b1f2
Merge #19658: [rpc] Allow RPC to fetch all addrman records and add records to addrman
37a480e0cd [net] Add addpeeraddress RPC method (John Newbery)
ae8051bbd8 [test] Test that getnodeaddresses() can return all known addresses (John Newbery)
f26502e9fc [addrman] Specify max addresses and pct when calling GetAddresses() (John Newbery)

Pull request description:

  Currently addrman only allows a maximum of 1000 records or 23% of all records to be returned in a call to `GetAddr()`. Relax this limit and have the client specify the max records they want. For p2p, behaviour is unchanged (but the rate limiting is set inside net_processing, where it belongs). For RPC, `getnodeaddresses` can now return the complete addrman, which is helpful for testing and monitoring.

  Also add a test-only RPC `addpeeraddress`, which adds an IP address:port to addrman. This is helpful for testing (eg #18991).

ACKs for top commit:
  naumenkogs:
    utACK 37a480e0cd
  laanwj:
    Code review and lightly manually tested ACK 37a480e0cd

Tree-SHA512: f86dcd410aaebaf6e9ca18ce6f23556e5e4649c1325577213d873aa09967298e65ab2dc19a72670641ae92211a923afda1fe124a82e9d2c1cad73d478ef27fdc
2020-08-12 15:23:06 +02:00
John Newbery 8e35bf5906 scripted-diff: rename misbehavior members
-BEGIN VERIFY SCRIPT-
sed -i 's/nMisbehavior/m_misbehavior_score/g' src/net_processing.cpp src/net_processing.h src/rpc/net.cpp src/qt/rpcconsole.cpp
-END VERIFY SCRIPT-
2020-08-12 11:23:22 +01:00
John Newbery 1f96d2e673 [net processing] Move misbehavior tracking state to Peer
Misbehavior tracking state is now contained in Peer instead of
CNode. It is no longer guarded by cs_main, but instead by a
dedicated m_misbehavior_mutex lock.

This allows us to remove 14 cs_main locks from net_processing.
2020-08-12 11:23:21 +01:00
John Newbery 7cd4159ac8 [net processing] Add Peer
Peer is a struct for holding per-peer data. This structure is not
protected by cs_main since it does not contain validation-critical data.
2020-08-12 11:22:44 +01:00
John Newbery aba03359a6 [net processing] Remove CNodeState.name
This has been unused since logging peer IPs was removed from
Misbehaving() in a8865f8b.
2020-08-12 10:10:22 +01:00
John Newbery 37a480e0cd [net] Add addpeeraddress RPC method
Allows addresses to be added to Address Manager for testing.
2020-08-12 09:22:10 +01:00
John Newbery f26502e9fc [addrman] Specify max addresses and pct when calling GetAddresses()
CAddrMan.GetAddr() would previously limit the number and percentage of
addresses returned (to ADDRMAN_GETADDR_MAX (1000) and
ADDRMAN_GETADDR_MAX_PCT (23) respectively). Instead, make it the callers
responsibility to specify the maximum addresses and percentage they want
returned.

For net_processing, the maximums are MAX_ADDR_TO_SEND (1000) and
MAX_PCT_ADDR_TO_SEND (23). For rpc/net, the maximum is specified by the
client.
2020-08-12 09:22:07 +01:00
fanquake ce3bdd0ed1
Merge #19316: [net] Cleanup logic around connection types
01e283068b [net] Remove unnecessary default args on CNode constructor (Amiti Uttarwar)
bc5d65b3ca [refactor] Remove IsOutboundDisconnectionCandidate (Amiti Uttarwar)
2f2e13b6c2 [net/refactor] Simplify multiple-connection checks (Amiti Uttarwar)
7f7b83deb2 [net/refactor] Rework ThreadOpenConnections logic (Amiti Uttarwar)
35839e963b [net] Fix bug where AddrFetch connections would be counted as outbound full relay (Amiti Uttarwar)
4972c21b67 [net/refactor] Clarify logic for selecting connections in ThreadOpenConnections (Amiti Uttarwar)
60156f5fc4 [net/refactor] Remove fInbound flag from CNode (Amiti Uttarwar)
7b322df629 [net/refactor] Remove m_addr_fetch member var from CNode (Amiti Uttarwar)
14923422b0 [net/refactor] Remove fFeeler flag from CNode (Amiti Uttarwar)
49efac5cae [net/refactor] Remove m_manual_connection flag from CNode (Amiti Uttarwar)
d3698b5ee3 [net/refactor] Add connection type as a member var to CNode (Amiti Uttarwar)
46578c03e9 [doc] Describe different connection types (Amiti Uttarwar)
442abae2ba [net/refactor] Add AddrFetch connections to ConnectionType enum (Amiti Uttarwar)
af59feb052 [net/refactor] Extract m_addr_known logic from initializer list (Amiti Uttarwar)
e1bc29812d [net/refactor] Add block relay only connections to ConnectionType enum (Amiti Uttarwar)
0e52a659a2 [net/refactor] Add feeler connections to ConnectionType enum (Amiti Uttarwar)
1521c47438 [net/refactor] Add manual connections to ConnectionType enum (Amiti Uttarwar)
26304b4100 [net/refactor] Introduce an enum to distinguish type of connection (Amiti Uttarwar)
3f1b7140e9 scripted-diff: Rename OneShot to AddrFetch (Amiti Uttarwar)

Pull request description:

  **This is part 1 of #19315, which enables the ability to test `outbound` and `block-relay-only` connections from the functional tests.** Please see that PR for more information of overall functionality.

  **This PR simplifies how we manage different connection types.** It introduces an enum with the various types of connections so we can explicitly define the connection type. The existing system relies on a series of independent flags, then has asserts scattered around to ensure that conflicting flags are not enabled at the same time. I find this approach to be both brittle and confusing. While making these changes, I found a small bug due to the silent assumptions.

  This PR also proposes a rename from `OneShot` to `AddrFetch`. I find the name `OneShot` to be very confusing, especially when we also have `onetry` manual connections. Everyone I've talked to offline has agreed that the name is confusing, so I propose a potential alternative. I think this is a good opportunity for a rename since I'm creating an enum to explicitly define the connection types.
  (some context for the unfamiliar: `oneshot` or `addrfetch` connections are short-lived connections created on startup. They connect to the seed peers, send a `getaddr` to solicit addresses, then close the connection.)

  Overview of this PR:
  * rename `oneshot` to `addrfetch`
  * introduce `ConnectionType` enum
  * one by one, add different connection types to the enum
  * expose the `conn_type` on CNode, and use this to reduce reliance on flags (& asserts)
  * fix the bug in counting different type of connections
  * some additional cleanup to simplify logic and make expectations explicit/inclusive rather than implicit/exclusive.

ACKs for top commit:
  jnewbery:
    utACK 01e283068b
  laanwj:
    Code review ACK 01e283068b, the commits are pretty straightforward to follow, and I think this is a move in the right direction overall
  vasild:
    ACK 01e283068
  sdaftuar:
    ACK 01e283068b.
  fanquake:
    ACK 01e283068b - I don't have as much experience with the networking code but these changes look fairly straight forward, the new code seems more robust/understandable and the additional documentation is great. I'm glad that a followup branch is already underway. There might be some more review comments here later today, so keep an eye on the discussion, however I'm going to merge this now.
  jb55:
    wow this code was messy before... ACK 01e283068b

Tree-SHA512: 7bb644a6ed5849913d777ebc2ff89133ca0fbef680355a9a344e07496a979e6f9ff21a958e8eea93dcd7d5c343682b0c7174b1a3de380a4247eaae73da436e15
2020-08-12 10:01:44 +08:00
Andrew Chow 9adc2f80fc Refactor OutputGroups to handle effective values, fees, and filtering
Instead of having callers set the fees, effective values, and filtering
of outputs, do these within OutputGroups themselves as member functions.

m_fee and m_long_term_fee is added to OutputGroup to track the fees of
the OutputGroup.
2020-08-11 14:25:02 -04:00
Fabian Jahr a51d0ad2de
rpc: Improve addnode remove command error message
This also adds test coverage for the remove command which was uncovered before.
2020-08-11 14:04:02 +02:00
Wladimir J. van der Laan 85fa648c85
Merge #19596: Deduplicate parent txid loop of requested transactions and missing parents of orphan transactions
4c0731f9c5 Deduplicate missing parents of orphan transactions (Suhas Daftuar)
8196176243 Rewrite parent txid loop of requested transactions (Suhas Daftuar)

Pull request description:

  I noticed a couple of places recently where we loop over all inputs of a transaction in order to do some processing on the txids we find in those inputs.  There may be thousands of inputs in a transaction, and the same txid may appear many times.  In a couple of places in particular, we loop over those txids and add them to a rolling bloom filter; doing that multiple times for the same txid wastes entries in that filter.

  This PR fixes that in two places relating to transaction relay: one on the server side, where we look for parent transactions of a tx that we are delivering to a peer to ensure that getdata requests for those parents will succeed; and the other on the client side, where when we process an orphan tx we want to loop over the parent txids and ensure that all are eventually requested from the peer who provided the orphan.

  This addresses a couple of [related](https://github.com/bitcoin/bitcoin/pull/19109#discussion_r455197217) [comments](https://github.com/bitcoin/bitcoin/pull/19109#discussion_r456820373) left in #19109.

ACKs for top commit:
  laanwj:
    Code review ACK 4c0731f9c5
  jonatack:
    ACK 4c0731f9c5
  ajtowns:
    ACK 4c0731f9c5

Tree-SHA512: 8af9df7f56c6e54b5915519d7d5465e081473ceb1bcc89bbebf83e78722cf51ff58145e588cf57126bce17071a8053273f4bcef0ad8166bec83ba14352e40f5d
2020-08-10 20:38:19 +02:00
fanquake 04a0676b3f
Merge #17563: lib: fix a compiler warning: unused GetDevURandom()
ca2e474372 Fix a compiler warning: unused GetDevURandom() (Vasil Dimov)

Pull request description:

  ~~Only define GetDevURandom() if it is going to be used.~~

  Silence by planting a dummy reference to the `GetDevURandom` symbol
  in the places where we don't call the function.

ACKs for top commit:
  practicalswift:
    ACK ca2e474372 -- increased signal to noise in compiler diagnostics is good
  sipa:
    utACK ca2e474372
  hebasto:
    re-ACK ca2e474372, tested on macOS 10.15.6 + llvm clang 10.0.0

Tree-SHA512: 03c98f00dad5d9a3c5c9f68553d72ad5489ec02f18b9769108a22003ec7be7819a731b1eab6a9f64dafb5be0efddccf6980de7e3bb90cd20d4f4d72f74124675
2020-08-10 21:30:42 +08:00
Wladimir J. van der Laan b75f2ad72d
Merge #19660: refactor: Make HexStr take a span
0a8aa626dd refactor: Make HexStr take a span (Wladimir J. van der Laan)

Pull request description:

  Make `HexSt`r take a span of bytes, instead of an awkward pair of templated iterators. This simplifies most of the uses.

ACKs for top commit:
  elichai:
    Code review ACK 0a8aa626dd
  hebasto:
    re-ACK 0a8aa626dd
  jonatack:
    re-ACK 0a8aa626dd

Tree-SHA512: 6e178ece5cbac62119c857a10299b1e85422938084c3f03063e17119a5129e0c28016e05a6fabaa4c271a7e0a37c7cd89fa47c435ee19b38a5acfe80d00de992
2020-08-09 15:35:58 +02:00
Wladimir J. van der Laan 6ea7348122
Merge #19638: Replace hidden service with onion service
1e72b68ab3 Replace `hidden service` with `onion service` (Riccardo Masutti)

Pull request description:

  For a couple of years, Tor has made the term `hidden service` obsolete, in favor of `onion service`: [Tor Project | Onion Services](https://community.torproject.org/onion-services/)

  This PR updates all the references.

ACKs for top commit:
  laanwj:
    Code review ACK 1e72b68ab3
  hebasto:
    ACK 1e72b68ab3, tested on Linux Mint 20 (x86_64).

Tree-SHA512: 6a29e828e1c5e1ec934b5666f67326dbd84d77c8b2641f6740abac6d3d5923b7729763b9ff2230390b0bb23359a5f3731ccd9a30011ca69004f7c820aed17262
2020-08-09 15:08:20 +02:00
MarcoFalke e349eeeb2c
Merge #19672: build: make clean removes .gcda and .gcno files from fuzz directory
90bd476ea6 build: make clean removes .gcda and .gcno files from fuzz directory (eugene)

Pull request description:

  I believe these should also be deleted upon invoking `make clean`. It also garbles the coverage file if you try to fuzz the same harness again.

ACKs for top commit:
  practicalswift:
    ACK 90bd476ea6 -- patch looks correct
  hebasto:
    ACK 90bd476ea6, tested with hints from #12602 and #18107.
  darosior:
    ACK 90bd476ea6

Tree-SHA512: 4b2eb664f64d18bc0385c5a0040b0b9fa6fe470c941ae39c7cb4544c4283427a8d4985517475fe0295c3ab2794b9a2ad4f76b6a443c05d846c97c966add87ca9
2020-08-08 16:43:03 +02:00
Amiti Uttarwar 01e283068b [net] Remove unnecessary default args on CNode constructor 2020-08-07 17:18:17 -07:00
Amiti Uttarwar bc5d65b3ca [refactor] Remove IsOutboundDisconnectionCandidate 2020-08-07 17:18:17 -07:00
Amiti Uttarwar 2f2e13b6c2 [net/refactor] Simplify multiple-connection checks
Extract logic that check multiple connection types into interface functions &
structure as switch statements. This makes it very clear what touch points are
for accessing `m_conn_type` & using the switch statements enables the compiler
to warn if a new connection type is introduced but not handled for these cases.
2020-08-07 17:18:16 -07:00
Amiti Uttarwar 7f7b83deb2 [net/refactor] Rework ThreadOpenConnections logic
Make the connection counts explicit and extract into interface functions around
m_conn_type. Using explicit counting and switch statements where possible
should help prevent counting bugs in the future.
2020-08-07 17:18:16 -07:00
Amiti Uttarwar 35839e963b [net] Fix bug where AddrFetch connections would be counted as outbound full relay
The desired logic is for us to only open feeler connections after we have hit
the max count for outbound full relay connections.  A short lived AddrFetch
connection (previously called oneshot) could cause ThreadOpenConnections to
miscount and mistakenly open a feeler instead of full relay.
2020-08-07 17:18:16 -07:00
Amiti Uttarwar 4972c21b67 [net/refactor] Clarify logic for selecting connections in ThreadOpenConnections 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 60156f5fc4 [net/refactor] Remove fInbound flag from CNode 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 7b322df629 [net/refactor] Remove m_addr_fetch member var from CNode 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 14923422b0 [net/refactor] Remove fFeeler flag from CNode 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 49efac5cae [net/refactor] Remove m_manual_connection flag from CNode 2020-08-07 17:18:16 -07:00
Amiti Uttarwar d3698b5ee3 [net/refactor] Add connection type as a member var to CNode
- Directly maintaining the connection type prevents having to deduce it from
  several flags.
2020-08-07 17:18:16 -07:00
Amiti Uttarwar 46578c03e9 [doc] Describe different connection types 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 442abae2ba [net/refactor] Add AddrFetch connections to ConnectionType enum
- AddrFetch connections are short lived connections used to getaddr from a peer
- previously called "one shot" connections
2020-08-07 17:18:16 -07:00
Amiti Uttarwar af59feb052 [net/refactor] Extract m_addr_known logic from initializer list 2020-08-07 17:18:16 -07:00
Amiti Uttarwar e1bc29812d [net/refactor] Add block relay only connections to ConnectionType enum 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 0e52a659a2 [net/refactor] Add feeler connections to ConnectionType enum 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 1521c47438 [net/refactor] Add manual connections to ConnectionType enum 2020-08-07 17:18:16 -07:00
Amiti Uttarwar 26304b4100 [net/refactor] Introduce an enum to distinguish type of connection
- extract inbound & outbound types
2020-08-07 17:18:16 -07:00
Amiti Uttarwar 3f1b7140e9 scripted-diff: Rename OneShot to AddrFetch
-BEGIN VERIFY SCRIPT-
sed -i 's/a oneshot/an addrfetch/g' src/chainparams.cpp #comment
sed -i 's/oneshot/addrfetch/g' src/net.cpp #comment
sed -i 's/AddOneShot/AddAddrFetch/g' src/net.h src/net.cpp
sed -i 's/cs_vOneShots/m_addr_fetches_mutex/g' src/net.h src/net.cpp
sed -i 's/vOneShots/m_addr_fetches/g' src/net.h src/net.cpp
sed -i 's/fOneShot/m_addr_fetch/g' src/net.h src/net.cpp src/net_processing.cpp
sed -i 's/ProcessOneShot/ProcessAddrFetch/g' src/net.h src/net.cpp
-END VERIFY SCRIPT-
2020-08-07 17:18:12 -07:00
Jeremy Rubin 9ab4cafabd Refactor Get{Prevout,Sequence,Outputs}Hash to Get{Prevouts,Sequences,Outputs}SHA256.
Several proposals (Taproot, MuHash, CTV) require access to the single
hash.
2020-08-07 11:08:40 -07:00
Riccardo Masutti 1e72b68ab3 Replace hidden service with onion service
For a couple of years, Tor documentation has made
the term hidden service obsolete, in favor of onion
service.

This PR updates all the references in the code base.
2020-08-07 14:55:02 +02:00
Sjors Provoost 6d1f51343c
[rpc] fundrawtransaction, walletcreatefundedpsbt lock manually selected coins
Previously only automatically selected coins were locked when lockUnspents is set.
It now also locks selected coins.
2020-08-07 14:13:15 +02:00
MarcoFalke 4b705b1c98
Merge #19098: test: Remove duplicate NodeContext hacks
edc316020e test: Remove duplicate NodeContext hacks (Russell Yanofsky)

Pull request description:

  Qt tests currently are currently using two NodeContext structs at the same time, one in interfaces::NodeImpl::m_context, and the other in BasicTestingSetup::m_node, and the tests have hacks transferring state between them.

  Fix this by getting rid of the NodeImpl::m_context struct and making it a pointer. This way a common BitcoinApplication object can be used for all qt tests, but they can still have their own testing setups.

  Non-test code is changing but non-test behavior is still the same as before.

  Motivation for this PR is to be able to remove the "std::move(test.m_node.connman)" and mempool hacks for swapping individual NodeContext members in Qt tests, because followup PR #19099 adds yet another member (wallet_client) that needs to be swapped. After this change, the whole NodeContext struct can be swapped instead of individual members, so the workarounds are less fragile and invasive.

ACKs for top commit:
  MarcoFalke:
    crACK edc316020e 🌮
  promag:
    ACK edc316020e.

Tree-SHA512: c1650e4127f43a4020304ca7c13b5d9122fb5723aacd8fa1cf855d03c6052fcfb7685810aa2a5ef708561015f0022fecaacbad479295104ca45d2c17579466a4
2020-08-07 08:07:37 +02:00
fanquake 6d8543504d
Merge #19620: Add txids with non-standard inputs to reject filter
9f88ded82b test addition of unknown segwit spends to txid reject filter (Gregory Sanders)
7989901c7e Add txids with non-standard inputs to reject filter (Suhas Daftuar)

Pull request description:

  Our policy checks for non-standard inputs depend only on the non-witness
  portion of a transaction: we look up the scriptPubKey of the input being
  spent from our UTXO set (which is covered by the input txid), and the p2sh
  checks only rely on the scriptSig portion of the input.

  Consequently it's safe to add txids of transactions that fail these checks to
  the reject filter, as the witness is irrelevant to the failure. This is helpful
  for any situation where we might request the transaction again via txid (either
  from txid-relay peers, or if we might fetch the transaction via txid due to
  parent-fetching of orphans).

  Further, in preparation for future witness versions being deployed on the
  network, ensure that WITNESS_UNKNOWN transactions are rejected in
  AreInputsStandard(), so that transactions spending v1 (or greater) witness
  outputs will fall into this category of having their txid added to the reject
  filter.

ACKs for top commit:
  ajtowns:
    ACK 9f88ded82b - code review
  jnewbery:
    Code review ACK 9f88ded82b
  ariard:
    Code Review/Tested ACK 9f88ded
  naumenkogs:
    utACK 9f88ded82b
  jonatack:
    ACK 9f88ded82b

Tree-SHA512: 1e93c0a5b68cb432524780ffc0093db893911fdfed9e2ed17f888e59114cc75d2a07062aefad4e5ce2e87c9270886117a8abb3c78fb889c9b9f31967f1777148
2020-08-07 07:34:27 +08:00
Jeremy Rubin 6510d0ff41 Add SHA256Uint256 helper functions 2020-08-06 16:28:26 -07:00
Jeremy Rubin b475d7d0fa Add single sha256 call to CHashWriter 2020-08-06 16:28:26 -07:00
Wladimir J. van der Laan 0a8aa626dd refactor: Make HexStr take a span
Make HexStr take a span of bytes, instead of an awkward pair of
templated iterators.
2020-08-06 19:41:43 +02:00
eugene 90bd476ea6 build: make clean removes .gcda and .gcno files from fuzz directory
With this commit, make clean now removes coverage files from the
fuzzing directory. Without this, subsequent fuzzing runs would have
garbled coverage signals for files in the fuzz directory as
they were never deleted with make clean.
2020-08-06 00:44:03 -04:00
Karl-Johan Alm b82067bf69
wallet: try -avoidpartialspends mode and use its result if fees are below threshold
The threshold is defined by a new max avoid partial spends fee flag, which defaults to 0 (i.e. if fees are unchanged, use the grouped option).
2020-08-06 10:07:00 +09:00
Wladimir J. van der Laan e3272ff290
Merge #19614: util: use HAVE_FDATASYNC to determine fdatasync() use
1d8338d6b7 util: use HAVE_FDATASYNC to determine fdatasync() use (fanquake)

Pull request description:

  Rather than just using on Linux and NetBSD, use `fdatasync()` based
  on whether it's available. i.e `fdatasync` is available in newer versions of FreeBSD.

  This also aligns more closely with what is being done in leveldb.

  Was pointed out by Luke in #19430.

ACKs for top commit:
  practicalswift:
    ACK 1d8338d6b7 -- patch looks correct
  laanwj:
    ACK 1d8338d6b7
  hebasto:
    ACK 1d8338d6b7

Tree-SHA512: 7dd6d87f5dc0c0ba21ae42f96b63fc12b34806cd536457fc4284f14bb8c235765344be228b000c6adf4cd1e8c4e6a03a18ca18ab22599c42cc3b706e0bcd1a17
2020-08-05 17:33:42 +02:00
Samuel Dobson e4df534c60
Merge #15382: util: add RunCommandParseJSON
31cf68a3ad [util] add RunCommandParseJSON (Sjors Provoost)
c17f54ee53 [ci] use boost::process (Sjors Provoost)
32128ba682 [doc] include Doxygen comments for HAVE_BOOST_PROCESS (Sjors Provoost)
3c84d85f7d [build] msvc: add boost::process (Sjors Provoost)
c47e4bbf0b [build] make boost-process opt-in (Sjors Provoost)
929cda5470 configure: add ax_boost_process (Sjors Provoost)
8314c23d7b [depends] boost: patch unused variable in boost_process (Sjors Provoost)

Pull request description:

  Prerequisite for external signer support in #16546. Big picture overview in [this gist](https://gist.github.com/Sjors/29d06728c685e6182828c1ce9b74483d).

  This adds a new dependency [boost process](https://github.com/boostorg/process/tree/boost-1.64.0). This is part of Boost since 1.64 which is part of `depends`. Because the minimum Boost version is 1.47, this functionality is skipped for older versions of Boost.

  Use `./configure --with-boost-process` to opt in, which checks for the presence of Boost::Process.

  We add `UniValue runCommandParseJSON(const std::string& strCommand)` to `system.{h,cpp}` which calls an arbitrary command and processes the JSON returned by it. This is currently only called by the test suite.

  ~For testing purposes this adds a new regtest-only RPC method `runcommand`, as well as `test/mocks/command.py` used by functional tests.~ (this is no longer the case)

  TODO:
  - [ ] review boost process in #15440

ACKs for top commit:
  achow101:
    ACK 31cf68a3ad
  hebasto:
    re-ACK 31cf68a3ad, only rebased (verified with `git range-diff`) and removed an unintentional tab character since the [previous](https://github.com/bitcoin/bitcoin/pull/15382#pullrequestreview-458371035) review.
  meshcollider:
    Very light utACK 31cf68a3ad, although I am not very confident with build stuff.
  promag:
    Code review ACK 31cf68a3ad, don't mind the nit.
  ryanofsky:
    Code review ACK 31cf68a3ad. I left some comments below that could be ignored or followed up later. The current change is clean and comprehensive.

Tree-SHA512: c506e747014b263606e1f538ed4624a8ad7bcf4e025cb700c12cc5739964e254dc04a2bbb848996b170e2ccec3fbfa4fe9e2b3976b191222cfb82fc3e6ab182d
2020-08-05 23:43:43 +12:00
Suhas Daftuar 4c0731f9c5 Deduplicate missing parents of orphan transactions
In the logic for requesting missing parents of orphan transactions, parent
transactions with multiple outputs being spent by the given orphan were being
processed multiple times. Fix this by deduplicating the set of missing parent
txids first.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2020-08-04 13:59:16 -04:00