Commit Graph

24031 Commits

Author SHA1 Message Date
Andrew Chow
3ff67f7783
Merge bitcoin/bitcoin#19690: util: improve FindByte() performance
72efc26439 util: improve streams.h:FindByte() performance (Larry Ruane)
604df63f6c [bench] add streams findbyte (gzhao408)

Pull request description:

  This PR is strictly a performance improvement; there is no functional change. The `CBufferedFile::FindByte()` method searches for the next occurrence of the given byte in the file. Currently, this is done by explicitly inspecting each byte in turn. This PR takes advantage of `std::find()` to do the same more efficiently, improving its CPU runtime by a factor of about 25 in typical use.

ACKs for top commit:
  achow101:
    re-ACK 72efc26439
  stickies-v:
    re-ACK 72efc26439

Tree-SHA512: ddf0bff335cc8aa34f911aa4e0558fa77ce35d963d602e4ab1c63090b4a386faf074548daf06ee829c7f2c760d06eed0125cf4c34e981c6129cea1804eb3b719
2023-05-10 17:50:42 -04:00
Andrew Chow
e0a70c5b4f
Merge bitcoin/bitcoin#27605: refactor: Replace global find_value function with UniValue::find_value method
fa266c4bbf Temporarily work around gcc-13 warning bug in interfaces_tests (MarcoFalke)
fa28850562 Fix clang-tidy performance-unnecessary-copy-initialization warnings (MarcoFalke)
faaa60a30e Remove unused find_value global function (MarcoFalke)
fa422aeec2 scripted-diff: Use UniValue::find_value method (MarcoFalke)
fa548ac872 Add UniValue::find_value method (MarcoFalke)

Pull request description:

  The global function has issues:

  * It causes gcc-13 warnings, see https://github.com/bitcoin/bitcoin/issues/26926
  * There is no rationale for it being a global function, when it acts like a member function
  * `performance-unnecessary-copy-initialization` clang-tidy isn't run on it

  Fix all issues by making it a member function.

ACKs for top commit:
  achow101:
    ACK fa266c4bbf
  hebasto:
    re-ACK fa266c4bbf

Tree-SHA512: 6c4e25da3122cd3b91c376bef73ea94fb3beb7bf8ef5cb3853c5128d95bfbacbcbfb16cc843eb7b1a7ebd350c2b6311f8085eeacf9aeeab3366987037d209e44
2023-05-10 12:56:37 -04:00
fanquake
104eed1166
Merge bitcoin/bitcoin#27611: refactor: Use ChainType enum exhaustively
e23088707b refactor: Use ChainType enum exhaustively (TheCharlatan)

Pull request description:

  This is a follow up of https://github.com/bitcoin/bitcoin/pull/27491, more concretely https://github.com/bitcoin/bitcoin/pull/27491#discussion_r1188847896, for not using default cases (as per the style guide), and https://github.com/bitcoin/bitcoin/pull/27491#discussion_r1188852707 and https://github.com/bitcoin/bitcoin/pull/27491#discussion_r1188851857 for avoiding dead code.

ACKs for top commit:
  fanquake:
    ACK e23088707b - deals with almost all follow up comments out of #27491.

Tree-SHA512: 1794190b03b91d3ca349a4da08e9610dbb3432983eee7cb21ecc758d1d7d710560c97661de14cdf493c28c00ebe8977511b4696055c0940e7f815b622dbacd16
2023-05-10 12:27:18 +01:00
TheCharlatan
e23088707b
refactor: Use ChainType enum exhaustively
This is a follow up of https://github.com/bitcoin/bitcoin/pull/27491,
more concretely
https://github.com/bitcoin/bitcoin/pull/27491#discussion_r1188847896,
for not using default cases (as per the style guide), and
https://github.com/bitcoin/bitcoin/pull/27491#discussion_r1188852707 and
https://github.com/bitcoin/bitcoin/pull/27491#discussion_r1188851857 for
avoiding dead code.

