Commit graph

23149 commits

Author SHA1 Message Date
Gleb Naumenko
88d326c8e3 p2p: Finish negotiating reconciliation support
Once we received a reconciliation announcement support
message from a peer and it doesn't violate our protocol,
we store the negotiated parameters which will be used
for future reconciliations.
2022-10-17 12:35:44 +03:00
Gleb Naumenko
36cf6bf216 Add helper to see if a peer is registered for reconciliations 2022-10-17 12:35:44 +03:00
Gleb Naumenko
4470acf076 p2p: Forget peer's reconciliation state on disconnect 2022-10-17 12:35:44 +03:00
Gleb Naumenko
3fcf78ee6a p2p: Announce reconciliation support
If we're connecting to the peer which might support
transaction reconciliation, we announce we want to reconcile
with them.

We store the reconciliation salt so that when the peer
responds with their salt, we are able to compute the
full reconciliation salt.

This behavior is enabled with a CLI flag.
2022-10-17 12:35:43 +03:00
Gleb Naumenko
24e36fac0a log: Add tx reconciliation log category 2022-10-17 12:00:59 +03:00
fanquake
9e9ae6101f
doc: remove library commentary from src/Makefile.am
This duplicates and is less explanatory than doc/libraries.md.
2022-10-14 17:07:36 +08:00
glozow
cbb2da8fcf
add lock annotation for FeeFilterRounder::round()
Calling WITH_LOCK() on a non-recursive mutex requires not holding it beforehand.

Co-authored-by: Niklas Gögge <n.goeggi@gmail.com>
2022-10-13 14:42:59 -04:00
Andrew Chow
0384b19414
Merge bitcoin/bitcoin#24851: init: ignore BIP-30 verification in DisconnectBlock for problematic blocks
e899d4ca6f init: limit bip30 exceptions to coinbase txs (Chris Geihsler)
511eb7fdea Ignore problematic blocks in DisconnectBlock (Chris Geihsler)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/22596

  When using checklevel=4, block verification fails because of duplicate coinbase transactions involving blocks 91812 and 91722. There was already a check in place within `ConnectBlock` to ignore the problematic blocks, but `DisconnectBlock` did not contain a similar check to ignore these blocks when called from `VerifyDB`.

  By ignoring these two blocks in `DisconnectBlock`, the block verification process succeeds at checklevel=4.

  (Note to reviewers: this is my first contribution to Bitcoin Core, so any feedback is most welcome. Thanks in advance for reviewing!)

  ## Steps to reproduce:

  Use the following bitcoin.conf file and start bitcoind. I only used block data through block ~100000 so that the verification process was much faster.

  ```
  assumevalid=0
  checkblocks=0
  checklevel=4
  ```

  Without this change, you will see the following error when the blocks are verified:

  ```
  2022-04-14T02:56:44Z init message: Verifying blocks…
  2022-04-14T02:56:44Z Verifying last 101881 blocks at level 4
  2022-04-14T02:56:44Z [0%]...[10%]...[20%]...[30%]...[40%]...ERROR: VerifyDB(): *** coin database inconsistencies found (last 10160 blocks, 142571 good transactions before that)

  2022-04-14T02:57:01Z : Corrupted block database detected.
  Please restart with -reindex or -reindex-chainstate to recover.
  : Corrupted block database detected.
  Please restart with -reindex or -reindex-chainstate to recover.
  ```

  With this change, you will see this instead:

  ```
  2022-04-14T02:32:29Z init message: Verifying blocks…
  2022-04-14T02:32:29Z Verifying last 101746 blocks at level 4
  2022-04-14T02:32:29Z [0%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...[70%]...[80%]...[90%]...[DONE].
  2022-04-14T02:32:48Z No coin database inconsistencies in last 101746 blocks (226126 transactions)
  ```

ACKs for top commit:
  laanwj:
    Code review ACK e899d4ca6f
  achow101:
    ACK e899d4ca6f
  jamesob:
    (Biased) ACK e899d4ca6f ([`jamesob/ackr/24851.2.seejee.init_ignore_bip_30_verif`](https://github.com/jamesob/bitcoin/tree/ackr/24851.2.seejee.init_ignore_bip_30_verif))

Tree-SHA512: d2f6d25e9619aee32c1a73fe846b1b587698eaa5a4994fa6424f1038f45654f9fd52b74a69843cc84d90168d74827130ccf8e9201502f5d52281acdb20429291
2022-10-13 14:15:28 -04:00
Andrew Chow
92be831847
Merge bitcoin/bitcoin#25412: rest: add /deploymentinfo endpoint
a8250e30f1 doc: add release note about `/rest/deploymentinfo` (brunoerg)
5c96020024 doc: add `/deploymentinfo` in REST-interface (brunoerg)
3e44bee08e test: add coverage for `/rest/deploymentinfo` (brunoerg)
91497031cb rest: add `/deploymentinfo` (brunoerg)

Pull request description:

  #23508 added a new RPC named `getdeploymentinfo`, it moved the softfork section from `getblockchaininfo` into this new one. In the REST interface, we have an endpoint named`/rest/chaininfo.json` (which refers to `getblockchaininfo`), so, this PR adds a new REST endpoint named `/deploymentinfo` which refers to `getdeploymentinfo`.

  You can use it by passing a block hash, e.g: '/rest/deploymentinfo/<BLOCKHASH>.json' or you can use it without passing a block hash to get the 'deploymentinfo' for the last block.

ACKs for top commit:
  jonatack:
    re-ACK a8250e30f1 rebase-only since my last review at c65f82bb
  achow101:
    ACK a8250e30f1
  stickies-v:
    re-ACK a8250e30f1

Tree-SHA512: 0735183b6828d51a72ed0e2be5a09b314ac4693f548982c6e9adaa0ef07a55aa428d3b2d1b1de70b83169811a663a8624b686166e5797f624dcc00178b9796e6
2022-10-13 13:30:55 -04:00
Andrew Chow
0bac04b758
Merge bitcoin/bitcoin#24407: fees: make the class FeeFilterRounder thread-safe
8173f160e0 style: rename variables to match coding style (Vasil Dimov)
8b4ad203d0 fees: make FeeFilterRounder::feeset const (Vasil Dimov)
e7a5bf6be7 fees: make the class FeeFilterRounder thread-safe (Vasil Dimov)

Pull request description:

  Make the class `FeeFilterRounder` thread-safe so that its methods can be called concurrently by different threads on the same object. Currently it has just one method (`round()`).

  The second commit is optional, but it improves readability, showing that the `feeset` member will never be changed, thus does not need protection from concurrent access.

ACKs for top commit:
  jonatack:
    re-ACK 8173f160e0
  laanwj:
    Code review ACK 8173f160e0
  promag:
    Code review ACK 8173f160e0

Tree-SHA512: 94b809997c485c0d114fa702d0406b980be8eaaebcfefa56808ed670aa943959c2f16cfd0ef72b4752fe2a409a23af1b4b7f2f236e51212957759569e3bbbefd
2022-10-13 11:57:07 -04:00
Andrew Chow
1dec90d95b
Merge bitcoin/bitcoin#25526: wallet: avoid double keypool TopUp() call on descriptor wallets
bfb9b94ebe wallet: remove duplicate descriptor type check in GetNewDestination (furszy)
76b982a4a5 wallet: remove unused `nAccountingEntryNumber` field (furszy)
599ff5adfc wallet: avoid double TopUp() calls on descriptor wallets (furszy)

Pull request description:

  Found it while was digging over a `getnewaddress` timeout on the functional test suite.

  ### Context:

  We are calling `TopUp()` twice in the following flows for descriptor wallets:

  A) `CWallet::GetNewDestination`:
     1) Calls spk_man->TopUp()
     2) Calls spk_man->GetNewDestination() --> which, after the basic script checks, calls TopUp() again.

  B) `CWallet::GetReservedDestination`:
     1) Calls spk_man->TopUp()
     2) Calls spk_man->GetReservedDestination() --> which calls to GetNewDestination (which calls to TopUp again).

  ### Changes:

  Move `TopUp()` responsibility from the wallet class to each scriptpubkeyman.
  So each spkm can decide to call it or not after perform the basic checks
  for the new destination request.

  Aside from that, remove the unused `nAccountingEntryNumber` wallet field. And a duplicated descriptor type check in `GetNewDestination`

ACKs for top commit:
  aureleoules:
    re-ACK bfb9b94ebe.
  achow101:
    ACK bfb9b94ebe
  theStack:
    Code-review ACK bfb9b94ebe

Tree-SHA512: 3ab73f37729e50d6c6a4434f676855bc1fb404619d63c03e5b06ce61c292c09c59d64cb1aa3bd9277b06f26988956991d62c90f9d835884f41ed500b43a12058
2022-10-13 11:27:38 -04:00
Andrew Chow
cb9764b686
Merge bitcoin/bitcoin#26109: rpc, doc: getpeerinfo updates
a3789c700b Improve getpeerinfo pingtime, minping, and pingwait help docs (Jon Atack)
df660ddb1c Update getpeerinfo/-netinfo/TxRelay#m_relay_txs relaytxes docs (for v24 backport) (Jon Atack)
1f448542e7 Always return getpeerinfo "minfeefilter" field (for v24 backport) (Jon Atack)
9cd6682545 Make getpeerinfo field order consistent with its help (for v24 backport) (Jon Atack)

Pull request description:

  Various updates and fixups, mostly targeting v24. Please refer to the commit messages for details.

ACKs for top commit:
  achow101:
    ACK a3789c700b
  brunoerg:
    ACK a3789c700b
  vasild:
    ACK a3789c700b