Also change chain name to chain type in docstrings
2023-05-10 10:39:58 +02:00
MarcoFalke
fa266c4bbf
Temporarily work around gcc-13 warning bug in interfaces_tests
This can be reverted once gcc excludes lambdas with decltype(auto)
return type from its -Wdangling-reference analysis.
2023-05-09 20:27:05 +02:00
Suhas Daftuar
52e52071e0 p2p: Avoid prematurely clearing download state for other peers 2023-05-09 13:52:13 -04:00
MarcoFalke
fa28850562
Fix clang-tidy performance-unnecessary-copy-initialization warnings 2023-05-09 18:48:52 +02:00
MarcoFalke
faaa60a30e
Remove unused find_value global function 2023-05-09 18:48:10 +02:00
MarcoFalke
fa422aeec2
scripted-diff: Use UniValue::find_value method
-BEGIN VERIFY SCRIPT-
 sed --regexp-extended -i 's/find_value\(([^ ,]+), /\1.find_value(/g' $(git grep -l find_value)
-END VERIFY SCRIPT-
2023-05-09 18:47:14 +02:00
MarcoFalke
fa548ac872
Add UniValue::find_value method 2023-05-09 18:47:14 +02:00
fanquake
fc06881f13
Merge bitcoin/bitcoin#27491: refactor: Move chain constants to the util library
d168458d1f scripted-diff: Remove unused chainparamsbase includes (TheCharlatan)
e9ee8aaf3a Add missing definitions in prep for scripted diff (TheCharlatan)
ba8fc7d788 refactor: Replace string chain name constants with ChainTypes (TheCharlatan)
401453df41 refactor: Introduce ChainType getters for ArgsManager (TheCharlatan)
bfc21c31b2 refactor: Create chaintype files (TheCharlatan)

Pull request description:

  This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". It is also a follow up to #26177.

  It replaces pull request https://github.com/bitcoin/bitcoin/pull/27294, which just moved the constants to a new file, but did not re-declare them as enums.

  The code move of the chain name constants out of the `chainparamsbase` to their own separate header allows the kernel `chainparams` to no longer include `chainparamsbase`. The `chainparamsbase` contain references to the `ArgsManager` and networking related options that should not belong to the kernel library. Besides this move, the constants are re-declared as enums with helper functions facilitating string conversions.

ACKs for top commit:
  ryanofsky:
    Code review ACK d168458d1f. Just suggested changes since last review.

Tree-SHA512: ac2fbe5cbbab4f52eae1e30af1f16700b6589eb4764c328a151a712adfc37f326cc94a65c385534c57d4bc92cc1a13bf1777d92bc924a20dbb30440e7380b316
2023-05-09 15:42:21 +01:00
fanquake
d5ff96f920
Merge bitcoin/bitcoin#27594: refactor: Remove unused GetTimeMillis
fae1d9cded refactor: Remove unused GetTimeMillis (MarcoFalke)

Pull request description:

  The function is unused, not type-safe, and does not denote the underlying clock type. So remove it.

ACKs for top commit:
  willcl-ark:
    tACK fae1d9cded

Tree-SHA512: 41ea7125d1964192b85a94265be974d02bf1e79b1feb61bff11486dc0ac811745156940ec5cad2ad1f94b653936f8ae563c959c1c4142203a55645fcb83203e8
2023-05-09 15:21:56 +01:00
TheCharlatan
d168458d1f
scripted-diff: Remove unused chainparamsbase includes
This is a follow-up to previous commits moving the chain constants out
of chainparamsbase.

The script removes the chainparamsbase header in all files where it is
included, but not used. This is done by filtering against all defined
symbols of the header as well as its respective .cpp file.

The kernel chainparams now no longer relies on chainparamsbase.

-BEGIN VERIFY SCRIPT-
sed -i '/#include <chainparamsbase.h>/d' $( git grep -l 'chainparamsbase.h' | xargs grep -L 'CBaseChainParams\|CreateBaseChainParams\|SetupChainParamsBaseOptions\|BaseParams\|SelectBaseParams\|chainparamsbase.cpp' )
-END VERIFY SCRIPT-
2023-05-09 15:49:19 +02:00
TheCharlatan
e9ee8aaf3a
Add missing definitions in prep for scripted diff
The missing include and ArgsManager were found after applying the
scripted diff in the following commit.
2023-05-09 15:49:17 +02:00
TheCharlatan
ba8fc7d788
refactor: Replace string chain name constants with ChainTypes
This commit effectively moves the definition of these constants
out of the chainparamsbase to their own file.

Using the ChainType enums provides better type safety compared to
passing around strings.

The commit is part of an ongoing effort to decouple the libbitcoinkernel
library from the ArgsManager and other functionality that should not be
part of the kernel library.
2023-05-09 15:49:14 +02:00
fanquake
b13830eff6
Merge bitcoin/bitcoin#27575: Introduce platform-agnostic ALWAYS_INLINE macro
3f19875d66 scripted-diff: Use platform-agnostic `ALWAYS_INLINE` macro (Hennadii Stepanov)
e16c22fe02 Introduce platform-agnostic `ALWAYS_INLINE` macro (Hennadii Stepanov)

Pull request description:

  Split from https://github.com/bitcoin/bitcoin/pull/24773 as requested in https://github.com/bitcoin/bitcoin/pull/24773#issuecomment-1534954977.

ACKs for top commit:
  theuni:
    utACK 3f19875d66
  fanquake:
    ACK 3f19875d66

Tree-SHA512: a19b713433bb4d3c5fff1ddb4d1413837823a400c1d46363a8181e7632b059846ba92264be1c867f35f532af90945ed20887103471b09c07623e0f3905b4098b
2023-05-09 14:45:52 +01:00
TheCharlatan
401453df41
refactor: Introduce ChainType getters for ArgsManager
These are introduced for the next commit where the usage of the
ChainType is adopted throughout the code.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2023-05-09 15:38:37 +02:00
TheCharlatan
bfc21c31b2
refactor: Create chaintype files
This is the first of a number of commits with the goal of moving the
chain type definitions out of chainparamsbase to their own file and
implementing them as enums instead of constant strings. The goal is to
allow the kernel chainparams to no longer include chainparamsbase.

The commit is part of an ongoing effort to decouple the libbitcoinkernel
library from the ArgsManager and other functionality that should not be
part of the kernel library.
2023-05-09 11:33:09 +02:00
Andrew Chow
fa53611cf1
Merge bitcoin/bitcoin#26076: Switch hardened derivation marker to h
fe49f06c0e doc: clarify PR 26076 release note (Sjors Provoost)
bd13dc2f46 Switch hardened derivation marker to h in descriptors (Sjors Provoost)

Pull request description:

  This makes it easier to handle descriptor strings manually, especially when importing from another Bitcoin Core wallet.

  For example the `importdescriptors` RPC call is easiest to use `h` as the marker: `'["desc": ".../0h/..."]'`, avoiding the need for escape characters. With this change `listdescriptors` will use `h`, so you can copy-paste the result, without having to add escape characters or switch `'` to 'h' manually.

  Both markers can still be parsed.

  The `hdkeypath` field in `getaddressinfo` is also impacted by this change, except for legacy wallets. The latter is to prevent accidentally breaking ancient software that uses our legacy wallet.

  See discussion in #15740

ACKs for top commit:
  achow101:
    ACK fe49f06c0e
  darosior:
    re-ACK fe49f06c0e

Tree-SHA512: f78bc873b24a6f7a2bf38f5dd58f2b723e35e6b10e4d65c36ec300e2d362d475eeca6e5afa04b3037ab4bee0bf8ebc93ea5fc18102a2111d3d88fc873c08dc89
2023-05-08 13:31:28 -04:00
MarcoFalke
fae1d9cded
refactor: Remove unused GetTimeMillis
The function is unused, not type-safe, and does not denote the
underlying clock type. So remove it.
2023-05-08 12:40:48 +02:00
fanquake
322ec63b01
Merge bitcoin/bitcoin#17860: fuzz: BIP 30, CVE-2018-17144
fa2d8b61f9 fuzz: BIP 42, BIP 30, CVE-2018-17144 (MarcoFalke)
faae7d5c00 Move LoadVerifyActivateChainstate to ChainTestingSetup (MarcoFalke)
fa26e3462a Avoid dereferencing interruption_point if it is nullptr (MarcoFalke)
fa846ee074 test: Add util to mine invalid blocks (MarcoFalke)