Tree-SHA512: b8586a9b83c1b18786b5ac1fc1dba91573c13225fc2cfc8d078f4220967c95056354f6be13327f33b4fcf3e9d5310fa4e1bdc93102cbd6574f956698993a54bf
2022-10-13 11:07:33 -04:00
Andrew Chow
bc2b1f0fe2
Merge bitcoin/bitcoin#23549: Add scanblocks RPC call (attempt 2)
626b7c8493 fuzz: add scanblocks as safe for fuzzing (James O'Beirne)
94fe5453c7 test: rpc: add scanblocks functional test (Jonas Schnelli)
6ef2566b68 rpc: add scanblocks - scan for relevant blocks with descriptors (Jonas Schnelli)
a4258f6e81 rpc: move-only: consolidate blockchain scan args (James O'Beirne)

Pull request description:

  Revives #20664. All feedback from the previous PR has either been responded to inline or incorporated here.

  ---

  Major changes from Jonas' PR:
  - consolidated arguments for scantxoutset/scanblocks
  - substantial cleanup of the functional test

  Here's the range-diff (`git range-diff master jonasschnelli/2020/12/filterblocks_rpc jamesob/2021-11-scanblocks`): https://gist.github.com/jamesob/aa4a975344209f0316444b8de2ec1d18

  ### Original PR description

  > The `scanblocks` RPC call allows one to get relevant blockhashes from a set of descriptors by scanning all blockfilters in a given range.
  >
  > **Example:**
  >
  > `scanblocks start '["addr(<bitcoin_address>)"]' 661000` (returns relevant blockhashes for `<bitcoin_address>` from blockrange 661000->tip)
  >
  > ## Why is this useful?
  > **Fast wallet rescans**: get the relevant blocks and only rescan those via `rescanblockchain getblockheader(<hash>)[height] getblockheader(<hash>)[height])`. A future PR may add an option to allow to provide an array of blockhashes to `rescanblockchain`.
  >
  > **prune wallet rescans**: (_needs additional changes_): together with a call to fetch blocks from the p2p network if they have been pruned, it would allow to rescan wallets back to the genesis block in pruned mode (relevant #15946).
  >
  > **SPV mode** (_needs additional changes_): it would be possible to build the blockfilterindex from the p2p network (rather then deriving them from the blocks) and thus allow some sort of hybrid-SPV mode with moderate bandwidth consumption (related #9483)

ACKs for top commit:
  furszy:
    diff re-ACK 626b7c8

Tree-SHA512: f84e4dcb851b122b39e9700c58fbc31e899cdcf9b587df9505eaf1f45578cc4253e89ce2a45d1ff21bd213e31ddeedbbcad2c80810f46755b30acc17b07e2873
2022-10-13 10:48:16 -04:00
Andrew Chow
6912a28f08
Merge bitcoin/bitcoin#25667: assumeutxo: snapshot initialization
bf95976061 doc: add note about snapshot chainstate init (James O'Beirne)
e4d7995286 test: add testcases for snapshot initialization (James O'Beirne)
cced4e7336 test: move-only-ish: factor out LoadVerifyActivateChainstate() (James O'Beirne)
51fc9241c0 test: allow on-disk coins and block tree dbs in tests (James O'Beirne)
3c361391b8 test: add reset_chainstate parameter for snapshot unittests (James O'Beirne)
00b357c215 validation: add ResetChainstates() (James O'Beirne)
3a29dfbfb2 move-only: test: make snapshot chainstate setup reusable (James O'Beirne)
8153bd9247 blockmanager: avoid undefined behavior during FlushBlockFile (James O'Beirne)
ad67ff377c validation: remove snapshot datadirs upon validation failure (James O'Beirne)
34d1590331 add utilities for deleting on-disk leveldb data (James O'Beirne)
252abd1e8b init: add utxo snapshot detection (James O'Beirne)
f9f1735f13 validation: rename snapshot chainstate dir (James O'Beirne)
d14bebf100 db: add StoragePath to CDBWrapper/CCoinsViewDB (James O'Beirne)

Pull request description:

  This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11) (parent PR: https://github.com/bitcoin/bitcoin/pull/15606)

  ---

  Half of the replacement for #24232. The original PR grew larger than expected throughout the review process.

  This change adds the ability to initialize a snapshot-based chainstate during init if one is detected on disk. This is of course unused as of now (aside from in unittests) given that we haven't yet enabled actually loading snapshots.

  Don't be scared! There are some big move-only commits in here.

  Accompanying changes include:

  - moving the snapshot coinsdb directory from being called `chainstate_[base blockhash]` to `chainstate_snapshot`, since we only support one snapshot in use at a time. This simplifies some logic, but it necessitates writing that base blockhash out to a file within the coinsdb dir. See [discussion here](https://github.com/bitcoin/bitcoin/pull/24232#discussion_r832762880).
  - adding a simple fix in `FlushBlockFile()` that avoids a crash when attemping to flush to disk before `LoadBlockIndexDB()` is called, which happens when calling `MaybeRebalanceCaches()` during multiple chainstate init.
  - improving the unittest to allow testing with on-disk chainstates - necessary to test a simulated restart and re-initialization.

ACKs for top commit:
  naumenkogs:
    utACK bf95976061
  ariard:
    Code Review ACK bf9597606
  ryanofsky:
    Code review ACK bf95976061. Changes since last review: rebasing, switching from CAutoFile to AutoFile, adding comments, switching from BOOST_CHECK to Assert in test util, using chainman.GetMutex() in tests, destroying one ChainstateManager before creating a new one in tests
  fjahr:
    utACK bf95976061
  aureleoules:
    ACK bf95976061

Tree-SHA512: 15ae75caf19f8d12a12d2647c52897904d27b265a7af6b4ae7b858592eeadb8f9da6c2394b6baebec90adc28742c053e3eb506119577dae7c1e722ebb3b7bcc0
2022-10-13 10:19:27 -04:00
glozow
147d64dbdf
Merge bitcoin/bitcoin#25858: psbt: Only include PSBT_OUT_TAP_TREE when the output has a script path
9e386afb67 tests: Test that PSBT_OUT_TAP_TREE is included correctly (Andrew Chow)
30ff25cf37 psbt: Only include m_tap_tree if it has scripts (Andrew Chow)
0577d423ad psbt: Change m_tap_tree to store just the tuples (Andrew Chow)
22c051ca70 tests: Test that PSBT_OUT_TAP_TREE is combined correctly (Andrew Chow)
7df6e1bb77 psbt: Fix merging of m_tap_tree (Andrew Chow)
0652dc53b2 [BugFix]: Do not allow deserializing PSBT with empty PSBT_OUT_TAP_TREE (Jeremy Rubin)

Pull request description:

  PSBT_OUT_TAP_TREE should not be included for outputs that do not have such a tree. This should be disallowed during parsing, as well as prior to serialization when the field is populated during updating.

  Also added some test cases.

  Alternative to #25856

ACKs for top commit:
  instagibbs:
    ACK 9e386afb67
  darosior:
    ACK 9e386afb67

Tree-SHA512: ce5c02a69752d176dbd967c1e8d30129b1905c8f186aeeef034576c1de82059271a1ee846bd040f5be4e66bb77ba711dcf14ac1e597c5707d7e7e2293f6cfefb
2022-10-13 09:40:27 -04:00
MacroFake
fa51cc9651
refactor: Use type-safe time point for CWallet::m_next_resend 2022-10-13 14:49:18 +02:00
fanquake
aa6fb37acc
Merge bitcoin/bitcoin#26205: wallet: #25768 follow ups
b01682a812 refactor: revert m_next_resend to not be std::atomic (stickies-v)
9245f45670 wallet: only update m_next_resend when actually resending (stickies-v)
7fbde8af5c refactor: carve out tx resend timer logic into ShouldResend (stickies-v)
01f3534632 refactor: remove unused locks for ResubmitWalletTransactions (stickies-v)
c6e8e11fb0 wallet: fix capitalization in docstring (stickies-v)

Pull request description:

  This PR addresses the outstanding comments/issues from #25768:

  - capitalization [typo](https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958572522) in docstring
  - remove [unused locks](01f3534632) that we previously needed for `ReacceptWalletTransactions()`
  - before #25768, only `ResendWalletTransactions()` would reset `m_next_resend` (formerly called `nNextResend`). By unifying it with `ReacceptWalletTransactions()` into `ResubmitWalletTransactions()`, the number of callsites that would reset the `m_next_resend` timer increased
    - since `m_next_resend` is only used in case of `relay=true` (formerly `ResendWalletTransactions()`), this is unintuitive
    - it leads to [unexpected behaviour](https://github.com/bitcoin/bitcoin/pull/25768#issuecomment-1252619427) such as transactions potentially never being rebroadcasted.
    - it makes the ResubmitWalletTransactions()` logic [more complicated than strictly necessary](https://github.com/bitcoin/bitcoin/pull/25768#discussion_r962828563)
    - since #25768, we relied on an earlier call of `ResubmitWalletTransactions(relay=false, force=true)` to initialize `m_next_resend()`, I think we can more elegantly do that by just providing `m_next_resend` with a default value
    - just to highlight: this commit introduces behaviour change

  Note: the `if (!fBroadcastTransactions)` in `CWallet:ShouldResend()` is duplicated on purpose, since it potentially avoids the slightly more expensive `if (!chain().isReadyToBroadcast())` check afterwards. I don't have a strong view on it, so happy to remove that additional check to reduce the diff, too.

ACKs for top commit:
  aureleoules:
    ACK b01682a812
  achow101:
    ACK b01682a812

Tree-SHA512: ac5f1d8858f8dd736dd1480f385984d660c1916b62a42562317020e8f9fd6a30bd8f23d973d47e4c9480d744c5ba39fdbefd69568a5eb0589a8422d7e5971c1c
2022-10-13 12:09:44 +08:00
fanquake
422efcad36
Merge bitcoin/bitcoin#26188: test: silence TSAN false positive in coinstatsindex_initial_sync
861cb3fadc test: move SyncWithValidationInterfaceQueue() before Stop() in txindex_tests (Vasil Dimov)
6526dc3b78 test: silence TSAN false positive in coinstatsindex_initial_sync (Vasil Dimov)

Pull request description:

  Silence false positives from TSAN about unsynchronized calls to `BaseIndex::~BaseIndex()` and `BaseIndex::SetBestBlockIndex()`. They are synchronized, but beyond the comprehension of TSAN - by `SyncWithValidationInterfaceQueue()`, called from `BaseIndex::BlockUntilSyncedToCurrentChain()`.

  Fixes https://github.com/bitcoin/bitcoin/issues/25365

ACKs for top commit:
  MarcoFalke:
    review ACK 861cb3fadc
  ryanofsky:
    Code review ACK 861cb3fadc. Just comment change since last review.

Tree-SHA512: 8c30fdf2fd11d54e9adfa68a67185ab820bd7bd9f7f3ad6456e7e6d219fa9cf6d34b41e98e723eae86cb0c1baef7f3fc57b1b011a13dc3fe3d78334b9b5596de
2022-10-13 11:42:27 +08:00
glozow
7e1007a3c6
Merge bitcoin/bitcoin#25421: net: convert standalone IsSelectableSocket() and SetSocketNonBlocking() to Sock methods
b527b54950 net: convert standalone SetSocketNonBlocking() to Sock::SetNonBlocking() (Vasil Dimov)
29f66f7682 moveonly: move SetSocketNonBlocking() from netbase to util/sock (Vasil Dimov)
b4bac55679 net: convert standalone IsSelectableSocket() to Sock::IsSelectable() (Vasil Dimov)
5db7d2ca0a moveonly: move IsSelectableSocket() from compat.h to sock.{h,cpp} (Vasil Dimov)

Pull request description:

  _This is a piece of #21878, chopped off to ease review._

  * convert standalone `IsSelectableSocket()` to `Sock::IsSelectable()`
  * convert standalone `SetSocketNonBlocking()` to `Sock::SetNonBlocking()`

  This further encapsulates syscalls inside the `Sock` class and makes the callers mockable.

ACKs for top commit:
  jonatack:
    ACK b527b54950 review/debug build/unit tests at each commit, cross-referenced the changes with `man select` and `man errno`, ran a signet node on the last commit with ip4/ip6//tor/i2p/cjdns and network connections were nominal
  dergoegge:
    Code review ACK b527b54950

Tree-SHA512: af783ce558c7a89e173f7ab323fb3517103d765c19b5d14de29f64706b4e1fea3653492e8ea73ae972699986aaddf2ae72c7cfaa7dad7614254283083b7d2632
2022-10-12 15:49:02 -04:00
glozow
cc12b8947b
Merge bitcoin/bitcoin#24858: incorrect blk file size calculation during reindex results in recoverable blk file corruption
bcb0cacac2 reindex, log, test: fixes #21379 (mruddy)

Pull request description:

  Fixes #21379.

  The blocks/blk?????.dat files are mutated and become increasingly malformed, or corrupt, as a result of running the re-indexing process.
  The mutations occur after the re-indexing process has finished, as new blocks are appended, but are a result of a re-indexing process miscalculation that lingers in the block manager's `m_blockfile_info` `nSize` data until node restart.
  These additions to the blk files are non-fatal, but also not desirable.
  That is, this is a form of data corruption that the reading code is lenient enough to process (it skips the extra bytes), but it adds some scary looking log messages as it encounters them.

  The summary of the problem is that the re-index process double counts the size of the serialization header (magic message start bytes [4 bytes] + length [4 bytes] = 8 bytes) while calculating the blk data file size (both values already account for the serialization header's size, hence why it is over accounted).

  This bug manifests itself in a few different ways, after re-indexing, when a new block from a peer is processed:
  1. If the new block will not fit into the last blk file processed while re-indexing, while remaining under the 128MiB limit, then the blk file is flushed to disk and truncated to a size that is 8 greater than it should be. The truncation adds zero bytes (see `FlatFileSeq::Flush` and `TruncateFile`).
  1. If the last blk file processed while re-indexing has logical space for the new block under the 128 MiB limit:
      1. If the blk file was not already large enough to hold the new block, then the zeros are, in effect, added by `fseek` when the file is opened for writing. Eight zero bytes are added to the end of the last blk file just before the new block is written. This happens because the write offset is 8 too great due to the miscalculation. The result is 8 zero bytes between the end of the last block and the beginning of the next block's magic + length + block.
      1. If the blk file was already large enough to hold the new block, then the current existing file contents remain in the 8 byte gap between the end of the last block and the beginning of the next block's magic + length + block. Commonly, when this occcurs, it is due to the blk file containing blocks that are not connected to the block tree during reindex and are thus left behind by the reindex process and later overwritten when new blocks are added. The orphaned blocks can be valid blocks, but due to the nature of concurrent block download, the parent may not have been retrieved and written by the time the node was previously shutdown.

ACKs for top commit:
  LarryRuane:
    tested code-review ACK bcb0cacac2
  ryanofsky:
    Code review ACK bcb0cacac2. This is a disturbing bug with an easy fix which seems well-worth merging.
  mzumsande:
    ACK bcb0cacac2 (reviewed code and did some testing, I agree that it fixes the bug).
  w0xlt:
    tACK bcb0cacac2

Tree-SHA512: acc97927ea712916506772550451136b0f1e5404e92df24cc05e405bb09eb6fe7c3011af3dd34a7723c3db17fda657ae85fa314387e43833791e9169c0febe51
2022-10-12 14:13:54 -04:00
fanquake
1d277f4223
Merge bitcoin/bitcoin#26280: rpc: Return coinbase flag in scantxoutset
fa08663344 rpc: Return coinbase flag in scantxoutset (MacroFake)

Pull request description:

  I guess it can't hurt to return this for someone that wants to know it

ACKs for top commit:
  aureleoules:
    ACK fa08663344
  shaavan:
    ACK fa08663344

Tree-SHA512: 04c554b3ed9877bab93ffcf0c1a4430cd41b30c5f4f3bf462a518fc8b3d68832dd85a29e81bd805eaa16e987856933d7a888a8c126f670bb2844bbd5ca1bf902
2022-10-12 10:28:32 +08:00
fanquake
5fc3939850
Merge bitcoin/bitcoin#22087: Validate port-options
04526787b5 Validate `port` options (amadeuszpawlik)
f8387c4234 Validate port value in `SplitHostPort` (amadeuszpawlik)

Pull request description:

  Validate `port`-options, so that invalid values are rejected early in the startup.
  Ports are `uint16_t`s, which effectively limits a port's value to <=65535. As discussed in https://github.com/bitcoin/bitcoin/pull/24116 and https://github.com/bitcoin/bitcoin/pull/24344, port "0" is considered invalid too.
  Proposed in https://github.com/bitcoin/bitcoin/issues/21893#issuecomment-835784223

  The `SplitHostPort(std::string in, uint16_t& portOut, std::string& hostOut)` now returns a bool that indicates whether the port value was set and within the allowed range. This is an improvement that can be used not only for port validation of options at startup, but also in rpc calls, etc,

ACKs for top commit:
  luke-jr:
    utACK 04526787b5
  ryanofsky:
    Code review ACK 04526787b5. Just suggested changes since last review: reverting some SplitHostPort changes, adding release notes, avoiding 'GetArgs[0]` problem.

Tree-SHA512: f1ac80bf98520b287a6413ceadb41bc3a93c491955de9b9319ee1298ac0ab982751905762a287e748997ead6198a8bb7a3bc8817ac9e3d2468e11ab4a0f8496d
2022-10-12 08:59:18 +08:00
Anthony Towns
7082ce3e88 scripted-diff: rename and de-globalise g_cs_orphans
-BEGIN VERIFY SCRIPT-
sed -i -e 's/static RecursiveMutex/mutable Mutex/' src/txorphanage.h
sed -i -e '/RecursiveMutex/d' src/txorphanage.cpp
sed -i -e 's/g_cs_orphans/m_mutex/g' $(git grep -l g_cs_orphans src/)
-END VERIFY SCRIPT-
2022-10-11 23:35:37 +10:00
Anthony Towns
733d85f79c Move all g_cs_orphans locking to txorphanage 2022-10-11 23:35:32 +10:00
Vasil Dimov
861cb3fadc
test: move SyncWithValidationInterfaceQueue() before Stop() in txindex_tests
So that the call order is the same as in coinstatsindex_tests.
2022-10-11 09:45:55 +02:00
Vasil Dimov
6526dc3b78
test: silence TSAN false positive in coinstatsindex_initial_sync
Fixes https://github.com/bitcoin/bitcoin/issues/25365
2022-10-11 09:45:54 +02:00
Anthony Towns
a936f41a5d txorphanage: make m_peer_work_set private 2022-10-11 14:05:09 +10:00
Anthony Towns
3614819864 txorphange: move orphan workset to txorphanage 2022-10-11 14:04:49 +10:00
fanquake
2e77dff744
Merge bitcoin/bitcoin#25676: sync: simplify and remove unused code from sync.h
75c3f9f880 sync: rename AnnotatedMixin::UniqueLock to AnnotatedMixin::unique_lock (Vasil Dimov)
8d9ee8efe8 sync: remove DebugLock alias template (Vasil Dimov)
4b2e16763f sync: avoid confusing name overlap (Mutex) (Vasil Dimov)
9d7ae4b66c sync: remove unused template parameter from ::UniqueLock (Vasil Dimov)
11c190e3f1 sync: simplify MaybeCheckNotHeld() definitions by using a template (Vasil Dimov)

Pull request description:

  Summary:

  * Reduce 4 of the `MaybeCheckNotHeld()` definitions to 2 by using a template.
  * Remove unused template parameter from `::UniqueLock`.
  * Use `MutexType` instead of `Mutex` for a template parameter name to avoid overlap/confusion with the `Mutex` class.
  * Rename `AnnotatedMixin::UniqueLock` to `AnnotatedMixin::unique_lock` to avoid overlap/confusion with the global `UniqueLock` and for consistency with `UniqueLock::reverse_lock`.

  The first commit `sync: simplify MaybeCheckNotHeld() definitions by using a template` is also part of https://github.com/bitcoin/bitcoin/pull/25390

ACKs for top commit:
  aureleoules:
    ACK 75c3f9f880 - LGTM
  ryanofsky:
    Code review ACK 75c3f9f880. Nice cleanups! Just suggested changes since last review: keeping UniqueLock name and fixing a missed rename in a code comment

Tree-SHA512: ec261f6a444bdfe4f06e844b57b3606fdd9b2f842647cae15266d9729970d87585c808d482fbba0b31c33a4aa03527c36e282c92b28d9052711f75a7048c96f1
2022-10-11 09:18:55 +08:00
Leonardo Araujo
2dede9f675 Adjust RPCTypeCheckObj error string 2022-10-10 18:08:00 -03:00
Ben Woosley
6630a1e844
Add warning on first startup if free disk space is less than necessary
To accommodate the expected blocks data.

Co-authored-by: Antoine Poinsot <darosior@protonmail.com>
Co-authored-by: benthecarman <benthecarman@live.com>
Co-authored-by: Justin Litchfield <litch@me.com>
Co-authored-by: Liran Cohen <c.liran.c@gmail.com>
Co-authored-by: Ryan Loomba <ryan.loomba@gmail.com>
Co-authored-by: Buck Perley <bucko.perley@gmail.com>
Co-authored-by: bajjer <bajjer@bajjer.xyz>
Co-authored-by: Suhail Saqan <suhail.saqan@gmail.com>
Co-authored-by: Christopher Sweeney <sweeney.chris@gmail.com>
Co-authored-by: Alyssa <orbitalturtle@protonmail.com>
Co-authored-by: Ben Schroth <ben@styng.social>
Co-authored-by: Jason Hester <mail@jason-hester.me>
Co-authored-by: Matt Clough <Matt.clough@pm.me>
Co-authored-by: Elise Schedler <eliseschedler@gmail.com>
Co-authored-by: ghander <cen254@gmail.com>
Co-authored-by: PopeLaz <btclz@fastmail.com>
Co-authored-by: Aurèle Oulès <hello@aureleoules.com>
2022-10-10 16:58:14 -04:00
MacroFake
9ca39d69df
Merge bitcoin/bitcoin#26254: iwyu: Add zmq source files
13afcc0cd4 iwyu: Add zmq source files (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK 13afcc0cd4

Tree-SHA512: 7af95e991fc2782aeba2edfef0a2f75f9c361058295586adb062087aa31c47cfcce2425aee9dd5153e18e018cf1f9272c9617c671b7262db55f241526c3fcb15
2022-10-10 18:08:45 +02:00
Aurèle Oulès
5d3f98d278
refactor: Replace m_params with chainman.GetParams()
Fixes a TODO introduced in #24595.
2022-10-10 17:43:45 +02:00
Hennadii Stepanov
13afcc0cd4
iwyu: Add zmq source files 2022-10-10 15:44:02 +01:00
MacroFake
239757409b
Merge bitcoin/bitcoin#26118: log: Use steady clock for bench logging
fabf1cdb20 Use steady clock for bench logging (MacroFake)
faed342a23 scripted-diff: Rename time symbols (MacroFake)

Pull request description:

  Instead of using `0.001` and similar constants to "convert" an int64_t to milliseconds, use the type-safe `Ticks<>` helper. Also, use steady clock instead of system clock, since the durations are used for benchmarking.

ACKs for top commit:
  fanquake:
    ACK fabf1cdb20 - validation bench output still looks sane.

Tree-SHA512: e6525b5fdad6045ca500c56014897d7428ad288aaf375933d3b5939feddf257f6910d562eb66ebcde9186bef9a604ee8d763a318253838318d59df2a285be7c2
2022-10-10 12:00:34 +02:00
fanquake
866dd664a1
Merge bitcoin/bitcoin#26196: kernel: move RunCommandParseJSON to its own file
43b8777dc3 refactor: move run_command from util to common (Cory Fields)
192325a77d kernel: move RunCommandParseJSON to its own file (Cory Fields)

Pull request description:

  Because libbitcoinkernel does not include this new object, this has the side-effect of eliminating its unnecessary `boost::process` dependency.

  This leaves libbitcoinkernel with 3 remaining boost dependencies:
  - `boost::date_time` for `util/time.cpp`, which I'll separate out next. Exactly like this PR.
  - `boost::signals2` for which I have a POC re-implementation here: https://github.com/theuni/bitcoin/commits/replace-boost-signals
  - `boost::multi_index` which I'm not sure about yet.

ACKs for top commit:
  ryanofsky:
    Code review ACK 43b8777dc3. Could consider squashing the two commits, so the code just moves once instead of twice.
  fanquake:
    ACK 43b8777dc3

Tree-SHA512: f2a46cac34aaadfb8a1442316152ad354f6990021b82c78d80cae9fd43cd026209ffd62132eaa99d5d0f8cf34e996b6737d318a9d9a3f1d2ff8d17d697abf26d
2022-10-10 17:58:18 +08:00
fanquake
869342f7fa
Merge bitcoin/bitcoin#26282: wallet: have prune error take precedence over assumedvalid
1c36bafc5f wallet: have prune error take precedence over assumedvalid (James O'Beirne)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/pull/23997#discussion_r891412739.

  From Russ Yanofsky:

  > Agree with all of Marco's points here and think this should be updated
  >
  > If havePrune and hasAssumedValidChain are both true, better to show havePrune error message.  Assumed-valid error message is vague and not very actionable.  Would suggest "Error loading wallet. Wallet requires blocks to be downloaded, and software does not currently support loading wallets while blocks are being downloaded out of order though assumeutxo snapshots. Wallet should be able to load successfully after node sync reaches height {block_height}"

ACKs for top commit:
  MarcoFalke:
    ACK 1c36bafc5f
  aureleoules:
    ACK 1c36bafc5f

Tree-SHA512: bfb0024bb962525cbbd392ade3c0331a8b0525e7f2f2ab52b2dbb9b6dd6311070d85ecb762a7689db84a30991971865698ab6fec187206e6a92133790c5a91dc
2022-10-10 17:04:43 +08:00
fanquake
9eaa5dbc81
Merge bitcoin/bitcoin#25073: test: Cleanup miner_tests
faa15527d7 test: Use dedicated mempool in TestBasicMining (MacroFake)
fafab384a0 test: Use dedicated mempool in TestPackageSelection (MacroFake)
fa4055d79c test: Use dedicated mempool in TestPrioritisedMining (MacroFake)
fa29218285 test: Pass mempool reference to AssemblerForTest (MacroFake)

Pull request description:

  This cleans up the miner tests:

  * Removes duplicate/redundant and thus confusing chainparams object.
  * Uses a fresh mempool for each subtest instead of using the "global" one from the testing setup. This makes it easier to follow the tests in smaller scopes. Also it makes sure the mempool is truly cleared by reconstructing it. Finally, this removes calls to `clear`, see https://github.com/bitcoin/bitcoin/pull/19909

ACKs for top commit:
  glozow:
    utACK faa15527d7

Tree-SHA512: ced1260f6ab70fba74b0fac7ff4fc7adfddcd2f3bee785249d2a4a9055ac253eff9090edbda7a17e72a71a81b56ff708d5ff64e1f57ebc7b7747d6c88fec51e3
2022-10-10 16:45:39 +08:00
MacroFake
9f44f2e32f
Merge bitcoin/bitcoin#26284: Fix comment typos
adb1714426 Fix comment typos in scriptpubkeyman.cpp, wallet.cpp, wallet.h (Dimitris Tsapakidis)

Pull request description:

  Fixes a number of comment typos found in the code.

Top commit has no ACKs.

Tree-SHA512: c2c996b66d33ecf0ee734b76303a0f2444e184d2f3ff6931768712ca51011ad51e54336c33a2ff55133766d20ae6adcbb14ddc754dde58b1fe9167d68f54fec5
2022-10-10 09:32:51 +02:00
Vasil Dimov
75c3f9f880
sync: rename AnnotatedMixin::UniqueLock to AnnotatedMixin::unique_lock
This avoids confusion with the global `UniqueLock` and the snake case
is consistent with `UniqueLock::reverse_lock.
2022-10-10 09:20:59 +02:00
Vasil Dimov
8d9ee8efe8
sync: remove DebugLock alias template
Use `UniqueLock` directly. Type deduction works just fine from the first
argument to the constructor of `UniqueLock`, so there is no need to
repeat

```cpp
UniqueLock<typename std::remove_reference<typename std::remove_pointer<decltype(cs)>::type>::type>
```

five times in the `LOCK` macros. Just `UniqueLock` suffices.
2022-10-10 09:20:58 +02:00
Vasil Dimov
4b2e16763f
sync: avoid confusing name overlap (Mutex)
Use `MutexType` instead of `Mutex` for the template parameter of
`UniqueLock` because there is already a class named `Mutex` and the
naming overlap is confusing. `MutexType` is used elsewhere in `sync.h`.
2022-10-10 09:20:45 +02:00
fanquake
4175c332b9
Merge bitcoin/bitcoin#26215: index: Improve BaseIndex::BlockUntilSyncedToCurrentChain reliability
8891949bdc index: Improve BaseIndex::BlockUntilSyncedToCurrentChain reliability (Ryan Ofsky)

Pull request description:

  Since commit f08c9fb0c6 from PR https://github.com/bitcoin/bitcoin/pull/21726, index  `BlockUntilSyncedToCurrentChain` behavior has been less reliable, and there has also been a race condition in the `coinstatsindex_initial_sync` unit test.

  It seems better for `BlockUntilSyncedToCurrentChain` to actually wait for the last connected block to be fully processed, than to be able to return before prune locks are set, so this switches the order of `m_best_block_index = block;` and `UpdatePruneLock` statements in `SetBestBlockIndex` to make it more reliable.

  Also since commit f08c9fb0c6, there has been a race condition in the `coinstatsindex_initial_sync` test. Before that commit, the atomic index best block pointer `m_best_block_index` was updated as the last step of `BaseIndex::BlockConnected`, so `BlockUntilSyncedToCurrentChain` could safely be used in tests to wait for the last `BlockConnected` notification to be finished before stopping and destroying the index.  But after that commit, calling `BlockUntilSyncedToCurrentChain` is no longer sufficient, and there is a race between the test shutdown code which destroys the index object and the new code introduced in that commit calling `AllowPrune()` and `GetName()` on the index object. Reproducibility instructions for this are in https://github.com/bitcoin/bitcoin/issues/25365#issuecomment-1259744133

  This commit fixes the `coinstatsindex_initial_sync` race condition, even though it will require an additional change to silence TSAN false positives, https://github.com/bitcoin/bitcoin/pull/26188, after it is fixed. So this partially addresses but does not resolve the bug reporting TSAN errors https://github.com/bitcoin/bitcoin/issues/25365.

  There is no known race condition outside of test code currently, because the bitcoind `Shutdown` function calls `FlushBackgroundCallbacks` not `BlockUntilSyncedToCurrentChain` to safely shut down.

  Co-authored-by: vasild
  Co-authored-by: MarcoFalke

ACKs for top commit:
  mzumsande:
    re-ACK 8891949bdc

Tree-SHA512: 52e29e3772a0c92873c54e5ffb31dd66a909b68a2031b7585713cd1d976811289c98bd9bb41679a8689062f03be4f97bb8368696e789caa4607c2fd8b1fe289b
2022-10-10 14:23:00 +08:00
fanquake
cf3db7c256
Merge bitcoin/bitcoin#26258: refactor: Remove unused CDataStream::rdbuf method
fabbbe32ee Remove unused CDataStream::rdbuf method (MacroFake)

Pull request description:

  It is unused and seems unlikely to be ever used.

ACKs for top commit:
  theStack:
    Code-review ACK fabbbe32ee
  aureleoules:
    ACK fabbbe32ee

Tree-SHA512: 5804642658f96a0fb51482ebf3a062bb0f997c1e0527455afa4aceeeb6c1ad139a98b14a7c8a0909daba733a83bdc24fcadad45060ead4be6eb3dc3e66c129e2
2022-10-10 14:14:15 +08:00
glozow
d33c5894e9
Merge bitcoin/bitcoin#26103: refactor: mempool: use CTxMemPool::Limits
33b12e5df6 docs: improve docs where MemPoolLimits is used (stickies-v)
6945853c0b test: use NoLimits() in MempoolIndexingTest (stickies-v)
3a86f24a4c refactor: mempool: use CTxMempool::Limits (stickies-v)
b85af25f87 refactor: mempool: add MemPoolLimits::NoLimits() (stickies-v)

Pull request description:

  Mempool currently considers 4 limits regarding ancestor and descendant count and size, which get passed around between functions quite a bit. This PR uses `CTxMemPool::Limits` introduced in https://github.com/bitcoin/bitcoin/pull/25290 to simplify those signatures and callsites.

  The purpose of this PR is to improve readability and maintenance, without behaviour change.

  As noted in the first commit "refactor: mempool: change MemPoolLimits members to uint", we currently have an underflow issue where a user could pass a negative `-limitancestorsize`, which is eventually cast to an unsigned integer. This behaviour already exists. Because it's orthogonal and to minimize scope, I think this should be fixed in a separate PR.

ACKs for top commit:
  hebasto:
    ACK 33b12e5df6, I have reviewed the code and it looks OK, I agree it can be merged.
  glozow:
    reACK 33b12e5df6

Tree-SHA512: 591c6dcee1894f1c3ca28b34a680eeadcf0d40cda92451b4a422c03087b27d682b5e30ba4367abd75a99b5ccb115b7884b0026958d3c7dddab030549db5a4056
2022-10-09 10:28:32 -04:00
Dimitris Tsapakidis
adb1714426 Fix comment typos in scriptpubkeyman.cpp, wallet.cpp, wallet.h
Fix comment typos:
sigature -> signature
ponter -> pointer
it's key -> its key
2022-10-09 17:19:59 +03:00
glozow
ec8016eba7
Merge bitcoin/bitcoin#26281: docs: fix m_children to be a member of CTxMemPoolEntry
01bf4af4f2 docs: fix m_children to be a member of CTxMemPoolEntry (stickies-v)

Pull request description:

  Small documentation fix to reflect that `m_children` [is a member](73b61717a9/src/txmempool.h (L99)) of `CTxMemPoolEntry`, not `CTxMemPool`

ACKs for top commit:
  hebasto:
    ACK 01bf4af4f2, wrong wording was introduced in bitcoin/bitcoin#19478.
  glozow:
    ACK 01bf4af4f2

Tree-SHA512: b66c43b92fda44682b1f67c43073ca9e133a6dc03cd28253e571e67170531138c20b22ffdb08f312fb2d47a1f869b876611646b54325c8b614d12049befad578
2022-10-09 10:17:02 -04:00
James O'Beirne
1c36bafc5f
wallet: have prune error take precedence over assumedvalid
From Russ Yanofsky:

"Agree with all of Marco's points here and think this should be updated

If havePrune and hasAssumedValidChain are both true, better to show
havePrune error message.  Assumed-valid error message is vague and not
very actionable.  Would suggest "Error loading wallet. Wallet requires
blocks to be downloaded, and software does not currently support loading
wallets while blocks are being downloaded out of order though assumeutxo
snapshots. Wallet should be able to load successfully after node sync
reaches height {block_height}"

Co-authored-by: MacroFake <MarcoFalke@gmail.com>
Co-authored-by: Russ Yanofsky <russ@yanofsky.org>
2022-10-07 15:19:31 -04:00
stickies-v
01bf4af4f2
docs: fix m_children to be a member of CTxMemPoolEntry 2022-10-07 15:06:45 +01:00
MacroFake
fa08663344
rpc: Return coinbase flag in scantxoutset 2022-10-07 15:04:28 +02:00
Anthony Towns
6f8e442ba6 net_processing: Localise orphan_work_set handling to ProcessOrphanTx 2022-10-07 14:41:24 +10:00
Anthony Towns
0027174b39 net_processing: move ProcessOrphanTx docs to declaration 2022-10-07 14:40:50 +10:00
Anthony Towns
9910ed755c net_processing: Pass a Peer& to ProcessOrphanTx 2022-10-07 14:40:26 +10:00
Anthony Towns
89e2e0da0b net_processing: move extra transactions to msgproc mutex
Previously vExtraTxnForCompact and vExtraTxnForCompactIt were protected
by g_cs_orphans; protect them by g_msgproc_mutex instead, as they
are only used during message processing.
2022-10-07 14:40:03 +10:00
Anthony Towns
ff8d44d196 Remove unnecessary includes of txorphange.h 2022-10-07 14:39:40 +10:00
josibake
2e3826cbcd
util: warn if reindex is used in conf
using reindex in a conf file can lead to the node reindexing on every restart.
we still allow it but throw a warning.
2022-10-06 18:20:30 -04:00
josibake
5e744f4238
util: disallow setting conf in bitcoin.conf
Help from `bitcoind -h` states that conf can only be used from the commandline.
However, if conf is set in a bitcoin.conf file, it is ignored but there is no error.

Show an error to user if conf is set in a .conf file and prompt them to use
`includeconf` if they wish to specify additional config files.

Adds `IsConfSupported` function to allow for easily adding conf options
to disallow or throw warnings for.
2022-10-06 18:20:14 -04:00
Andrew Chow
30ff25cf37 psbt: Only include m_tap_tree if it has scripts 2022-10-06 15:32:51 -04:00
Andrew Chow
0577d423ad psbt: Change m_tap_tree to store just the tuples
Instead of having an entire TaprootBuilder which may or may not be
complete, and could potentially have future changes that interact oddly
with taproot tree tuples, have m_tap_tree be just the tuples.

When needed in other a TaprootBuilder for actual use, the tuples will be
added to a a TaprootBuilder that, in the future, can take in whatever
other data is needed as well.
2022-10-06 15:32:51 -04:00
Andrew Chow
7df6e1bb77 psbt: Fix merging of m_tap_tree
Merging should be checking that the current PSBTOutput doesn't have a
taptree and the other one's is copied over. The original merging had
this inverted and would remove m_tap_tree if the other did not have it.
2022-10-06 15:19:30 -04:00
MacroFake
73b61717a9
Merge bitcoin/bitcoin#26272: test: Prevent UB in minisketch_tests.cpp
97007e2b9b test: Prevent UB in `minisketch_tests.cpp` (Hennadii Stepanov)

Pull request description:

  [`std::optional::operator*`](https://en.cppreference.com/w/cpp/utility/optional/operator*), which follows after the changed line, can cause UB.

  This PR addresses https://github.com/bitcoin/bitcoin/issues/26262#issuecomment-1268855418

ACKs for top commit:
  stickies-v:
    ACK 97007e2b9b

Tree-SHA512: a7dde8dac0cbdfa362fa1158b4564eccff9405852612227d581690c9a34084b3467ae6d4c0269262688d75339dcea90aaa38fccbba9be92d2643c2113860f3d6
2022-10-06 16:01:17 +02:00
Hennadii Stepanov
97007e2b9b
test: Prevent UB in minisketch_tests.cpp 2022-10-06 12:50:54 +01:00
glozow
292f652d53
Merge bitcoin/bitcoin#24364: refactor: remove duplicate code from BlockAssembler
0f40d65321 refactor: remove duplicate code from BlockAssembler (James O'Beirne)

Pull request description:

  Found while reminding myself how transactions are chosen for blocks. Take it or leave it!

ACKs for top commit:
  glozow:
    ACK 0f40d65321
  theStack:
    Concept and code-review ACK 0f40d65321

Tree-SHA512: 8a2694e670ce3fe897ab8f64f64c8df5f8487fc1264527a3abbcba0e5b921fb693416497ccd62508295bc33f202c65556b91b6af463acb91aab43138d2492c14
2022-10-06 12:50:33 +01:00
muxator
addf9d6502 rpc: fix crash in deriveaddresses when derivation index is 2147483647
2147483647 is the maximum positive value of a signed int32, and - currently -
the maximum value that the deriveaddresses bitcoin RPC call accepts as
derivation index due to its input validation routines.

Before this change, when the derivation index (and thus range_end) reached
std::numeric_limits<int_32_t>::max(), the "i" variable in the for cycle (which
is declared as int, and as such 32 bits in size on most platforms) would be
incremented at the end of the first iteration and then warp back to
-2147483648. This caused SIGABRT in bitcoind and a core dump.

This change assigns "i" an explicit size of 64 bits on every platform,
sidestepping the problem.

Fixes #26274.
2022-10-06 22:17:49 +02:00
amadeuszpawlik
04526787b5 Validate port options
Check `port` options for invalid values (ports are parsed as uint16, so
in practice values >65535 are invalid; port 0 is undefined and therefore
considered invalid too). This allows for an early rejection of faulty
values and an supplying an informative message to the user.

Splits tests in `feature_proxy.py` to cover both invalid `hostname`
and `port` values.

Adds a release-note as previously valid `-port` and `-rpcport` values
can now result in errors.
2022-10-05 19:30:15 +02:00
amadeuszpawlik
f8387c4234 Validate port value in SplitHostPort
Forward the validation of the port from `ParseUInt16(...)`.
Consider port 0 as invalid.
Add suitable test for the `SplitHostPort` function.
Add doxygen description to the `SplitHostPort` function.
2022-10-05 19:24:04 +02:00
Ryan Ofsky
8891949bdc index: Improve BaseIndex::BlockUntilSyncedToCurrentChain reliability
Since commit f08c9fb0c6 from PR
https://github.com/bitcoin/bitcoin/pull/21726, index
`BlockUntilSyncedToCurrentChain` behavior has been less reliable, and there has
also been a race condition in the `coinstatsindex_initial_sync` unit test.

It seems better for `BlockUntilSyncedToCurrentChain` to actually wait for the
last connected block to be fully processed, than to be able to return before
prune locks are set, so this switches the order of `m_best_block_index =
block;` and `UpdatePruneLock` statements in `SetBestBlockIndex` to make it more
reliable.

Also since commit f08c9fb0c6, there has been a
race condition in the `coinstatsindex_initial_sync` test. Before that commit,
the atomic index best block pointer `m_best_block_index` was updated as the
last step of `BaseIndex::BlockConnected`, so `BlockUntilSyncedToCurrentChain`
could safely be used in tests to wait for the last `BlockConnected`
notification to be finished before stopping and destroying the index. But
after that commit, calling `BlockUntilSyncedToCurrentChain` is no longer
sufficient, and there is a race between the test shutdown code which destroys
the index object and the new code introduced in that commit calling
`AllowPrune()` and `GetName()` on the index object. Reproducibility
instructions for this are in
https://github.com/bitcoin/bitcoin/issues/25365#issuecomment-1259744133

This commit fixes the `coinstatsindex_initial_sync` race condition, even though
it will require an additional change to silence TSAN false positives,
https://github.com/bitcoin/bitcoin/pull/26188, after it is fixed. So this
partially addresses but does not resolve the bug reporting TSAN errors
https://github.com/bitcoin/bitcoin/issues/25365.

There is no known race condition outside of test code currently, because the
bitcoind `Shutdown` function calls `FlushBackgroundCallbacks` not
`BlockUntilSyncedToCurrentChain` to safely shut down.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
Co-authored-by: MacroFake <falke.marco@gmail.com>
2022-10-05 11:06:58 -04:00
MacroFake
5e82b9ba96
Merge bitcoin/bitcoin#26252: refactor: Make 64-bit shift explicit
5c5b85d0e7 refactor: Make 64-bit shift explicit (Hennadii Stepanov)

Pull request description:

  [`std::array::at()`](https://en.cppreference.com/w/cpp/container/array/at) expects an argument of the `size_t` type. This PR avoids implicit type conversion (for both 64-bit and 32-bit systems).

  Also it enables MSVC warning [C4334](https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4334) for all codebase.

ACKs for top commit:
  MarcoFalke:
    ACK 5c5b85d0e7 🚎
  jonatack:
    Code review ACK 5c5b85d0e7

Tree-SHA512: fda850a42068f2ada9f877fac9ff8af1e22b5dcb3e708f5b95c316e77c52c72d33cd9ec6507a7f5d1731d1afdf5af6dc65025d388cc480f82c46f4d88ef2d306
2022-10-05 15:46:23 +02:00
MacroFake
fabbbe32ee
Remove unused CDataStream::rdbuf method
It is unused and seems unlikely to be ever used.
2022-10-05 15:29:36 +02:00
Jon Atack
c2a21c0670 gui: use fallback value for Version and User Agent during peer connection
During connection setup for a peer, getpeerinfo returns "version": 0, "subver": ""
and the GUI Peers window displays 0 and an empty field, respectively.

Give these fields the same behavior as the other fields in the GUI Peers window:
display the fallback value in src/qt/forms/debugwindow.ui (i.e. "N/A") until a
valid result is available after the peer connection completes.
2022-10-05 15:19:01 +02:00
stickies-v
33b12e5df6
docs: improve docs where MemPoolLimits is used 2022-10-05 13:09:08 +01:00
stickies-v
6945853c0b
test: use NoLimits() in MempoolIndexingTest
The (100, 1000000, 1000, 1000000) limits are arbitrarily high and
don't restrict anything, they are just meant to calculate ancestors
properly. Using NoLimits() makes this intent more clear and simplifies
the code.
2022-10-05 13:07:11 +01:00
stickies-v
3a86f24a4c
refactor: mempool: use CTxMempool::Limits
Simplifies function signatures by removing repetition of all the
ancestor/descendant limits,  and increases readability by being
more verbose by naming the limits, while still reducing the LoC.
2022-10-05 13:07:11 +01:00
stickies-v
b85af25f87
refactor: mempool: add MemPoolLimits::NoLimits()
There are quite a few places in the codebase that require us to
construct a CTxMemPool without limits on ancestors and descendants.
This helper function allows us to get rid of all that duplication.
2022-10-05 13:07:11 +01:00
MacroFake
faa15527d7
test: Use dedicated mempool in TestBasicMining
No need for a shared mempool. Also remove unused chainparams parameter.

Can be reviewed with --ignore-all-space
2022-10-05 13:36:57 +02:00
MacroFake
fafab384a0
test: Use dedicated mempool in TestPackageSelection
No need for a shared mempool. Also remove unused chainparams parameter.
2022-10-05 13:36:56 +02:00
MacroFake
fa4055d79c
test: Use dedicated mempool in TestPrioritisedMining
No need for a shared mempool. Also remove unused chainparams parameter.
2022-10-05 13:35:18 +02:00
MacroFake
fa29218285
test: Pass mempool reference to AssemblerForTest 2022-10-05 13:34:36 +02:00
MacroFake
d3cdd37d92
Merge bitcoin/bitcoin#26250: fuzz: add mempool_utils.cpp
8a6b6dfcd8 fuzz: pass max fee into ConsumeTxMemPoolEntry (fanquake)
eb15569280 fuzz: add util/mempool/h.cpp (fanquake)

Pull request description:

  Moving the heavy (Boost) mempool code out of fuzz/util.h. Means that (for ex) a crypto_common fuzz unit doesn't need to care about seeing endless Boost headers. This results in a ~10% speedup (for me) when compiling the fuzz tests. Your results may vary.

ACKs for top commit:
  MarcoFalke:
    review ACK 8a6b6dfcd8 🍮

Tree-SHA512: 27dc9d9581ac0b1b319cc0dc08fe5f8fbf9269386a5cb23f6fd5d8231bf015ed942ab4414d8001220541be0013756354578ddab1fec607c6fba04daf421bc870
2022-10-05 10:29:00 +02:00
Cory Fields
43b8777dc3 refactor: move run_command from util to common
Quoting ryanofsky: "util can be the library for things included in the kernel
which the kernel can depend on, and common can be the library for other code
that needs to be shared internally, but should not be part of the kernel or
shared externally."
2022-10-04 21:21:05 +00:00
Hennadii Stepanov
5c5b85d0e7
refactor: Make 64-bit shift explicit
Also this change enables MSVC warning C4334 for all codebase.

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4334
2022-10-04 21:49:07 +01:00
fanquake
8a6b6dfcd8
fuzz: pass max fee into ConsumeTxMemPoolEntry 2022-10-04 21:12:50 +01:00
fanquake
eb15569280
fuzz: add util/mempool/h.cpp
Moving the mempool code (Boost) out of util.h, results in a ~10% speedup
(for me) when compiling the fuzz tests.
2022-10-04 21:12:50 +01:00
James O'Beirne
626b7c8493 fuzz: add scanblocks as safe for fuzzing 2022-10-04 13:51:35 -04:00
Jonas Schnelli
6ef2566b68 rpc: add scanblocks - scan for relevant blocks with descriptors
Co-authored-by: James O'Beirne <james.obeirne@gmail.com>
2022-10-04 13:51:35 -04:00
James O'Beirne
a4258f6e81 rpc: move-only: consolidate blockchain scan args
For later reuse in `scanblocks`.
2022-10-04 13:51:33 -04:00
MacroFake
dddd1acf58
net: Set relay in version msg to peers with relay permission 2022-10-04 16:07:00 +02:00
Cory Fields
192325a77d kernel: move RunCommandParseJSON to its own file
Because libbitcoinkernel does not include this new object, this has the
side-effect of eliminating the unnecessary boost::process dependency.
2022-10-04 13:51:40 +00:00
MacroFake
fa9436e908
test: Remove unused fCheckpointsEnabled from miner_tests
The earliest checkpoint is at height 11111, so this can't possibly have
any impact on this test.
2022-10-04 12:40:19 +02:00
MacroFake
914c00074b
Merge bitcoin/bitcoin#26235: refactor: move *index constants out of validation
7d14577d0f refactor: move DEFAULT_BLOCKFILTERINDEX from val to blockfilterindex (fanquake)
c87d569189 refactor: move DEFAULT_COINSTATSINDEX from validation to coinstatsindex (fanquake)
2bfc1e6aaa refactor: move DEFAULT_TXINDEX from validation to txindex (fanquake)

Pull request description:

  Move `*index` default constants out of `validation.h`.

ACKs for top commit:
  stickies-v:
    re-ACK 7d14577d0f
  aureleoules:
    ACK 7d14577d0f

Tree-SHA512: 3021db1a63ceb714dee4b91f755d1fb9a6633adb6f1081e34e4179900e7543e3a7b06fe47507d580a3a2caf52f7ede784cb36716d521c76b0404bdc798f0186a
2022-10-04 12:36:13 +02:00
MacroFake
f65a2c6f57
Merge bitcoin/bitcoin#26237: kernel: remove util/bytevectorhash.cpp
4bee62e9b8 kernel: remove util/bytevectorhash.cpp (fanquake)

Pull request description:

  This is no-longer used.

ACKs for top commit:
  hebasto:
    ACK 4bee62e9b8, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 4d61f87b640ef3c759008631433b3e6d2bd2ac54bbe0b287f32ea1569760048f17a66cfe846b94ec458a7db5d064be6da59299b9280572a3dc649df60760c63f
2022-10-04 11:34:23 +02:00
fanquake
44a29758a0
Merge bitcoin/bitcoin#26209: Update leveldb subtree
1a463c70a3 Squashed 'src/leveldb/' changes from 22f1e4a02f..e2f10b4e47 (fanquake)

Pull request description:

  Pulls in https://github.com/bitcoin-core/leveldb-subtree/pull/34: win32: fix -Wmissing-field-initializers warnings
  Related to #26090, #25972.

  Guix Build:
  ```bash
  a8c49e700309e9268ad0a503e7813775f58daf37813501775ae5831eab0cf26a  guix-build-13601da17e7a/output/aarch64-linux-gnu/SHA256SUMS.part
  3a1722403f8daf8ea152c72004fb1021f8a7241ee7f51fb0e6adeeb50881f001  guix-build-13601da17e7a/output/aarch64-linux-gnu/bitcoin-13601da17e7a-aarch64-linux-gnu-debug.tar.gz
  3b7c1f2361ef4832c305ff4b0d9eb7419f787f8cf537952d7c20be549debe0af  guix-build-13601da17e7a/output/aarch64-linux-gnu/bitcoin-13601da17e7a-aarch64-linux-gnu.tar.gz
  329cb5bc932621785a6aeca43af307279c47d87a4983ee3d59636f8e3dc27afa  guix-build-13601da17e7a/output/arm-linux-gnueabihf/SHA256SUMS.part
  4030f344c4c31cc0877c11d3b89f6ea93f930a4ae7e7976d49ad5123cc31a367  guix-build-13601da17e7a/output/arm-linux-gnueabihf/bitcoin-13601da17e7a-arm-linux-gnueabihf-debug.tar.gz
  ab50945c416b256b4c92ea0a50c0b7ec241e4c1f5803a4e7cb4ba83a6c5db888  guix-build-13601da17e7a/output/arm-linux-gnueabihf/bitcoin-13601da17e7a-arm-linux-gnueabihf.tar.gz
  604557cc73c4065697255c6971547a46cd0d6ad1cdf74261d4c73d002abe8c46  guix-build-13601da17e7a/output/arm64-apple-darwin/SHA256SUMS.part
  11e781c64fab7933df4a9b4f56357ad18dd8f149b3c9195bf2d310b58355851d  guix-build-13601da17e7a/output/arm64-apple-darwin/bitcoin-13601da17e7a-arm64-apple-darwin-unsigned.dmg
  e3fe9e278310f3dc97f463bb8cf2b930b587dba5095e18a7f38c4ef76338daad  guix-build-13601da17e7a/output/arm64-apple-darwin/bitcoin-13601da17e7a-arm64-apple-darwin-unsigned.tar.gz
  00828a9bfd74013a439b7f0254bd72904b99ff1e3a9503ef6307ee57de81c5eb  guix-build-13601da17e7a/output/arm64-apple-darwin/bitcoin-13601da17e7a-arm64-apple-darwin.tar.gz
  d80032d2509a982dc81790b3ef3cd8d44551b41047082ebc506f01bbb8830de1  guix-build-13601da17e7a/output/dist-archive/bitcoin-13601da17e7a.tar.gz
  61655cdf7c081c43275da57e5b42c21e33d7864378f3784652969ffdf7c3c2b2  guix-build-13601da17e7a/output/powerpc64-linux-gnu/SHA256SUMS.part
  3d213e2f25ca72dc0c3d372c0ad3f6803865825a233b29dd80b5cff3e3963621  guix-build-13601da17e7a/output/powerpc64-linux-gnu/bitcoin-13601da17e7a-powerpc64-linux-gnu-debug.tar.gz
  ef8cad747428b6b46c5d2c598fb7896b320a5321cf9a0c9dba2209c638bfbc7b  guix-build-13601da17e7a/output/powerpc64-linux-gnu/bitcoin-13601da17e7a-powerpc64-linux-gnu.tar.gz
  2302e022394ca46570c70bc5977f35bbed258bfbb19c2c6d80f1982a725c9e35  guix-build-13601da17e7a/output/powerpc64le-linux-gnu/SHA256SUMS.part
  5ca3104b7d546c7d905f82dfd92b5350af754e3973b533adc50c6cbde8f59f96  guix-build-13601da17e7a/output/powerpc64le-linux-gnu/bitcoin-13601da17e7a-powerpc64le-linux-gnu-debug.tar.gz
  2781824d8d08f8ac6663925db8b2d1b50b80165e67ed69df86580438284f0c3b  guix-build-13601da17e7a/output/powerpc64le-linux-gnu/bitcoin-13601da17e7a-powerpc64le-linux-gnu.tar.gz
  24a73f91c5ab9e72f2471cd7b31482c702a3de8dade9aff6b76af34253748cec  guix-build-13601da17e7a/output/riscv64-linux-gnu/SHA256SUMS.part
  b09658af4bd24eb5e76bacbfc7f8750a8941f117511b5c55a44ef1beffec8367  guix-build-13601da17e7a/output/riscv64-linux-gnu/bitcoin-13601da17e7a-riscv64-linux-gnu-debug.tar.gz
  56bde3f3df115dbf801944e4f923a08752fd05cda0bbf0e0e3c915387f98e4a8  guix-build-13601da17e7a/output/riscv64-linux-gnu/bitcoin-13601da17e7a-riscv64-linux-gnu.tar.gz
  ca9a5acb332fb2ffda42e44d84b58e273a769e94f0abaaa0623ed1d1c5267dde  guix-build-13601da17e7a/output/x86_64-apple-darwin/SHA256SUMS.part
  ccae805bca5d4075d1bccbaeca7ac40bb4dac0a97f4fd4c3c80b2d6134d6acb0  guix-build-13601da17e7a/output/x86_64-apple-darwin/bitcoin-13601da17e7a-x86_64-apple-darwin-unsigned.dmg
  b12c9682b69b3662150abd6680bb60f9fef656a1fdc3cd21951c2da571be40cc  guix-build-13601da17e7a/output/x86_64-apple-darwin/bitcoin-13601da17e7a-x86_64-apple-darwin-unsigned.tar.gz
  fd3378e4d60f0ef3ae1b18f526e96ed9e838df4def021de332dd0b6cd20ed0c4  guix-build-13601da17e7a/output/x86_64-apple-darwin/bitcoin-13601da17e7a-x86_64-apple-darwin.tar.gz
  47c7af42153850a94d70de6489389f6faf8772d6adc88269705a12e6b894e84e  guix-build-13601da17e7a/output/x86_64-linux-gnu/SHA256SUMS.part
  876898d116041680ea6fa3bbce1becb05e45ea5bdbaf973a1465fde4bd2df26d  guix-build-13601da17e7a/output/x86_64-linux-gnu/bitcoin-13601da17e7a-x86_64-linux-gnu-debug.tar.gz
  56671e22f25ba695c7315de916c6a2d1b57d5f00982b331c68a43912ac3ebc44  guix-build-13601da17e7a/output/x86_64-linux-gnu/bitcoin-13601da17e7a-x86_64-linux-gnu.tar.gz
  f5b9b7d83ad34b7b6c3cb98b9d7878795a1f6fb7b422ffb02b23266beb76d3a6  guix-build-13601da17e7a/output/x86_64-w64-mingw32/SHA256SUMS.part
  a72cfb4ce41cad3bb24df2e4bb318edd05370e12fc31f9ba21637b3fd412dccd  guix-build-13601da17e7a/output/x86_64-w64-mingw32/bitcoin-13601da17e7a-win64-debug.zip
  4b175eac7355715884be279dd4595665912b62815f1d0186ca9874cb9e6424cb  guix-build-13601da17e7a/output/x86_64-w64-mingw32/bitcoin-13601da17e7a-win64-setup-unsigned.exe
  c45d927f0adedc3eb0a01cee0f9fa734c17d9e9a6692b0f416a3830c007b52cc  guix-build-13601da17e7a/output/x86_64-w64-mingw32/bitcoin-13601da17e7a-win64-unsigned.tar.gz
  360a5b8806c72dbfcfed616d5cec78606461d664e21fb28a44bd473a2b7c9326  guix-build-13601da17e7a/output/x86_64-w64-mingw32/bitcoin-13601da17e7a-win64.zip
  ```

ACKs for top commit:
  hebasto:
    ACK 13601da17e, I have reviewed the code and it looks OK, I agree it can be merged.
  theuni:
    ACK 13601da17e

Tree-SHA512: 1450618714a456d8969fa5bfc3ed700452e0737213af50656a0a1e0764e6063390fb528eb1889d8bf1e02e451f601f0a5bc63a02ac34ef10aeb7dc80fe41acd1
2022-10-04 10:20:26 +01:00
glozow
cda6c79190
Merge bitcoin/bitcoin#26203: wallet: Use correct effective value when checking target
d0d9cf7aea test: Check external coin effective value is used in CoinSelection (Aurèle Oulès)
76b79c1a17 wallet: Use correct effective value when checking target (Aurèle Oulès)

Pull request description:

  Fixes #26185. The following assert failed because it was not checked in the parent function.

  2bd9aa5a44/src/wallet/coinselection.cpp (L391)

ACKs for top commit:
  glozow:
    reACK d0d9cf7aea
  furszy:
    ACK d0d9cf7a

Tree-SHA512: e126daba1115e9d143f2a582c6953e7ea55e96853b6e819c7744fd7a23668f7d9854681d43ef55d8774655bc54e7e87c1c9fccd746d9e30fbf3caa82ef808ae9
2022-10-04 09:57:17 +01:00
fanquake
4bee62e9b8
kernel: remove util/bytevectorhash.cpp 2022-10-03 18:49:07 +01:00
fanquake
1730f6cb23
Merge bitcoin/bitcoin#26189: refactor: Do not discard try_lock() return value
30cc1c6609 refactor: Drop `owns_lock()` call (Hennadii Stepanov)
bff4e068b6 refactor: Do not discard `try_lock()` return value (Hennadii Stepanov)

Pull request description:

  Microsoft's C++ Standard Library uses the `[[nodiscard]]` attribute for `try_lock()`.
  See: https://github.com/microsoft/STL/blob/main/stl/inc/mutex

  This change allows to drop the current suppression for the warning C4838 and helps to prevent the upcoming warning C4858.
  See: 539c26c923

  Fixes bitcoin/bitcoin#26017.

  Split from bitcoin/bitcoin#25819.

ACKs for top commit:
  vasild:
    ACK 30cc1c6609

Tree-SHA512: ce17404e1c78af4f763129753caf8e5a0e1c91ba398778fe912f9fcc56a847e8112460d1a1a35bf905a593b7d8e0b16c6b099ad74976b67dca5f4f3eda6ff621
2022-10-03 18:21:35 +01:00
fanquake
7d14577d0f
refactor: move DEFAULT_BLOCKFILTERINDEX from val to blockfilterindex 2022-10-03 18:19:40 +01:00
fanquake
c87d569189
refactor: move DEFAULT_COINSTATSINDEX from validation to coinstatsindex 2022-10-03 18:19:39 +01:00
fanquake
2bfc1e6aaa
refactor: move DEFAULT_TXINDEX from validation to txindex 2022-10-03 18:19:39 +01:00
fanquake
b92b12e8f3
Merge bitcoin/bitcoin#25735: net: remove useless call to IsReachable() from CConnman::Bind()
9cbfe40d8a net: remove useless call to IsReachable() from CConnman::Bind() (Vasil Dimov)

Pull request description:

  `CConnman::Bind()` is called without `BF_EXPLICIT` only when passed
  either `0.0.0.0` or `::`. For those addresses `IsReachable()` is always
  true (regardless of the `-onlynet=` setting!), meaning that the `if`
  condition never evaluates to true.

  `IsReachable()` is always true for the "any" IPv4 and IPv6 addresses
  because `CNetAddr::GetNetwork()` returns `NET_UNROUTABLE` instead of
  `NET_IPV4` or `NET_IPV6` and the network `NET_UNROUTABLE` is always
  considered reachable.

  It follows that `BF_EXPLICIT` is unnecessary, remove it too.

ACKs for top commit:
  naumenkogs:
    ACK 9cbfe40d8a
  aureleoules:
    ACK 9cbfe40d8a
  mzumsande:
    ACK 9cbfe40d8a

Tree-SHA512: 4e53ee8a73ddd133fd4ff25635135b65e5c19d1fc56fe5c30337406560664616c0adff414dca47602948919f34c81073aae6bfc2871509f3912663d86750928e
2022-10-03 18:16:10 +01:00
Hennadii Stepanov
30cc1c6609
refactor: Drop owns_lock() call
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2022-10-03 12:26:37 +01:00
fanquake
c21b32ccd1
Merge bitcoin/bitcoin#26198: refactor: move Boost Datetime usage to wallet
079cf88c0d refactor: move Boost datetime usage to wallet (fanquake)

Pull request description:

  This means we don't need Boost Datetime in a `--disable-wallet` build, and it isn't included in the kernel (via time.h/cpp). Split from a larger boost removal branch/effort.

ACKs for top commit:
  hebasto:
    re-ACK 079cf88c0d
  aureleoules:
    re-ACK 079cf88c0d - rebased and two additional unit tests since my last review.
  jarolrod:
    crACK 079cf88c0d

Tree-SHA512: c84f47158a4f21902f211c059d8c4bd55ffe95a256835deee723653be08cca49eeddfc33a2316b0cd31805e81cf77eaa39c6c9dcff4cda11a26ba4c1c143974e
2022-10-03 11:13:12 +01:00
Hennadii Stepanov
5c9a27a46f
test: Use proper Boost macros instead of assertions 2022-10-03 00:00:31 +01:00
fanquake
93001b16a4
Merge bitcoin/bitcoin#26216: fuzz: Limit outpoints.size in txorphan target to avoid OOM
fa5752da6a fuzz: Limit outpoints.size in txorphan target to avoid OOM (MacroFake)

Pull request description:

  Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52008

ACKs for top commit:
  fanquake:
    ACK fa5752da6a

Tree-SHA512: f010c0eabb72ad4bbf428954f6f978e88d6d15ec3ee77536334b11c0ca605377bdaa40ecf1984f027a430d62f05e9201775f5a6b047ffa38563aeefc04958a1f
2022-10-02 16:37:40 +01:00
Aurèle Oulès
d0d9cf7aea
test: Check external coin effective value is used in CoinSelection 2022-10-02 01:34:45 +02:00
Aurèle Oulès
76b79c1a17
wallet: Use correct effective value when checking target 2022-10-02 01:34:25 +02:00
fanquake
079cf88c0d
refactor: move Boost datetime usage to wallet
This means we don't need datetime in a --disable-wallet build, and it
isn't included in the kernel.
2022-10-01 11:41:53 +01:00
MacroFake
fa5752da6a
fuzz: Limit outpoints.size in txorphan target to avoid OOM 2022-09-30 16:52:01 +02:00
MacroFake
f59e91511a
Merge bitcoin/bitcoin#26131: log: log RPC port on startup
9d14f27bdd log: log RPC port on startup (James O'Beirne)

Pull request description:

  I just spent a few hours trying to figure out why "18444" wasn't getting me to regtest's RPC server. I'm not the sharpest tool in the shed, but I was maybe understandably confused because "Bound to 127.0.0.1:18445" appears in the logs, which I assumed was the P2P port.

  This change logs the RPC listening address by default on startup, which seems like a basic piece of information that shouldn't be buried under `-debug`.

ACKs for top commit:
  dergoegge:
    ACK 9d14f27bdd
  jarolrod:
    ACK 9d14f27bdd
  aureleoules:
    ACK 9d14f27bdd

Tree-SHA512: 5c86f018c0b8d6264abf878c921afe53033b23ab4cf289276bb1ed28fdf591c9d8871a4baa4098c363cb2aa9a637d2e4e18e56b14dfc7d767ee40757d7ff2e7c
2022-09-30 16:29:22 +02:00
stickies-v
b01682a812
refactor: revert m_next_resend to not be std::atomic
Since m_next_resend is now only called from MaybeResendWalletTxs()
we don't have any potential race conditions anymore, so the usage
of std::atomic can be reverted.
2022-09-30 14:47:39 +01:00
stickies-v
9245f45670
wallet: only update m_next_resend when actually resending
We only want to relay our resubmitted transactions once every 12-36h.
By separating the timer update logic out of ResubmitWalletTransactions
and into MaybeResendWalletTxs we avoid non-relay calls (previously in
the separate ReacceptWalletTransactions function) from resetting that
timer.
2022-09-30 14:47:39 +01:00
stickies-v
7fbde8af5c
refactor: carve out tx resend timer logic into ShouldResend
Moves the logic of whether or not transactions should actually be
resent out of the function that's resending them. This reduces
responsibilities of ResubmitWalletTransactions and allows
carving out the updating of m_next_resend in a future commit.
2022-09-30 14:47:38 +01:00
MacroFake
33eef562a3
Merge bitcoin/bitcoin#26074: refactor: Set RPCArg options with designated initializers
fa2c72dda0 rpc: Set RPCArg options with designated initializers (MacroFake)

Pull request description:

  For optional constructor arguments, use a new struct. This comes with two benefits:
  * Earlier unused optional arguments can be omitted
  * Designated initializers can be used

ACKs for top commit:
  stickies-v:
    re-ACK fa2c72dda0

Tree-SHA512: 2a0619548187cc7437fee2466ac4780746490622f202659f53641be01bc2a1fea4416d1a77f3e963bf7c4cce62899b61fab0b9683440cf82f68be44f63826658
2022-09-30 10:06:14 +02:00
stickies-v
01f3534632
refactor: remove unused locks for ResubmitWalletTransactions
ReacceptWalletTransactions is replaced by ResubmitWalletTransactions
which already handles acquiring the necessary locks internally.
2022-09-29 17:32:53 +01:00
stickies-v
c6e8e11fb0
wallet: fix capitalization in docstring 2022-09-29 17:32:52 +01:00
fanquake
13601da17e
Update leveldb-subtree subtree to latest upstream 2022-09-29 16:43:30 +01:00
furszy
f1593780b8
bench: place benchmark implementation inside benchmark namespace 2022-09-28 13:27:51 -03:00
Hennadii Stepanov
b147322a7a
Use PACKAGE_NAME in messages rather than hardcoding "Bitcoin Core" 2022-09-27 23:04:37 +01:00
Hennadii Stepanov
bff4e068b6
refactor: Do not discard try_lock() return value
Microsoft's C++ Standard Library uses the `[[nodiscard]]` attribute for
`try_lock()`.
See: https://github.com/microsoft/STL/blob/main/stl/inc/mutex

This change allows to drop the current suppression for the warning C4838
and helps to prevent the upcoming warning C4858.
See: 539c26c923
2022-09-27 22:35:16 +01:00
glozow
9fcdb9f3a0
Merge bitcoin/bitcoin#26172: p2p: ProcessHeadersMessage(): fix received_new_header
bdcafb9133 p2p: ProcessHeadersMessage(): fix received_new_header (Larry Ruane)

Pull request description:

  Follow-up to #25717. The commit "Utilize anti-DoS headers download strategy" changed how this bool variable is computed, so that its value is now the opposite of what it should be.

  Prior to #25717:
  ```
  bool received_new_header{WITH_LOCK(::cs_main, return m_chainman.m_blockman.LookupBlockIndex(headers.back().GetHash()) == nullptr)};
  ```
  After #25717 (simplified):
  ```
  {
      LOCK(cs_main);
      last_received_header = m_chainman.m_blockman.LookupBlockIndex(headers.back().GetHash());
  }
  bool received_new_header{last_received_header != nullptr};
  ```

ACKs for top commit:
  dergoegge:
    ACK bdcafb9133
  glozow:
    ACK bdcafb9133, I believe this is correct and don't see anything to suggest the switch was intentional.
  stickies-v:
    ACK bdcafb9133

Tree-SHA512: 35c12762f1429585a0b1c15053e310e83efb28c3d8cbf4092fad9fe81c893f6d766df1f2b20624882acb9654d0539a0c871f587d7090dc2a198115adf59db3ec
2022-09-27 11:02:44 +01:00
MacroFake
eeac05aa22
Merge bitcoin/bitcoin#26156: test: check that listdescriptors descriptor strings are sorted
810c3dc7ef doc, rpc: mention that `listdescriptors` result is sorted by string representation (Sebastian Falbesoner)
d99af861d0 test: check that `listdescriptors` descriptor strings are sorted (Sebastian Falbesoner)

Pull request description:

  This small PR adds a test for the change introduced in PR #25931 ("rpc: sort listdescriptors result", commit 50996241f2). The correctness of the test can easily be verified by commenting out the `std::sort` call in the `listdescriptors` RPC implementation:
  ```diff
  diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
  index 09c74ea2da..3ed1a69b26 100644
  --- a/src/wallet/rpc/backup.cpp
  +++ b/src/wallet/rpc/backup.cpp
  @@ -1829,9 +1829,11 @@ RPCHelpMan listdescriptors()
           });
       }

  +    /*
       std::sort(wallet_descriptors.begin(), wallet_descriptors.end(), [](const auto& a, const auto& b) {
           return a.descriptor < b.descriptor;
       });
  +    */

       UniValue descriptors(UniValue::VARR);
       for (const WalletDescInfo& info : wallet_descriptors) {

  ```
  leading to a fail of the functional test `wallet_listdescriptors.py`.

ACKs for top commit:
  jarolrod:
    ACK 810c3dc7ef
  aureleoules:
    ACK 810c3dc7ef

Tree-SHA512: 31770e3149b8a0251ecfa8662a2270c149f778eb910985f48a91d6a5d288b7b1c2244f9f1b798ebe3f1aa9f0b935cb4d6f12d5d28f78bcde3c4a61af76d11d0a
2022-09-27 09:27:00 +00:00
Sebastian Falbesoner
810c3dc7ef doc, rpc: mention that listdescriptors result is sorted by string representation 2022-09-26 15:16:01 +02:00
Hennadii Stepanov
f09d47b263
bench: Add missed ECCVerifyHandle instance 2022-09-26 11:03:36 +01:00
MacroFake
ec13810a00
Merge bitcoin/bitcoin#26159: build: Remove stdlib.h from header checks
553ff452c0 build: remove stdlib.h from header checks (fanquake)
a63d4cb26a refactor: use <cstdlib> over stdlib.h (fanquake)

Pull request description:

  We already use a mix of `<cstlib>` and `stdlib.h` unconditionally throughout
  the codebase.

  Us checking this header also duplicates work already done by autotools.
  Currently stdlib.h is checked for 3 times during a ./configure run, after
  this change, at least it's only twice.

  Similar to #26150.

ACKs for top commit:
  kristapsk:
    ACK 553ff452c0
  TheCharlatan:
    ACK 553ff452c0

Tree-SHA512: 0a43d39d3df180a1614dbd3a1ee1531b0969ffe4a0c09dfe9d2f3f0ec16196b5fd7523309f6722936a8c8b20908508724e1903e939dd81c3b4538d85d0f42953
2022-09-25 11:45:41 +00:00
MacroFake
0cfbb171bd
Merge bitcoin/bitcoin#26130: Bugfix: Wallet: Lock cs_wallet for SignMessage
a60d9eb9e6 Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)

Pull request description:

  cs_desc_main is typically locked within scope of a cs_wallet lock, but:

  CWallet::IsLocked locks cs_wallet
  ...called from DescriptorScriptPubKeyMan::GetKeys
  ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

  Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first

  -------------

  Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by #26082 (CI fails as a result)

ACKs for top commit:
  achow101:
    ACK a60d9eb9e6
  w0xlt:
    ACK a60d9eb9e6

Tree-SHA512: 60f6959b0ceaf4d9339ba1a47154734034b637c41b1f9e26748a2dbbc3a2a95fc3696019103c55ae70c91d910ba8f3d7f4e27d263030eb60b689f290c4d82ea9
2022-09-24 14:02:13 +00:00
Larry Ruane
bdcafb9133 p2p: ProcessHeadersMessage(): fix received_new_header
Follow-up to #25717. The commit "Utilize anti-DoS headers download
strategy" changed how this bool variable is computed, so that its value
is now the opposite of what it should be.
2022-09-24 00:07:46 -06:00
fanquake
a63d4cb26a
refactor: use <cstdlib> over stdlib.h
We currently use both. Consolidate on the former.
2022-09-23 10:48:47 +01:00
Jon Atack
a3789c700b Improve getpeerinfo pingtime, minping, and pingwait help docs 2022-09-22 16:45:48 +02:00
Jon Atack
df660ddb1c Update getpeerinfo/-netinfo/TxRelay#m_relay_txs relaytxes docs (for v24 backport)
to the current p2p behavior.  We only initialize the Peer::TxRelay m_relay_txs
data structure if it isn't an outbound block-relay-only connection and fRelay=true
(the peer wishes to receive tx announcements) or we're offering NODE_BLOOM to this peer.
2022-09-22 16:45:32 +02:00
Jon Atack
1f448542e7 Always return getpeerinfo "minfeefilter" field (for v24 backport)
with its pre-existing v23 default value of 0.
2022-09-22 16:45:20 +02:00
Jon Atack
9cd6682545 Make getpeerinfo field order consistent with its help (for v24 backport)
This also keeps it consistent with the last release (v23)
2022-09-22 16:44:38 +02:00
fanquake
100949af0e
Merge bitcoin/bitcoin#26012: fuzz: Avoid timeout in bitdeque fuzz target
fa4ba04c15 fuzz: Remove no-op call to get() (MacroFake)
fa642286b8 fuzz: Avoid timeout in bitdeque fuzz target (MacroFake)

Pull request description:

  I'd guess that any bug should be discoverable within `10` ops. However, `900` seems also better than no limit at all, which causes timeouts such as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50892

ACKs for top commit:
  sipa:
    ACK fa4ba04c15

Tree-SHA512: f6bd25e78d5f04c6f88e9300c2fa3d0993a0911cb0fd1b414077adc0edde1a06ad72af5e2f50f0ab1324f91999ae57d879686c545b2e6c19ae7f637a8804bd48
2022-09-22 14:55:43 +01:00
fanquake
590d206444
Merge bitcoin/bitcoin#26150: build: remove stdio.h from header checks
55aad5f3a9 build: remove stdio.h from header checks (fanquake)
b95633121b refactor: use <cstdio> over stdio.h (fanquake)

Pull request description:

  We already use a mix of `<cstdio>` and `stdio.h` unconditionally throughout
  the codebase.

  Us checking this header also duplicates work already done by autotools.
  Currently `stdio.h` is checked for 3 times during a ./configure run, after
  this change, at least it's only twice.

ACKs for top commit:
  TheCharlatan:
    ACK 55aad5f3a9
  kristapsk:
    ACK 55aad5f3a9

Tree-SHA512: a83cc724528ab92aacfa53048b12fcccec3962637ca7fad30f6c610365edeb0e951f74e37832ad7d3f79ca9b8d7203cb10165c89d0e4b63eeda7a970dab82dfb
2022-09-22 14:45:13 +01:00
Andrew Chow
2b2c970627
Merge bitcoin/bitcoin#26149: Fix assert failure in miniscript string parsing
648f6950cd Correct sanity-checking script_size calculation (Pieter Wuille)

Pull request description:

  Fix a bug in the script_size sanity-check in the miniscript string parser, found by oss-fuzz in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51636, and introduced in e8cc2e4afc (#25540).

  This bug would cause an assertion failure when feeding a miniscript with a `thresh(k,...)` fragment, with k >= 128, to an RPC.

ACKs for top commit:
  darosior:
    utACK 648f6950cd
  achow101:
    ACK 648f6950cd

Tree-SHA512: d86a0721758cd1e42ef02050b542f0935efdc19447a1ca76a3ade96352a6ee8261eef3d4a5cbdec77bf0ad14dfed42e9eb6bd4246b816a9f6f06d786900da9e7
2022-09-21 13:17:07 -04:00
fanquake
b95633121b
refactor: use <cstdio> over stdio.h
We currently use both. Consolidate on the former.
2022-09-21 16:53:11 +01:00
Andrew Chow
25cd47de71
Merge bitcoin/bitcoin#25933: wallet: AvailableCoins, simplify output script type acquisition
58b7df3caa wallet: AvailableCoins, simplify output script type acquisition (furszy)

Pull request description:

  There is an unnecessary `ExtractDestination()` call and subsequent result parse into an `CScriptID`.

  The `Solver()` call, which we are already doing below anyway, retrieves the script type and, in the P2SH case, the program id.

ACKs for top commit:
  achow101:
    ACK 58b7df3caa
  aureleoules:
    re-ACK 58b7df3caa
  rajarshimaitra:
    ACK 58b7df3caa
  w0xlt:
    ACK 58b7df3caa

Tree-SHA512: 51080766877c34cb2232ee3a1cb6b6a62b829c9297c67b99577742b94854a737a74d248015a4603ca9b6cd0a3c9e1d6d78673ff3cc9fc65dd82deea72dc537fd
2022-09-21 11:27:37 -04:00
Pieter Wuille
648f6950cd Correct sanity-checking script_size calculation 2022-09-21 09:17:45 -04:00
fanquake
80d1598133
Merge bitcoin/bitcoin#26099: build: remove duplicate / unneeded libs from bench_bitcoin
ff7c81f63a build: remove duplicate / unneeded libs from bench_bitcoin (fanquake)

Pull request description:

  EVENT_*_LIBS are already in LDADD.
  Move wallet libs into the wallet conditional, similar to zmq.

ACKs for top commit:
  theuni:
    ACK ff7c81f63a

Tree-SHA512: 6bd92f03478d56cd38645e38c0e6c4614cdf9c745124069d0d1d80483d76f5c656e1749061455ba04c619684513a063dda3f8f4bd09fe7b66911714d83592f25
2022-09-21 11:25:47 +01:00
fanquake
b1f44ecdcd
Merge bitcoin/bitcoin#25737: rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR
e68d380797 rpc: remove unneeded RPCTypeCheckArgument checks (furszy)
55566630c6 rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR (furszy)

Pull request description:

  Same rationale as #26039, tackling another angle of the problem.

  #### Context
  We have the same univalue type error checking code spread/duplicated few times:
  `RPCTypeCheckObj`, `RPCTypeCheckArgument`, `UniValue::checkType`.

  In the first two functions, we are properly returning an `RPC_TYPE_ERROR` while in `UniValue::checkType`
  we are throwing an `std::runtime_error` which is caught by the RPC server request handler, who invalidly
  treats it as `RPC_MISC_ERROR` (which is a generic error return code that provides no information to the user).

  #### Proposed Changes

  Throw a custom exception from `Univalue::checkType` (instead of a plain
  `std::runtime_error`) and catch it on the RPC server request handler.

  So we properly return `RPC_TYPE_ERROR` (-3) on every arg type error and
  not the general `RPC_MISC_ERROR` (-1).

  This will allow us to remove all the `RPCTypeCheckArgument` calls. As them are redundant since #25629.

Top commit has no ACKs.

Tree-SHA512: 4e4c41851fd4e2b01a2d8b94e71513f9831f810768ebd89684caca4901e87d3677980003949bcce441f9ca607a1b38a5894839b6c492f5947b8bab8cd9423ba6
2022-09-21 11:19:44 +01:00
fanquake
97f865bb76
Merge bitcoin/bitcoin#25989: init: abort if i2p/cjdns are chosen via -onlynet but are unreachable
68209a7b5c rpc: make addpeeraddress work with cjdns addresses (Martin Zumsande)
a8a9ed67cc init: Abort if i2p/cjdns are chosen via -onlynet but unreachable (Martin Zumsande)

Pull request description:

  If the networks i2p / cjdns are chosen via `-onlynet` but the user forgot to provide `-i2psam` / `-cjdnsreachable`, no outbound connections will be made - it would be nice to inform the user about that.
  The solution proposed here mimics existing behavior for `-onlynet=onion` and non-specified `-onion`/`-proxy` where we already abort with an InitError - if reviewers would prefer to just print a warning, please say so.

  The second commit adds CJDNS support to the debug-only `addpeeraddress` RPC allowing to add CJDNS addresses to addrman for testing and debug purposes. (if `-cjdnsreachable=1`)

  This is the result of an [IRC discussion](https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2022-09-01#848066;) with vasild.

ACKs for top commit:
  vasild:
    ACK 68209a7b5c
  dergoegge:
    ACK 68209a7b5c

Tree-SHA512: 6db9787f01820190f14f90a0b39e4206603421eb7521f792879094d8bbf4d4d0bfd70665eadcc40994ac7941a15ab5a8d65c4779fba5634c0e6fa66eb0972b8d
2022-09-21 11:00:47 +01:00
Andrew Chow
9e2a2b88d5
Merge bitcoin/bitcoin#26132: wallet: Fix nNextResend data race in ResubmitWalletTransactions
fad61573ed Fix nNextResend data race in ResubmitWalletTransactions (MacroFake)

Pull request description:

  Now that `ResubmitWalletTransactions` is called from more than one thread, it is no longer thread-safe.

  Introduced in 5291933fed.

ACKs for top commit:
  achow101:
    ACK fad61573ed
  jonatack:
    ACK fad61573ed
  stickies-v:
    However, I think the current data race UB fix in fad61573e is the most critical to get into v24, so: ACK fad61573e - but open to further improvements.

Tree-SHA512: 54da2ed1c5f44e33588ac1d21ce26908fcf0bfe785c28ba8f6a479389b5ab7a0b32b016d4c482a2ccb405e0686efb61ffe23e427f5e589dc7d2b3c7469978977
2022-09-20 18:48:06 -04:00
Andrew Chow
fc4017552c
Merge bitcoin/bitcoin#26116: rpc: Allow importmulti watchonly imports with locked wallet
2c03465dfa test: Test watchonly imports with passphrase-locked wallet (Aurèle Oulès)
1fcf9e6e81 rpc: Allow importmulti watchonly imports with locked wallet (Aurèle Oulès)

Pull request description:

  Allows watch-only imports on locked wallets with `importmulti`.
  Also adds a test.

  Fixes #17867.

ACKs for top commit:
  achow101:
    ACK 2c03465dfa
  kristapsk:
    re-ACK 2c03465dfa
  theStack:
    re-ACK 2c03465dfa

Tree-SHA512: 9978d6e59a230c0d160efd312c671cf59458797387d6622b6bf5c9e0681c1fcfebedb3d834fa9314dc5a1eda97e3295696352eacbeab9b43a46b942990087035
2022-09-20 12:00:02 -04:00
fanquake
5b6f0f31fa
Merge bitcoin/bitcoin#26036: net: add NetEventsInterface::g_msgproc_mutex
d575a675cc net_processing: add thread safety annotation for m_highest_fast_announce (Anthony Towns)
0ae7987f68 net_processing: add thread safety annotations for PeerManagerImpl members accessed only via the msgproc thread (Anthony Towns)
a66a7ccb82 net_processing: add thread safety annotations for Peer members accessed only via the msgproc thread (Anthony Towns)
bf12abe454 net: drop cs_sendProcessing (Anthony Towns)
1e78f566d5 net: add NetEventsInterface::g_msgproc_mutex (Anthony Towns)

Pull request description:

  There are many cases where we assume message processing is single-threaded in order for how we access node-related memory to be safe. Add an explicit mutex that we can use to document this, which allows the compiler to catch any cases where we try to access that memory from other threads and break that assumption.

ACKs for top commit:
  MarcoFalke:
    review ACK d575a675cc 📽
  dergoegge:
    Code review ACK d575a675cc
  w0xlt:
    ACK d575a675cc
  vasild:
    ACK d575a675cc modulo the missing runtime checks

Tree-SHA512: b886d1aa4adf318ae64e32ccaf3d508dbb79d6eed3f1fa9d8b2ed96f3c72a3d38cd0f12e05826c9832a2a1302988adfd2b43ea9691aa844f37d8f5c37ff20e05
2022-09-20 14:18:23 +01:00
MacroFake
fad61573ed
Fix nNextResend data race in ResubmitWalletTransactions 2022-09-20 11:49:57 +02:00
MacroFake
71ac70d877
Merge bitcoin/bitcoin#26095: script: bump codespell to 2.2.1, update ignored words and fix spelling
b6a65568df Fix issues identified by codespell 2.2.1 and update ignored words (Jon Atack)
8f2010de6e Bump codespell version to 2.2.1 (Jon Atack)

Pull request description:

  as well as one in `test/lint/lint-locale-dependence.py` not seen by the spelling linter.

  Can be tested locally by running `test/lint/lint-spelling.py` on this branch versus on master and by checking the CI linter result.

ACKs for top commit:
  satsie:
    ACK b6a65568df

Tree-SHA512: ab4ba029a9a5de5926fa5d336bd3b21245acf0649c6aa69a48c223bd22327e13beb32e970f66f54db58cd318731b643e1c7ace9a89776ed2a069cddc02363b71
2022-09-20 11:22:22 +02:00
MacroFake
d76a423809
Merge bitcoin/bitcoin#26067: util: improve bitcoin-wallet exit codes
fa2b8ae0a2 util: improve bitcoin-wallet exit codes (MacroFake)

Pull request description:

  Refactors `bitcoin-wallet` so that it doesn't return a non-zero exit code by default, and makes the option handling more inline with the other binaries. i.e outputting `Error: too few parameters` if you don't pass any options.

  Fixing this means we can check the process output in `gen-manpages.py`; which addresses the remaining [review comment](https://github.com/bitcoin/bitcoin/pull/24263#discussion_r806126705) from #24263.

Top commit has no ACKs.

Tree-SHA512: 80bd8098faefb4401ca1e4d49937ef6c960cf60ce0e7fb9dc38904fbc2fd92e319ec04570381da84943b7477845bf6be00e977f4c0451b247a6698662ce8f1bf
2022-09-20 09:54:04 +02:00
James O'Beirne
9d14f27bdd log: log RPC port on startup
I just spent a few hours trying to figure out why "18444" wasn't getting
me to regtest's RPC server. I'm not the sharpest tool in the shed, but I
was maybe understandably confused because "Bound to
127.0.0.1:18445" appears in the logs, which I assumed was the P2P port.

This change logs the RPC listening address, which seems like a basic
piece of information that shouldn't be buried in debug logs.
2022-09-19 21:43:26 -04:00
Luke Dashjr
a60d9eb9e6 Bugfix: Wallet: Lock cs_wallet for SignMessage
cs_desc_main is typically locked within scope of a cs_wallet lock, but:

CWallet::IsLocked locks cs_wallet
...called from DescriptorScriptPubKeyMan::GetKeys
...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet
...called from DescriptorScriptPubKeyMan::SignMessage
...called from CWallet::SignMessage which can access and lock cs_wallet

Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first
2022-09-20 00:46:27 +00:00
MacroFake
9843a8c1f3
Merge bitcoin/bitcoin#26119: doc: Move -permitbaremultisig to the relay help category
faf5bb87da doc: Move -permitbaremultisig to the relay help category (MacroFake)

Pull request description:

  This transaction relay setting doesn't have anything to do with establishing p2p connections.

ACKs for top commit:
  glozow:
    concept ACK faf5bb87da
  luke-jr:
    utACK faf5bb87da, but (nit) prefer to keep it on a single line

Tree-SHA512: 436fcff5191c346fe16b3208411886e3239fb5819322673a45cf0c0f9a3070563d312da8bb5d5f6060b36d305e59e5b58928526d5042cb3dac29ce7740d17c1c
2022-09-19 18:12:34 +02:00
fanquake
9f650062fc
Merge bitcoin/bitcoin#26005: Wallet: Fix error handling (copy_file failure in RestoreWallet, and in general via interfaces)
c3e536555a Bugfix: Wallet: Return util::Error rather than non-error nullptr when CreateWallet/LoadWallet/RestoreWallet fail (Luke Dashjr)
335ff98c8a Bugfix: Wallet: Wrap RestoreWallet content in a try block to ensure exceptions become returned errors and incomplete wallet directory is removed (Luke Dashjr)

Pull request description:

  Bug 1: `copy_file` can throw exceptions, but `RestoreWallet` is expected to return a nullptr with a populated `errors` parameter. This is fixed by wrapping `copy_file` and `LoadWallet` (for good measure) in a `try` block, and converting any exceptions to the intended return style.

  Bug 2: `util::Result` turns what would have been a `false` unique_ptr into a `true` nullptr result, which leads to nullptr dereferences in at least the 3 cases of wallet creation/loading/restoring. This is fixed by keeping the pointer as a plain `std::unique_ptr` until actually returning it (ie, after the nullptr check).

  Fixes https://github.com/bitcoin-core/gui/issues/661

ACKs for top commit:
  achow101:
    ACK c3e536555a

Tree-SHA512: 4291b3dbbb147acea2e63a704324c9371bc16ecb4237f8753729b0b0a6e55c9758ad61bfe8bd432fd7b0bae95d8b63a9831e61ac8b8d5c0197b550a2e0f4a105
2022-09-19 16:10:47 +01:00
Martin Zumsande
68209a7b5c rpc: make addpeeraddress work with cjdns addresses
This allows us to add cjdns addresses to addrman for
testing and debug purposes (if -cjdnsreachable is true)
2022-09-19 11:06:43 -04:00
Martin Zumsande
a8a9ed67cc init: Abort if i2p/cjdns are chosen via -onlynet but unreachable
...because -i2psam or -cjdnsreachable are not provided.
This mimics existing behavior for -onlynet=onion and non-specified proxy.
2022-09-19 11:06:43 -04:00
MacroFake
faf5bb87da
doc: Move -permitbaremultisig to the relay help category 2022-09-19 14:09:34 +02:00
MacroFake
fabf1cdb20
Use steady clock for bench logging 2022-09-19 11:51:34 +02:00
MacroFake
faed342a23
scripted-diff: Rename time symbols
-BEGIN VERIFY SCRIPT-

 ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ':(exclude)src/versionbits.cpp') ; }

 ren nStart                 time_start
 ren nTimeStart             time_start
 ren nTimeReadFromDiskTotal time_read_from_disk_total
 ren nTimeConnectTotal      time_connect_total
 ren nTimeFlush             time_flush
 ren nTimeChainState        time_chainstate
 ren nTimePostConnect       time_post_connect
 ren nTimeCheck             time_check
 ren nTimeForks             time_forks
 ren nTimeConnect           time_connect
 ren nTimeVerify            time_verify
 ren nTimeUndo              time_undo
 ren nTimeIndex             time_index
 ren nTimeTotal             time_total
 ren nTime1                 time_1
 ren nTime2                 time_2
 ren nTime3                 time_3
 ren nTime4                 time_4
 ren nTime5                 time_5
 ren nTime6                 time_6

 ren nBlocksTotal num_blocks_total

 # Newline after semicolon
 perl -0777 -pi -e 's/; time_connect_total/;\n        time_connect_total/g' src/validation.cpp
 perl -0777 -pi -e 's/; time_/;\n    time_/g'                               src/validation.cpp

-END VERIFY SCRIPT-
2022-09-19 10:45:49 +02:00
Aurèle Oulès
1fcf9e6e81
rpc: Allow importmulti watchonly imports with locked wallet 2022-09-17 21:38:55 +02:00
furszy
58b7df3caa
wallet: AvailableCoins, simplify output script type acquisition 2022-09-17 10:29:30 -03:00
Pieter Wuille
e8cc2e4afc
Make miniscript string parsing account for exact script size as bound
Co-Authored-by: Antoine Poinsot <darosior@protonmail.com>
2022-09-17 15:12:48 +02:00
Pieter Wuille
4cb8f9a92c
Permit delaying duplicate key check in miniscript::Node construction 2022-09-17 10:47:05 +02:00
Luke Dashjr
c3e536555a Bugfix: Wallet: Return util::Error rather than non-error nullptr when CreateWallet/LoadWallet/RestoreWallet fail 2022-09-16 23:28:21 +00:00
Luke Dashjr
335ff98c8a Bugfix: Wallet: Wrap RestoreWallet content in a try block to ensure exceptions become returned errors and incomplete wallet directory is removed 2022-09-16 21:07:10 +00:00
fanquake
a688ff9046
Merge bitcoin/bitcoin#26087: build: prune BOOST_CPPFLAGS from libbitcoin_zmq
a10df7cf35 build: prune BOOST_CPPFLAGS from libbitcoin_zmq (fanquake)

Pull request description:

  Rather than including `validation.h`, which ultimately means needing boost via `txmempool.h`, include `primitives/block.h` for `CBlock`, and remove `validation.h`, as we can get `cs_main` from `node/blockstorage.h`.

ACKs for top commit:
  theuni:
    Nice. ACK a10df7cf35.
  hebasto:
    ACK a10df7cf35, tested on Linux x86_64 using theuni's [patch](e131d8f1e3) with depends.

Tree-SHA512: 792b6f9e7e7788d10333b4943609efbc798f3b187c324a0f2d5acbb2d44e3c67705dc54d698eb04c23e5af7b8b73a47f8e7974e819eac12f12ae62f28c807476
2022-09-16 14:53:53 +01:00
fanquake
3d892d8695
Merge bitcoin/bitcoin#26086: build: remove BOOST_CPPFLAGS usage from bitcoin-tx
f839697d9b build: remove BOOST_CPPFLAGS usage from bitcoin-tx (fanquake)

Pull request description:

  The only reason `BOOST_CPPFLAGS` was needed here, is because of the `policy/rbf.h` include, which ultimately includes boost multi_index via `txmempool.h`. However this include is unused.

ACKs for top commit:
  theuni:
    Nice. ACK f839697d9b.
  hebasto:
    ACK f839697d9b, tested on Linux x86_64 using theuni's [patch](e131d8f1e3) with depends.

Tree-SHA512: ec93f4045d927789d70e2a96a6869c0df63891483bb61361327bfefafaabc2925f63382aa3d9302963df2306bc035edad4cabd5eeb315db6603266e677be7cd3
2022-09-16 12:12:14 +01:00
MacroFake
5eb9781763
Merge bitcoin/bitcoin#25971: refactor: Use std::string for thread and index names
26cf9ea8e4 scripted-diff: rename pszThread to thread_name (stickies-v)
200d84d568 refactor: use std::string for index names (stickies-v)
97f5b20c12 refactor: use std::string for thread names (stickies-v)

Pull request description:

  As a follow-up to https://github.com/bitcoin/bitcoin/pull/25967#discussion_r959637189, this PR changes the return type of [`BaseIndex::GetName()`](fa5c224d44/src/index/base.h (L120)) to `const std::string&` instead of `const char*`. The first commit is not essential for this change, but since the code is touched and index names are commonly used to specify thread names, I've made the same update there.

  No behaviour change, just refactoring to further phase out C-style strings.

  Note: `util::ThreadRename()` used to take an rvalue ref, but since it then passes this to `SetInternalName()` by value, I don't think there's any benefit to having both an rvalue and lvalue ref function so I just changed it into lvalue ref. Not 100% sure I'm missing something?

ACKs for top commit:
  MarcoFalke:
    review ACK 26cf9ea8e4 only change is new scripted-diff 😀
  hebasto:
    ACK 26cf9ea8e4, I have reviewed the code and it looks OK.
  w0xlt:
    reACK 26cf9ea8e4

Tree-SHA512: 44a03ebf2bb86ca1411a36222a575217cdba8ee3a3c985e74d74c934516f002b27336147fa22f59eda7dac21204a93951563317005d475da95b23c427014d77b
2022-09-16 12:39:39 +02:00
fanquake
08785aa75b
Merge bitcoin/bitcoin#25499: Use steady clock for all millis bench logging
fa521c9603 Use steady clock for all millis bench logging (MacroFake)

Pull request description:

  Currently `GetTimeMillis` is used for bench logging in milliseconds integral precision. Replace it to use a steady clock that is type-safe and steady.

  Microsecond or float precision can be done in a follow-up.

ACKs for top commit:
  fanquake:
    ACK fa521c9603 - started making the same change.

Tree-SHA512: 86a810e496fc663f815acb8771a6c770331593715cde85370226685bc50c13e8e987e3c5efd0b4e48b36ebd2372255357b709204bac750d41e94a9f7d9897fa6
2022-09-16 11:10:15 +01:00
fanquake
2530a24689
Merge bitcoin/bitcoin#26105: Use ReadLE64 in uint256::GetUint64 instead of duplicating logic
04fee75bac Use ReadLE64 in uint256::GetUint64() instead of duplicating logic (Pieter Wuille)

Pull request description:

  No need to have a (naive) copy of the `ReadLE64` logic inside `uint256::GetUint64`, when we have an optimized function for exactly that.

ACKs for top commit:
  davidgumberg:
    ACK 04fee75bac
  jonatack:
    ACK 04fee75bac review, this use of ReadLE64() is similar to the existing invocation by Num3072::Num3072(), sanity checked that before and after this change GetUint64() returns the same result (debug build, clang 13)

Tree-SHA512: 0fc2681536a18d82408411bcc6d5c6445fb96793fa43ff4021cd2933d46514c725318da35884f428d1799023921f33f8af091ef428ceb96a50866ac53a345356
2022-09-16 10:32:23 +01:00
fanquake
19526d937f
Merge bitcoin/bitcoin#26065: i2p: use the same destination type for transient and persistent addresses
8b2891a6d1 i2p: use the same destination type for transient and persistent addresses (Vasil Dimov)

Pull request description:

  We generate our persistent I2P address with type `EdDSA_SHA512_Ed25519` (`DEST GENERATE SIGNATURE_TYPE=7`).

  Use the same type for our transient addresses which are created by the `SESSION CREATE ...` command. If not specified, then the default one is `DSA_SHA1` according to https://geti2p.net/en/docs/api/samv3.

  Fixes https://github.com/bitcoin/bitcoin/issues/26062

ACKs for top commit:
  mzumsande:
    ACK 8b2891a6d1
  sipa:
    utACK 8b2891a6d10f4a3875010d2e8eafd78bcf378952; didn't test but verified this matches the documentation

Tree-SHA512: 1b10e7e1e274b77609d08ee9cf9d73fef8c975c51aec452ce23e15fcf41709398c697087bfdece121b1fd26bc0501fc45857a91aaab679cadd0cbb37dd94c3a7
2022-09-16 09:13:49 +01:00
Pieter Wuille
04fee75bac Use ReadLE64 in uint256::GetUint64() instead of duplicating logic 2022-09-15 16:48:50 -04:00
Andrew Chow
a56876e6b9
Merge bitcoin/bitcoin#26024: wallet: fix sendall creates tx that fails tx-size check
cc434cbf58 wallet: fix sendall creates tx that fails tx-size check (kouloumos)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/26011

  The `sendall` RPC doesn't use `CreateTransactionInternal` as the rest of
  the wallet RPCs. [This has already been discussed in the original PR](https://github.com/bitcoin/bitcoin/pull/24118#issuecomment-1029462114).
  By not going through that path, it never checks the transaction's weight
  against the maximum tx weight for transactions we're willing to relay.
  447f50e4ae/src/wallet/spend.cpp (L1013-L1018)
  This PR adds a check for tx-size as well as test coverage for that case.

  _Note: It seems that the test takes a bit of time on slower machines,
  I'm not sure if dropping it might be for the better._

ACKs for top commit:
  glozow:
    re ACK cc434cb via range-diff. Changes were addressing https://github.com/bitcoin/bitcoin/pull/26024#discussion_r971325299 and https://github.com/bitcoin/bitcoin/pull/26024#discussion_r970651614.
  achow101:
    ACK cc434cbf58
  w0xlt:
    reACK cc434cbf58

Tree-SHA512: 64a1d8f2c737b39f3ccee90689eda1dd9c1b65f11b2c7bc0ec8bfe72f0202ce90ab4033bb0ecfc6080af8c947575059588a00938fe48e7fd553f7fb5ee03b3cc
2022-09-15 13:26:22 -04:00
Andrew Chow
96f1b2d34f
Merge bitcoin/bitcoin#26091: test: Fix syncwithvalidationinterfacequeue calls
fa1ce96184 test: Add missing syncwithvalidationinterfacequeue (MacroFake)
faa4916529 test/doc: Remove unused syncwithvalidationinterfacequeue (MacroFake)

Pull request description:

  Fixes #26071

ACKs for top commit:
  achow101:
    ACK fa1ce96184
  glozow:
    ACK fa1ce96184
  w0xlt:
    ACK fa1ce96184

Tree-SHA512: d1e101b55477360ead2b99ade5d42b922aabe293ec84fb26764e29161c5be6c534aef6f22d2cc5ea63a4bd6b6e77b701f1a7a2283b8e7e815d343a604cd77656
2022-09-15 13:17:43 -04:00
fanquake
f332c4f64d
Merge bitcoin/bitcoin#26090: fs: fully initialize _OVERLAPPED for win32
02c9e56468 fs: fully initialize _OVERLAPPED for win32 (Cory Fields)

Pull request description:

  ```bash
  fs.cpp: In member function ‘bool fsbridge::FileLock::TryLock()’:
  fs.cpp:129:32: error: missing initializer for member ‘_OVERLAPPED::InternalHigh’ [-Werror=missing-field-initializers]
    129 |     _OVERLAPPED overlapped = {0};
        |                                ^
  fs.cpp:129:32: error: missing initializer for member ‘_OVERLAPPED::<anonymous>’ [-Werror=missing-field-initializers]
  fs.cpp:129:32: error: missing initializer for member ‘_OVERLAPPED::hEvent’ [-Werror=missing-field-initializers]
  ```

  Came up in #25972. That PR is now rebased on this change.

  Closes: #26006

ACKs for top commit:
  sipsorcery:
    tACK 02c9e56468.
  hebasto:
    ACK 02c9e56468, tested on Linux x86_64:

Tree-SHA512: 6a0495c34bd952b2bb8c994a1450da7d3eee61225bb4ff0ce009c013f5e29dba94bb1c3ecef9989dc18c939909fdc8eba690a38f96da431ae9d64c23656de7d0
2022-09-15 15:32:29 +01:00
furszy
e68d380797
rpc: remove unneeded RPCTypeCheckArgument checks
No-behavior change.

Since #25629, we check the univalue type internally.
2022-09-15 10:45:18 -03:00
furszy
55566630c6
rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERROR
By throwing a custom exception from `Univalue::checkType` (instead of a plain
std::runtime_error) and catching it on the RPC server request handler.

So we properly return RPC_TYPE_ERROR (-3) on arg type errors and
not the general RPC_MISC_ERROR (-1).
2022-09-15 10:24:53 -03:00
Jon Atack
b6a65568df Fix issues identified by codespell 2.2.1 and update ignored words
and also fix spelling in test/lint/lint-locale-dependence.py not caught by the
spelling linter and fix up a paragraph we are touching here in test/README.md.
2022-09-15 13:03:40 +02:00
Anthony Towns
d575a675cc net_processing: add thread safety annotation for m_highest_fast_announce 2022-09-15 20:28:55 +10:00
Anthony Towns
0ae7987f68 net_processing: add thread safety annotations for PeerManagerImpl members accessed only via the msgproc thread 2022-09-15 20:28:55 +10:00
Anthony Towns
a66a7ccb82 net_processing: add thread safety annotations for Peer members accessed only via the msgproc thread 2022-09-15 20:28:55 +10:00
kouloumos
cc434cbf58 wallet: fix sendall creates tx that fails tx-size check
The `sendall` RPC doesn't use `CreateTransactionInternal`as the rest of
the wallet RPCs and it never checks against the tx-size mempool limit.
Add a check for tx-size as well as test coverage for that case.
2022-09-15 13:22:19 +03:00
fanquake
ff7c81f63a
build: remove duplicate / unneeded libs from bench_bitcoin
EVENT_*_LIBS are already in LDADD.
Move wallet libs into the wallet conditional, similar to zmq.
2022-09-15 10:29:12 +01:00
fanquake
4b656b9ed3
build: remove unused libevent cppflags 2022-09-15 09:30:26 +01:00
fanquake
afce044bb6
build: remove unused natpmp / upnp cppflags
Their inclusion is likely just the result of copy-paste.

The only place upnp/natpmpflags  should be used is `libbitcoin_node`
(mapport.cpp).
2022-09-15 09:30:26 +01:00
MacroFake
fa1ce96184
test: Add missing syncwithvalidationinterfacequeue 2022-09-15 09:06:13 +02:00
MacroFake
718304d222
Merge bitcoin/bitcoin#26084: sendall: check if the maxtxfee has been exceeded
6f8e3818af sendall: check if the maxtxfee has been exceeded (ishaanam)

Pull request description:

  Previously the `sendall` RPC didn't check whether the fees of the transaction it creates exceed the set `maxtxfee`. This PR adds this check to `sendall` and a test case for it.

ACKs for top commit:
  achow101:
    ACK 6f8e3818af
  Xekyo:
    ACK 6f8e3818af
  glozow:
    Concept ACK 6f8e3818af. The high feerate is unlikely but sendall should respect the existing wallet options.

Tree-SHA512: 6ef0961937091293d49be16f17e4451cff3159d901c0c7c6e508883999dfe0c20ed4d7126bf74bfea8150d4c1eef961a45f0c28ef64562e6cb817fede2319f1a
2022-09-15 08:45:08 +02:00
Anthony Towns
bf12abe454 net: drop cs_sendProcessing
SendMessages() is now protected g_msgproc_mutex; so this additional
per-node mutex is redundant.
2022-09-15 14:44:42 +10:00
Anthony Towns
1e78f566d5 net: add NetEventsInterface::g_msgproc_mutex
There are many cases where we assume message processing is
single-threaded in order for how we access node-related memory to be
safe. Add an explicit mutex that we can use to document this, which allows
the compiler to catch any cases where we try to access that memory from
other threads and break that assumption.
2022-09-15 14:44:38 +10:00
Andrew Chow
2e3cd26a1a
Merge bitcoin/bitcoin#26053: rpc: bugfix, 'add_inputs' default value is true unless 'inputs' are provided
b00fc44ca5 test: add coverage for 'add_inputs' dynamic default value (furszy)
ddbcfdf3d0 RPC: bugfix, 'add_inputs' default value is true unless 'inputs' are provided (furszy)

Pull request description:

  This bugfix was meant to be in #25685, but decoupled it to try to make it part of 24.0 release.
  It's a truly misleading functionality.

  This PR doesn't change behavior in any way. Just fixes two invalid RPC help messages and adds test
  coverage for the current behavior.

  #### Description
  In both RPC commands `send()` and `walletcreatefundedpsbt` the help message says
  that `add_inputs` default value is false when it's actually dynamically set by the following statement:

  ```c++
  coin_control.m_allow_other_inputs = rawTx.vin.size() == 0;
  ```

  Which means that, by default, `add_inputs` is true unless there is any pre-set input, in which
  case, the default is false.

ACKs for top commit:
  achow101:
    ACK b00fc44ca5
  S3RK:
    ACK b00fc44ca5

Tree-SHA512: 5c68a40d81c994e0ab6de0817db69c4d3dea3a9a64a60362531bf583b7a4c37d524b740905a3f3a89cdbf221913ff5b504746625adb8622788aea93a35bbcd40
2022-09-14 16:15:03 -04:00
Hennadii Stepanov
6725030e41
qt: Update translation source file for string freeze (round 2) 2022-09-14 15:03:07 +01:00
Hennadii Stepanov
f523df1ee8
Merge bitcoin-core/gui#664: Prevent wrong handling of %2 token by Transifex
8ed2b72767 qt: Prevent wrong handling of `%2` token by Transifex (Hennadii Stepanov)

Pull request description:

  On master (124e75a41e), Transifex translation check fails for 124e75a41e/src/qt/forms/intro.ui (L206) with a message:
  > The expression '%2G' is not present in the translation.

  In "Organization Settings" --> ["Translation checks"](https://www.transifex.com/bitcoin/settings/validations/) I have changed the status of the "**Variable substitution specifiers (like "%s") are preserved in the translations.**" check from "error" to "warning" temporarily. This setting should be reverted after applying this PR change.

  [Noted](https://www.transifex.com/bitcoin/bitcoin/translate/#ru/qt-translation-024x/436102928/) by Transifex user [AHOHNMYC](https://www.transifex.com/user/profile/AHOHNMYC/).

  I faced the same issue while working on Ukrainian translation.

ACKs for top commit:
  katesalazar:
    ACK 8ed2b72767
  jarolrod:
    ACK 8ed2b72767

Tree-SHA512: 304f795ac9241ac8453c614ed18d967226d9d515f9ea079b51af5bcbe2f0760ca7dcaea5efb38207720cb7a18159c2bcd337b961bc522a128715c70e0db81061
2022-09-14 14:58:59 +01:00
Hennadii Stepanov
bc29c4d4a5
Merge bitcoin-core/gui#663: Cleanup translation comment
5f28fc8160 qt: Cleanup translation comment (Hennadii Stepanov)

Pull request description:

  An unneeded character slipped in bitcoin-core/gui#629.

ACKs for top commit:
  jarolrod:
    ACK 5f28fc8160
  jonatack:
    utACK 5f28fc8160

Tree-SHA512: 210fb626e8035786cf6859160c60b2815c813e02908c75efc71a2c64d511edd6f81b2f67f1c98b29122b990260ebf663da445ea2d01b6268e3e046ada1ca5b6e
2022-09-14 14:56:26 +01:00
MacroFake
faa4916529
test/doc: Remove unused syncwithvalidationinterfacequeue
See https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958562071

Also fix doc typo from https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958571943
2022-09-14 14:34:53 +02:00
Vasil Dimov
9d7ae4b66c
sync: remove unused template parameter from ::UniqueLock
The template parameter `typename Base = typename Mutex::UniqueLock` is
not used, so remove it. Use internally defined type `Base` to avoid
repetitions of `Mutex::UniqueLock`.
2022-09-14 14:17:09 +02:00
Vasil Dimov
11c190e3f1
sync: simplify MaybeCheckNotHeld() definitions by using a template
Reduce 4 of the `MaybeCheckNotHeld()` definitions to 2 by using a
template. This also makes the function usable for other
[BasicLockable](https://en.cppreference.com/w/cpp/named_req/BasicLockable)
types.
2022-09-14 14:17:01 +02:00
MacroFake
a8c3590890
Merge bitcoin/bitcoin#25831: refactor: Remove trailing semicolon from LOCK2 macro
0f0cc05e4c refactor: Remove trailing semicolon from LOCK2 (Aurèle Oulès)

Pull request description:

  Macros should not have a trailing semi-colon to avoid empty statements when using them with another semi-colon.
  Noticed this while reviewing a PR.

ACKs for top commit:
  vasild:
    ACK 0f0cc05e4c

Tree-SHA512: 97fa4d89f5131ac30e05b293f750b757d5526feed56885c6feeb403b3ac3d3d3205874bc507c3b56a8296a6e3bdc8d879b2c339784f1e6ab1963d1b8a8d7b02f
2022-09-14 13:06:25 +02:00
Cory Fields
02c9e56468
fs: fully initialize _OVERLAPPED for win32 2022-09-14 11:55:10 +01:00
stickies-v
26cf9ea8e4
scripted-diff: rename pszThread to thread_name
Since it is now a string_view instead of a const char*, update the
name to reflect that the variable is no longer a "Pointer to
String, Zero-terminated" (psz).

-BEGIN VERIFY SCRIPT-
sed -i s/pszThread/thread_name/ $(git grep -l pszThread src)
-END VERIFY SCRIPT-
2022-09-14 11:00:14 +01:00
fanquake
a10df7cf35
build: prune BOOST_CPPFLAGS from libbitcoin_zmq
Rather than including validation.h, which ultimately means needing boost
via txmempool.h, include primitives/block.h for CBlock, and remove
validation.h, as we can get cs_main from node/blockstorage.h.
2022-09-14 09:33:34 +01:00
fanquake
f839697d9b
build: remove BOOST_CPPFLAGS usage from bitcoin-tx
The only reason BOOST_CPPFLAGS is needed here, is because of the
policy/rbf.h include, which ultimately includes boost multi_index
via txmempool.h. However this include is actually unused.
2022-09-14 09:10:04 +01:00
ishaanam
6f8e3818af sendall: check if the maxtxfee has been exceeded 2022-09-13 18:12:42 -04:00
furszy
ddbcfdf3d0
RPC: bugfix, 'add_inputs' default value is true unless 'inputs' are provided
In both RPC commands `send()` and `walletcreatefundedpsbt` the RPC help was saying
that `add_inputs` default value was false when it's actually dynamically set
by the following statement:

`coin_control.m_allow_other_inputs = rawTx.vin.size() == 0;`

Which means that, by default, `add_inputs` is true unless there
was any pre-set input, in which case, the default is false.
2022-09-13 16:13:05 -03:00
stickies-v
200d84d568
refactor: use std::string for index names 2022-09-13 19:10:41 +01:00
stickies-v
97f5b20c12
refactor: use std::string for thread names 2022-09-13 19:07:39 +01:00