Pull request description:

  Add a validation fuzz test for BIP 30 and CVE-2018-17144

ACKs for top commit:
  dergoegge:
    Code review ACK fa2d8b61f9
  mzumsande:
    Tested ACK fa2d8b61f9

Tree-SHA512: 1f4620cc078709487abff24b304a6bb4eeab2e7628b392e2bc6de9cc0ce6745c413388ede6e93025d0c56eec905607ba9786633ef183e5779bf5183cc9ff92c0
2023-05-06 12:13:06 +01:00
fanquake
e460c0a24a
Merge bitcoin/bitcoin#27405: util: Use steady clock instead of system clock to measure durations
fa83fb3161 wallet: Use steady clock to calculate number of derive iterations (MarcoFalke)
fa2c099cec wallet: Use steady clock to measure scanning duration (MarcoFalke)
fa97621804 qt: Use steady clock to throttle GUI notifications (MarcoFalke)
fa1d8044ab test: Use steady clock in index tests (MarcoFalke)
fa454dcb20 net: Use steady clock in InterruptibleRecv (MarcoFalke)

Pull request description:

  `GetTimeMillis` has multiple issues:

  * It doesn't denote the underlying clock type
  * It isn't type-safe
  * It is used incorrectly in places that should use a steady clock

  Fix all issues here.

ACKs for top commit:
  willcl-ark:
    ACK fa83fb3161
  martinus:
    Code review ACK fa83fb3161, also ran all tests. All usages of the steady_clock are just for duration measurements, so the change to a different epoch is ok.

Tree-SHA512: 5ec4fede8c7f97e2e08863c011856e8304f16ba30a68fdeb42f96a50a04961092cbe46ccf9ea6ac99ff5203c09f9e0924eb483eb38d7df0759addc85116c8a9f
2023-05-06 12:03:50 +01:00
Larry Ruane
72efc26439 util: improve streams.h:FindByte() performance
Avoid use of the expensive mod operator (%) when calculating the
buffer offset. No functional difference.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2023-05-05 06:03:17 -06:00
gzhao408
604df63f6c [bench] add streams findbyte 2023-05-05 06:03:14 -06:00
MarcoFalke
fa2d8b61f9
fuzz: BIP 42, BIP 30, CVE-2018-17144 2023-05-05 13:31:01 +02:00
MarcoFalke
faae7d5c00
Move LoadVerifyActivateChainstate to ChainTestingSetup 2023-05-05 13:19:09 +02:00
Hennadii Stepanov
3f19875d66
scripted-diff: Use platform-agnostic ALWAYS_INLINE macro
-BEGIN VERIFY SCRIPT-
sed -i 's/ inline __attribute__((always_inline)) / ALWAYS_INLINE /g' $(git grep -l "inline __attribute__((always_inline))")
sed -i 's/ inline  __attribute__((always_inline)) / ALWAYS_INLINE /g' $(git grep -l "inline  __attribute__((always_inline))")
-END VERIFY SCRIPT-
2023-05-04 20:58:01 +01:00
Hennadii Stepanov
e16c22fe02
Introduce platform-agnostic ALWAYS_INLINE macro
`<attributes.h>` has been included in anticipation of the following
commit.
2023-05-04 20:57:51 +01:00
MarcoFalke
fa5d7c39eb
Remove unused chainparams from BlockManager methods
Also, replace pointer with reference while touching the signature.
2023-05-04 19:27:23 +02:00
MarcoFalke
fa3f74a40e
Replace pindex pointer with block reference
pindex can not be nullptr, so document that, and clear it up in the next
commit.
2023-05-04 19:26:48 +02:00
MarcoFalke
facdb8b331
Add BlockManagerOpts::chainparams reference
and use it in blockstorage.cpp
2023-05-04 19:26:43 +02:00
Andrew Chow
aebcd18c65
Merge bitcoin/bitcoin#24957: prune, import: allow pruning to work during loadblock import
c4981e7f63 prune, import: fixes #23852 (mruddy)

Pull request description:

  Fixes #23852

  This allows pruning to work during the `-loadblock` import process.

  An example use case is where you have a clean set of block files and you want to create a pruned node from them, but you don't want to alter the input set of block files.

  #23852 noted that pruning was not working reliably during the loadblock import process. The reason why the loadblock process was not pruning regularly as it progressed is that the pruning process (`BlockManager::FindFilesToPrune`) checks the tip height of the active chainstate, and `CChainState::ActivateBestChain` was not called (which updates that tip height) in `ThreadImport` until after all the import files were processed.

  An example bash command line that makes it easy to import a bunch of block files:
  ```
  ./src/qt/bitcoin-qt -debug -logthreadnames -datadir=/tmp/btc -prune=550 -loadblock=/readonly/btc/main/blk{00000..00043}.dat
  ```

  One interesting side note is that `CChainState::ActivateBestChain` can be called while the import process is running (in the `loadblk` thread) by concurrent network message processing activity in the `msghand` thread. For example, one way to reproduce this easily is with the `getblockfrompeer` RPC (requesting a block with height greater than 100000) run from a node connected to an importing node. There are other ways too, but this is an easy way. I only mention this to explain how the `max_prune_height=225719` log message in the original issue came to occur.

ACKs for top commit:
  achow101:
    re-ACK c4981e7f63

Tree-SHA512: d287c7753952c22f598ba782914c47f45ad44ce60b0fbce9561354e701f1a2a98bafaaaa106c8428690b814e281305ca3622b177ed3cb2eb7559f07c958ab537
2023-05-03 17:49:57 -04:00
Andrew Chow
0e70a1b625
Merge bitcoin/bitcoin#26066: wallet: Refactor and document CoinControl
daba95700b refactor: Make ListSelected return vector (Sebastian Falbesoner)
94776621ba wallet: Move CoinCointrol definitions to .cpp (Aurèle Oulès)
1db23da6e1 wallet: Use std::optional for GetExternalOutput and fixups (Aurèle Oulès)
becc45b589 scripted-diff: Rename setSelected->m_selected_inputs (Aurèle Oulès)

Pull request description:

  - Moves CoinControl function definitions from `coincontrol.h` to `coincontrol.cpp`
  - Adds more documentation
  - Renames class member for an improved comprehension
  - Use `std::optional` for `GetExternalOutput`

ACKs for top commit:
  achow101:
    ACK daba95700b
  Xekyo:
    ACK daba95700b

Tree-SHA512: 3bf2dc834a3246c2f53f8c55154258e605fcb169431d3f7b156931f33c7e3b1ae28e03e16b37f9140a827890eb7798be485b2c36bfc23ff29bb01763f289a07c
2023-05-03 11:17:28 -04:00
0xb10c
4581a682d2
clarify processing of mempool-msgs when NODE_BLOOM
Under which circumstances we process received 'mempool' P2P messages
caused confusion in #27426. Rather than bikeshedding the formulation
of the IF-statement, this adds a comment clarifing when we process
the message. Also, correcting the comment of `m_send_mempool`.

Co-authored-by: willcl-ark <will8clark@gmail.com>
2023-05-03 00:24:22 +02:00
MarcoFalke
fa26e3462a
Avoid dereferencing interruption_point if it is nullptr 2023-05-02 20:19:28 +02:00
Andrew Chow
da9f62f912
Merge bitcoin/bitcoin#26094: rpc: Return block hash & height in getbalances, gettransaction and getwalletinfo
710b83938a rpc: return block hash & height in getbalances, gettransaction & getwalletinfo JSONs (Harris)

Pull request description:

  Reopens #18570 and closes #18567.
  I have rebased the original PR.
  Not sure why the original got closed as it was about to get merged.

ACKs for top commit:
  achow101:
    ACK 710b83938a

Tree-SHA512: d4478d990be98b1642e9ffb2930987f4a224e8bd64e2e35a5dda927a54c509ec9d712cd0eac35dc2bb89f00a1678e530ce14d7445f1dd93aa3a4cce2bc9b130d
2023-05-02 11:50:45 -04:00
MarcoFalke
fa846ee074
test: Add util to mine invalid blocks
With the current utils it is only possible to mine valid blocks. This
commit adds new util methods to mine invalid blocks.
2023-05-02 17:17:06 +02:00
fanquake
8a373a5c7f
Merge bitcoin/bitcoin#27191: blockstorage: Adjust fastprune limit if block exceeds blockfile size
8f14fc8622 test: cover fastprune with excessive block size (Matthew Zipkin)
271c23e87f blockstorage: Adjust fastprune limit if block exceeds blockfile size (Martin Zumsande)

Pull request description:

  The debug-only `-fastprune` option used in several tests is not always safe to use:
  If a `-fastprune` node receives a block larger than the maximum blockfile size of `64kb` bad things happen: The while loop in `BlockManager::FindBlockPos` never terminates, and the node runs oom because memory for `m_blockfile_info` is allocated in each iteration of the loop.
  The same would happen if a naive user used `-fastprune` on anything other than regtest (so this can be tested by syncing on signet for example, the first block that crashes the node is at height 2232).

  Change the approach by raising the blockfile size to the size of the block, if that block otherwise wouldn't fit (idea by TheCharlatan).

ACKs for top commit:
  ryanofsky:
    Code review ACK 8f14fc8622. Added new assert, test, and comment since last review
  TheCharlatan:
    ACK 8f14fc8622
  pinheadmz:
    ACK 8f14fc8622

Tree-SHA512: df2fea30613ef9d40ebbc2416eacb574f6d7d96847db5c33dda22a29a2c61a8db831aa9552734ea4477e097f253dbcb6dcb1395d43d2a090cc0588c9ce66eac3
2023-05-02 10:04:34 +01:00
Andrew Chow
0eae93e65f
Merge bitcoin/bitcoin#26780: rpc: simplify scan blocks
b922f6b526 rpc: scanblocks, add "completed" flag to the result obj (furszy)
ce50acc54f rpc: scanblocks, do not traverse the whole chain block by block (furszy)

Pull request description:

  Coming from https://github.com/bitcoin/bitcoin/pull/23549#pullrequestreview-1105712566

  The current `scanblocks` flow walks-through every block in the active chain
  until hits the chain tip or processes 10k blocks, then calls `lookupFilterRange`
  function to obtain all filters from that particular range.

  This is only done to obtain the heights range to look up the block
  filters. Which is unneeded.

  As `scanblocks` only lookup block filters in the active chain, we can
  directly calculate the lookup range heights, by using the chain tip,
  without requiring to traverse the chain block by block.

ACKs for top commit:
  achow101:
    ACK b922f6b526
  TheCharlatan:
    ACK b922f6b526

Tree-SHA512: 0587e6d9cf87a59184adb2dbc26a4e2bce3a16233594c6c330f69feb49bf7dc63fdacf44fc20308e93441159ebc604c63eb7de19204d3e745a2ff16004892b45
2023-05-01 09:10:11 -04:00
Andrew Chow
3497df4c75
Merge bitcoin/bitcoin#27195: bumpfee: allow send coins back to yourself
be72663a15 test: bumpfee, add coverage for "send coins back to yourself" (furszy)
7bffec6715 bumpfee: enable send coins back to yourself (furszy)

Pull request description:

  Simple example:

  1) User_1 sends 0.1 btc to user_2 on a low fee transaction.
  2) After few hours, the tx is still in the mempool, user_2
     is not interested anymore, so user_1 decides to cancel
     it by sending coins back to himself.
  3) User_1 has the bright idea of opening the explorer and
     copy the change output address of the transaction. Then
     call bumpfee providing such output (in the "outputs" arg).

  Currently, this is not possible. The wallet fails with
  "Unable to create transaction. Transaction must have at least
  one recipient" error.
  The error reason is because we discard the provided output
  from the recipients list and set it inside the coin control
  so the process adds it later (when the change is calculated).
  But.. there is no later if the tx has no outputs.

ACKs for top commit:
  ishaanam:
    reACK be72663a15
  achow101:
    ACK be72663a15

Tree-SHA512: c2c38290a998f9b426a830d9624c7feb730158980ac186f8fb0138d5e200935d6538307bc60a2c3d0b7b6ee2b4ffb77a1e98baf8feb1d20a7d825f6055ac377f
2023-05-01 08:38:50 -04:00
Andrew Chow
071308860a
Merge bitcoin/bitcoin#25680: rpc, docs: Add note for commands that supports only legacy wallets
9141e4395a rpc, docs: Add note for commands that supports only legacy wallets (Yusuf Sahin HAMZA)

Pull request description:

  Refs #25363, apparently issue is not updated since over a month, so i decided to put the same `importaddress` note in #25368 to other rpc commands that needs this note.

  Note is added for following commands:

  - `importprivkey`
  - `importpubkey`
  - `importwallet`
  - `dumpprivkey`
  - `dumpwallet`
  - `importmulti`
  - `addmultisigaddress`
  - `sethdseed`

ACKs for top commit:
  achow101:
    ACK 9141e4395a

Tree-SHA512: f3dc05d26577fd8dbe2bd69cb5c14ffccebacd6010402af44427b3d01be8484895dfcf33d55dfa766eadb7f9f3bae5cc4c2add3ac816a2ac60e8beb5a97527f3
2023-05-01 08:24:42 -04:00
Andrew Chow
5325a61167
Merge bitcoin/bitcoin#27224: refactor: Remove CAddressBookData::destdata
a5986e82dd refactor: Remove CAddressBookData::destdata (Ryan Ofsky)
5938ad0bdb wallet: Add DatabaseBatch::ErasePrefix method (Ryan Ofsky)

Pull request description:

  This is cleanup that doesn't change external behavior. Benefits of the cleanup are:

  - Removes awkward `StringMap` intermediate representation for wallet address metadata.
  - Simplifies `CWallet`, deals with used address and received request serialization in `walletdb.cpp` instead of higher level wallet code
  - Adds test coverage and documentation

  This PR doesn't change externally observable behavior. Internally, the only change in behavior is that `EraseDestData` deletes rows directly from the database because they are no longer stored in memory. This is more direct and efficient because it uses a single lookup and scan instead of multiple lookups.

  Motivation for this cleanup is making changes like #18550, #18192, #13756 easier to reason about and less likely to result in unintended behavior and bugs

  ---

  This PR is a rebased copy of #18608. For some reason that PR is locked and couldn't be reopened or commented on.

  This PR is an alternative to #27215 with differences described in https://github.com/bitcoin/bitcoin/pull/27215#pullrequestreview-1329028143

ACKs for top commit:
  achow101:
    ACK a5986e82dd
  furszy:
    Code ACK a5986e82

Tree-SHA512: 6bd3e402f1f60263fbd433760bdc29d04175ddaf8307207c4a67d59f6cffa732e176ba57886e02926f7a1615dce0ed9cda36c8cbc6430aa8e5b56934c23f3fe7
2023-05-01 08:16:54 -04:00
furszy
b922f6b526
rpc: scanblocks, add "completed" flag to the result obj
To tell the user whether the process was aborted or not.

Plus, as the process can be aborted prior to the end range,
have also changed the "to_height" result value to return the
last scanned block instead of the end range block.
2023-04-30 19:26:11 +01:00
furszy
ce50acc54f
rpc: scanblocks, do not traverse the whole chain block by block
The current flow walks-through every block in the active chain until
hits the chain tip or processes 10k blocks, then calls
`lookupFilterRange()` to obtain all the filters from that
particular range.

This is only done to obtain the heights range to look up the block
filters. Which is unneeded.

As `scanblocks` only lookup block filters in the active chain, we can
directly calculate the lookup range heights, by using the chain tip,
without requiring to traverse the chain block by block.
2023-04-30 19:14:20 +01:00
Harris
710b83938a rpc: return block hash & height in getbalances, gettransaction & getwalletinfo JSONs
Co-authored-by: Aurèle Oulès <aurele@oules.com>
2023-04-26 16:07:47 +02:00
Andrew Chow
91ccb62faa
Merge bitcoin/bitcoin#25158: rpc, wallet: add abandoned field for all categories of transaction in ListTransaction
0c520679ab doc: add release notes for `abandoned` field in `gettransaction` and `listtransactions` (brunoerg)
a1aaa7f51f rpc, wallet: add `abandoned` field for all categories of transactions in ListTransactions (brunoerg)

Pull request description:

  Fixes #25130

ACKs for top commit:
  achow101:
    re-ACK 0c520679ab

Tree-SHA512: 1864460d76decab7898737c96517d722055eb8f81ca52248fe1035723258c6cd4a93251e06a86ecbbb0b0a80af1466b2c86fb142ace4ccb74cc40d5dc3967d7f
2023-04-26 08:50:56 -04:00
glozow
bdfe27c9d2
Merge bitcoin/bitcoin#26933: mempool: disallow txns under min relay fee, even in packages
bf77fc9cb4 [test] mempool full in package accept (glozow)
b51ebccc28 [validation] set PackageValidationState when mempool full (glozow)
563a2ee4f5 [policy] disallow transactions under min relay fee, even in packages (glozow)
c4554fe894 [test] package cpfp bumps parents <mempoolminfee but >=minrelaytxfee (glozow)
ac463e87df [test util] mock mempool minimum feerate (glozow)

Pull request description:

  Part of package relay, see #27463.

  Note that this still allows packages to bump transactions that are below the dynamic mempool minimum feerate, which means this still solves the "mempool is congested and my presigned 1sat/vB tx is screwed" problem for all transactions.

  On master, the package policy (only accessible through regtest-only RPC submitpackage) allows 0-fee (or otherwise below min relay feerate) transactions if they are bumped by a child. However, with default package limits, we don't yet have a DoS-resistant way of ensuring these transactions remain bumped throughout their time in the mempool. Primarily, the fee-bumping child may later be replaced by another transaction that doesn't bump the parent(s). The parent(s) could potentially stay bumped by other transactions, but not enough to ever be selected by the `BlockAssembler` (due to `blockmintxfee`).

  For example, (tested [here](https://github.com/glozow/bitcoin/commits/26933-motivation)):
  - The mempool accepts 24 below-minrelayfeerate transactions ("0-fee parents"), all bumped by a single high-fee transaction ("the fee-bumping child"). The fee-bumping child also spends a confirmed UTXO.
  - Two additional children are added to each 0-fee parent. These children each pay a feerate slightly above the minimum relay feerate (e.g. 1.9sat/vB) such that, for each 0-fee parent, the total fees of its two children divided by the total size of the children and parent is above the minimum relay feerate.
  - If a block template is built now, all transactions would be selected.
  - A transaction replaces the the fee-bumping child, spending only the confirmed UTXO and not any of the outputs from the 0-fee parents.
   - The 0-fee parents now each have 2 children. Their descendant feerates are above minrelayfeerate, which means that they remain in the mempool, even if the mempool evicts all below-minrelayfeerate packages.
   - If a block template is built now, none of the 0-fee parents or their children would be selected.
   - Even more low-feerate descendants can be added to these below-minrelayfeerate packages and they will not be evicted until they expire or the mempool reaches capacity.

  Unless we have a DoS-resistant way of ensuring package CPFP-bumped transactions are always bumped, allowing package CPFP to bump below-minrelayfeerate transactions can result in these problematic situations. See #27018 which proposes a partial solution with some limitations, and contains discussion about potential improvements to eviction strategy. While no adequate solution exists, for now, avoid these situations by requiring all transactions to meet min relay feerate.

ACKs for top commit:
  ajtowns:
    reACK bf77fc9cb4
  instagibbs:
    re-ACK bf77fc9cb4

Tree-SHA512: 28940f41493a9e280b010284316fb8caf1ed7b2090ba9a4ef8a3b2eafc5933601074b142f4f7d4e3c6c4cce99d3146f5c8e1393d9406c6f2070dd41c817985c9
2023-04-26 11:18:09 +01:00
Sebastian Falbesoner
daba95700b refactor: Make ListSelected return vector 2023-04-26 10:41:10 +02:00
Aurèle Oulès
94776621ba wallet: Move CoinCointrol definitions to .cpp
Move definitions to coincontrol.cpp and add documentation.
2023-04-26 10:16:16 +02:00
Aurèle Oulès
1db23da6e1 wallet: Use std::optional for GetExternalOutput and fixups 2023-04-26 10:16:16 +02:00