Commit graph

37432 commits

Author SHA1 Message Date
Ryan Ofsky
5938ad0bdb wallet: Add DatabaseBatch::ErasePrefix method
This new function is not used yet this commit, but next commit adds usages and
test coverage for both BDB and sqlite.
2023-04-12 05:30:43 -04:00
Sebastian Falbesoner
6b17994ede doc: update OpenBSD build docs for 7.3 (external signer support available)
With OpenBSD 7.3, the waitid(2) system call is implemented (see
8112871f19).

This means Boost.Process finally doesn't fail to compile anymore and we
can remove the build hint about missing external signer support. Tested
on my amd64 machine by reconfiguring / rebuilding master branch and
successfully running the functional test wallet_signer.py.
2023-04-11 22:59:08 +02:00
Andrew Chow
18fc71a3ad doc: Release note for purpose string restriction 2023-04-11 15:55:32 -04:00
Andrew Chow
e83babe3b8 wallet: Replace use of purpose strings with an enum
Instead of storing and passing around fixed strings for the purpose of
an address, use an enum.

This also rationalizes the CAddressBookData struct, documenting all fields and
making them public, and simplifying the representation to avoid bugs like
https://github.com/bitcoin/bitcoin/pull/26761#discussion_r1134615114 and make
it not possible to invalid address data like change addresses with labels.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2023-04-11 15:55:31 -04:00
Ryan Ofsky
2f80005136 wallet: add AddressPurpose enum to replace string values 2023-04-11 15:52:25 -04:00
Ryan Ofsky
8741522e6c wallet: Add wallet/types.h for simple public enum and struct types
Move isminetype and isminefilter there this commit, add WalletPurpose type next
commit.
2023-04-11 15:52:25 -04:00
Andrew Chow
27dcc07c08
Merge : wallet, gui: bugfix, getAvailableBalance skips selected coins
68eed5df86 test,gui: add coverage for PSBT creation on legacy watch-only wallets (furszy)
306aab5bb4 test,gui: decouple widgets and model into a MiniGui struct (furszy)
2f76ac0383 test,gui: decouple chain and wallet initialization from test case (furszy)
cd98b71739 gui: 'getAvailableBalance', include watch only balance (furszy)
74eac3a82f test: add coverage for 'useAvailableBalance' functionality (furszy)
dc1cc1c359 gui: bugfix, getAvailableBalance skips selected coins (furszy)

Pull request description:

  Fixes https://github.com/bitcoin-core/gui/issues/688 and https://github.com/bitcoin/bitcoin/issues/26687.

  First Issue Description (https://github.com/bitcoin-core/gui/issues/688):

  The previous behavior for `getAvailableBalance`, when the coin control had selected coins, was to return the sum of them. Instead, we are currently returning the wallet's available total balance minus the selected coins total amount.

  Reason:
  Missed to update the `GetAvailableBalance` function to include the coin control selected coins on .

  Context:
  Since  we skip the selected coins inside `AvailableCoins`, the reason is that there is no need to waste resources walking through the entire wallet's txes map just to get coins that could have gotten by just doing a simple `mapWallet.find`).

  Places Where This Generates Issues (only when the user manually select coins via coin control):
  1) The GUI balance check prior the transaction creation process.
  2) The GUI "useAvailableBalance" functionality.

  Note 1:
  As the GUI uses a balance cache since https://github.com/bitcoin-core/gui/pull/598, this issue does not affect the regular spending process. Only arises when the user manually select coins.

  Note 2:
  Added test coverage for the `useAvailableBalance` functionality.

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

  Second Issue Description (https://github.com/bitcoin/bitcoin/issues/26687):

  As we are using a cached balance on `WalletModel::getAvailableBalance`,
  the function needs to include the watch-only available balance for wallets
  with private keys disabled.

ACKs for top commit:
  Sjors:
    tACK 68eed5df86
  achow101:
    ACK 68eed5df86
  theStack:
    ACK 68eed5df86

Tree-SHA512: 674f3e050024dabda2ff4a04b9ed3750cf54a040527204c920e1e38bd3d7f5fd4d096e4fd08a0fea84ee6abb5070f022b5c0d450c58fd30202ef05ebfd7af6d3
2023-04-11 14:05:55 -04:00
fanquake
c17d4d3b6b
Merge : fuzz: Add HeadersSyncState target
3153e7d779 [fuzz] Add HeadersSyncState target (dergoegge)
53552affca [headerssync] Make m_commit_offset protected (dergoegge)

Pull request description:

  This adds a fuzz target for the `HeadersSyncState` class.

  I am unsure how well this is able to cover the logic since it is just processing unserialized CBlockHeaders straight from the fuzz input (headers are sometimes made continuous). However, it does manage to get to the redownload phase so i thought it is better then not having fuzzing at all.

  It would also be nice to fuzz the p2p logic that is using `HeadersSyncState` (e.g. `TryLowWorkHeadersSync`, `IsContinuationOfLowWorkHeadersSync`) but that likely requires some more work (refactoring👻).

ACKs for top commit:
  mzumsande:
    ACK 3153e7d779

Tree-SHA512: 8a4630ceeeb30e4eeabaa8eb5491d98f0bf900efe7cda07384eaac9f2afaccfbcaa979cc1cc7f0b6ca297a8f5c17a7759f94809dd87eb87d35348d847c83e8ab
2023-04-11 16:17:04 +01:00
MarcoFalke
fa4a46de0b
ci: Bump nowallet_libbitcoinkernel task to ubuntu:focal
This is needed to work around
https://github.com/bitcoin/bitcoin/pull/27340#issuecomment-1484988445

The only change should be that python3.7 is bumped to 3.8, but this is
fine because ci/test/00_setup_env_native_qt5.sh still checks for
python3.7 compatibility.
2023-04-11 14:12:37 +02:00
MarcoFalke
fabc7d90a9
ci: Use credits in more tasks
This should give faster feedback about the CI result, while still
keeping expenses reasonable.
2023-04-11 14:12:30 +02:00
MarcoFalke
facae3b149
ci: Use Cirrus CI dockerfile env 2023-04-11 14:11:48 +02:00
fanquake
53eb4b7a21
Merge : refactor, net processing: Avoid CNode::m_relays_txs usage
55c4795c57 [net processing] Use TxRelay::m_relay_txs over CNode::m_relays_txs (dergoegge)

Pull request description:

  `CNode::m_relays_txs` is meant to only be used for the eviction logic in `net`. `TxRelay::m_relay_txs` will hold the same value and is meant to be used on the application layer to determine if we will/should relay transactions to a peer.

  (Shameless plug: we should really better specify the interface for updating eviction data to avoid refactors like this in the future -> )

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 55c4795c57

Tree-SHA512: 59cfd23e32568fd96cda5570790e518242a6c76d4edf5b7d1a2a7f9724d590d2a38395504e05be0af4e98dd5c0056fc0be6568eab2818934692483a186e5181d
2023-04-11 11:43:21 +01:00
fanquake
b24553c04c
Merge : test: LLVM/Clang 16 for MSAN jobs
676671527f test: LLVM/Clang 16 for MSAN jobs (fanquake)

Pull request description:

  Similar to other CI infra changes we've made recently. Move to LLVM/Clang 16 for the MSAN jobs (which is currently using LLVM 12).

  See also: https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#sanitizers:
  > `-fsanitize-memory-param-retval` is turned on by default. With `-fsanitize=memory`, passing uninitialized variables to functions and returning uninitialized variables from functions is more aggressively reported. `-fno-sanitize-memory-param-retval` restores the previous behavior.

ACKs for top commit:
  dergoegge:
    utACK 676671527f

Tree-SHA512: a105bd1bf7f4e3ede50bb119fd8ab7f308919dc46e093eb3e94351484d65a13220e2449c40d80b8103b9ac0f4b1c8ca29576ab83e2083c26b9d8060c5802b64d
2023-04-11 11:10:42 +01:00
Andrew Chow
a3eea2a27d
Merge : doc: correct sqlite & qrencode versions used in depenendencies.md
a12d9cfa46 doc: correct sqlite & qrencode versions used in depenendencies.md (fanquake)

Pull request description:

  Followup to https://github.com/bitcoin/bitcoin/pull/27312 & https://github.com/bitcoin/bitcoin/pull/25378.

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

Tree-SHA512: 29e1fe4c31089fce6acbadb14aa7619fdd55738a882b490f1a0835d7648798a68b4f0d62e213c60d92f8e021ea856a4d1759578da07413265fef2338840da506
2023-04-10 21:20:53 -04:00
Andrew Chow
9270a56662
Merge bitcoin/bitcoin#27440: contrib: followups to (verify-binaries)
ad841608d4 contrib: minor doc improvements in verify-binaries (fanquake)
e2e5683afe contrib: fixup verifybinaries example docs (fanquake)
663a89cfed contrib: move verify scripts to verify-binaries (fanquake)

Pull request description:

  Followup to , fixing up the example command docs and other requests. See https://github.com/bitcoin/bitcoin/pull/27358#issuecomment-1500389847.

ACKs for top commit:
  josibake:
    ACK ad841608d4
  achow101:
    ACK ad841608d4
  theuni:
    ACK ad841608d4. Thanks for doing these.

Tree-SHA512: 14c47b5a1b231d5116a1e5ddc78cb3a32ca1d4e86f7e18a0c63d5caac95a5272b3eddcc531052e130970a694dd1bc721bfcb29092755e306c37abc0b9f6c9dfd
2023-04-10 21:19:33 -04:00
Jon Atack
7ccdd741fe test: fix importmulti/importdescriptors assertion
as these RPCs have a "warnings" field, not a "warning" one.
2023-04-10 10:42:25 -07:00
Jon Atack
19d888ce40 rpc: move WALLET_FLAG_CAVEATS to the compilation unit of its caller
and add the walletutil.h include header for WALLET_FLAG_AVOID_REUSE that was
already missing before this change.

WALLET_FLAG_CAVEATS is only used in one RPC, so no need to encumber wallet.h and
wallet.cpp with it, along with all of the files that include wallet.h during
their compilation. Also apply clang-format per:

git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
2023-04-10 10:41:56 -07:00
Jon Atack
01df011ca2 doc: release note for wallet RPCs "warning" field deprecation 2023-04-10 10:41:56 -07:00
Jon Atack
9ea8b3739a test: createwallet "warning" field deprecation test 2023-04-10 10:41:56 -07:00
Jon Atack
645d7f75ac rpc: deprecate "warning" field in {create,load,unload,restore}wallet
This string field has been replaced in these four RPCs by a "warnings" field
returning a JSON array of strings.
2023-04-10 10:41:56 -07:00
Jon Atack
2f4a926e95 test: add test coverage for "warnings" field in createwallet
and clarify the "warning" field behavior.
2023-04-10 10:41:56 -07:00
Jon Atack
4a1e479ca6 rpc: add "warnings" field to RPCs {create,load,unload,restore}wallet
This new "warnings" field is a JSON array of strings intended to replace the
"warning" string field in these four RPCs, to better handle returning multiple
warning messages and for consistency with other wallet RPCs.
2023-04-10 10:41:35 -07:00
Jon Atack
079d8cdda8 rpc: extract wallet "warnings" fields to a util helper 2023-04-10 10:41:35 -07:00
Jon Atack
f73782a903 doc: fix/improve warning helps in {create,load,unload,restore}wallet
- clarify that there can be multiple warning messages
- specify the correct wallet action
- describe the use of newlines as delimiters
2023-04-10 10:41:06 -07:00
Andrew Chow
d52fa1b0a5 tests: Make sure that bumpfee feerate checks work when replacing outputs
When replacing the outputs of a transaction, we can end up with
fees that are drastically different from the original. This tests that
the feerate checks we perform will properly detect when the bumping tx
will have an insufficient feerate.
2023-04-10 10:02:41 -04:00
Andrew Chow
be177c15a4 bumpfee: Check the correct feerate when replacing outputs
When doing the feerate check for bumped transactions that replace the
outputs, we need to consider that the size of the new outputs may be
different from the old outputs and calculate the minimum feerate accordingly.
2023-04-10 09:56:25 -04:00
fanquake
676671527f
test: LLVM/Clang 16 for MSAN jobs
Sync up with other CI infra.
2023-04-10 10:57:05 +01:00
fanquake
d544d03ba6
Merge : doc: FreeBSD DataDirectoryGroupReadable Setting
499c464394 doc: update DataDirectoryGroupReadable 1 in tor.md (Jesse Barton)

Pull request description:

  Updating tor.md doc to include mention of FreeBSD requiring the DataDirectoryGroupReadable be set to 1.
  Default per the FreeBSD man page is 0.

         DataDirectoryGroupReadable 0|1
     If this option is set to 0, don't allow the filesystem groupto
     readthe DataDirectory. If the option is setto 1, make the
     DataDirectory readable by the default GID. (Default:0)

ACKs for top commit:
  vasild:
    ACK 499c464394

Tree-SHA512: 8750b49cd04e900435c7991d1a24641fd1171227c1f14ed59afb157f24c1ca60380d30aecfb174ca46fd5b4b99dcdb3a1cfd019aafc343362e8103abf7c17e6a
2023-04-09 22:11:43 +02:00
fanquake
ad841608d4
contrib: minor doc improvements in verify-binaries 2023-04-09 13:08:46 +02:00
fanquake
e2e5683afe
contrib: fixup verifybinaries example docs
Followup to , fixing up the example command docs.
2023-04-09 13:08:38 +02:00
fanquake
a12d9cfa46
doc: correct sqlite & qrencode versions used in depenendencies.md 2023-04-09 12:55:47 +02:00
fanquake
663a89cfed
contrib: move verify scripts to verify-binaries 2023-04-09 12:43:59 +02:00
Jesse Barton
499c464394 doc: update DataDirectoryGroupReadable 1 in tor.md
Move DataDirectoryGroupReadable 1 up a few lines to more clearly
communicate that it is required for the filesystem group to read the
DataDirectory.

Per the Tor documentation
https://2019.www.torproject.org/docs/tor-manual.html.en#DataDirectoryGroupReadable
"If this option is set to 0, don’t allow the filesystem group to read
the DataDirectory. If the option is set to 1, make the DataDirectory
readable by the default GID. (Default: 0)"
2023-04-07 12:31:58 -05:00
fanquake
db720b5a70
Merge : contrib: allow multi-sig binary verification v2
754fb6bb81 verifybinaries: fix argument type error pointed out by mypy (Cory Fields)
8a65e5145c verifybinaries: catch the correct exception (Cory Fields)
4b23b488d2 verifybinaries: fix OS download filter (Cory Fields)
8cdadd1729 verifybinaries: use recommended keyserver by default (Cory Fields)
4e0396835d verifybinaries: remove unreachable code (Cory Fields)
5668c6473a verifybinaries: Don't delete shasums file (Cory Fields)
46c73b57c6 verifybinaries: README cleanups (Cory Fields)
6d11830265 verifybinaries: remove awkward bitcoin-core prefix handling (Cory Fields)
c44323a717 verifybinaries: move all current examples to the pub subcommand (Cory Fields)
7a6e7ffd06 contrib: Use machine parseable GPG output in verifybinaries (Andrew Chow)
6b2cebfa2f contrib: Add verifybinaries command for specifying files to verify (Andrew Chow)
e4d5778228 contrib: Specify to GPG the SHA256SUMS file that is detached signed (Andrew Chow)
17575c0efa contrib: Refactor verifbinaries to support subcommands (Andrew Chow)
37c9fb7a59 contrib: verifybinaries: allow multisig verification (James O'Beirne)

Pull request description:

  Following up on  from jamesob with achow101's additional features on top.

  Both mentioned that they will be away for the next few weeks, so this is intended to keep review going.

  All credit to the jamesob and achow101. See  for the original description and [here](https://github.com/bitcoin/bitcoin/pull/23020#issuecomment-1480603300) for the added features.

  I squashed the last commit from https://github.com/achow101/bitcoin/tree/pr23020-direct-bins-gpg-parse into the first commit here.

  Fetching and local verification seem to work as intended for me.

ACKs for top commit:
  josibake:
    ACK 754fb6bb81

Tree-SHA512: b310c57518daa690a00126308a3e7e94b978ded56d13da15d5189e9e90b71c93888d854f64179150586b0a915db8dadd43c92b716613913c198128db8867257b
2023-04-07 08:26:45 +01:00
fanquake
d6c2a46a4b
Merge : ci: Run base install at most once
fa5af94de6 ci: Run base install at most once (MarcoFalke)

Pull request description:

  This should avoid errors when running it twice. For example, network errors on the second invocation of 'apt update'; or unguarded modifications such as APPEND_APT_SOURCES_LIST, which will append the same string repeatedly.

  The base install may be run twice in Cirrus CI with dockerfiles, or locally when running twice with DANGER_RUN_CI_ON_HOST specified.

ACKs for top commit:
  josibake:
    utACK fa5af94de6

Tree-SHA512: 020ba747e282076ddf10547025bb576ce626378d9f8313e09b1a5f99af1cf8237e44957aa4a0b8d64015bc730a090c83af0b3908a8eda15d3fb1ca7dae69dd7c
2023-04-07 08:14:08 +01:00
Cory Fields
754fb6bb81 verifybinaries: fix argument type error pointed out by mypy 2023-04-06 19:57:25 +00:00
Cory Fields
8a65e5145c verifybinaries: catch the correct exception 2023-04-06 19:57:25 +00:00
Cory Fields
4b23b488d2 verifybinaries: fix OS download filter
Co-authored-by: Reproducibility Matters <seb.kung@gmail.com>
2023-04-06 19:32:18 +00:00
Cory Fields
8cdadd1729 verifybinaries: use recommended keyserver by default 2023-04-06 19:32:18 +00:00
Cory Fields
4e0396835d verifybinaries: remove unreachable code 2023-04-06 19:32:18 +00:00
Cory Fields
5668c6473a verifybinaries: Don't delete shasums file
It may be useful for local validation.
2023-04-06 19:32:18 +00:00
Cory Fields
46c73b57c6 verifybinaries: README cleanups
- Use correct name for verify.py
- Add usage examples for verifybinaries bin
- Document proper use of new cleanup option
- Fixup broken example
2023-04-06 19:32:18 +00:00
Cory Fields
6d11830265 verifybinaries: remove awkward bitcoin-core prefix handling 2023-04-06 19:13:35 +00:00
Cory Fields
c44323a717 verifybinaries: move all current examples to the pub subcommand 2023-04-06 19:13:35 +00:00
stratospher
b5585ba5f9 p2p: skip netgroup diversity of new connections for tor/i2p/cjdns networks
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2023-04-07 00:13:15 +05:30
MarcoFalke
fa5af94de6
ci: Run base install at most once
This should avoid errors when running it twice. For example, network
errors on the second invocation of 'apt update'; or unguarded
modifications such as APPEND_APT_SOURCES_LIST, which will append the
same string repeatedly.

The base install may be run twice in Cirrus CI with dockerfiles, or
locally when running twice with DANGER_RUN_CI_ON_HOST specified.
2023-04-06 11:52:30 +02:00
fanquake
5a8bd45056
Merge : ci: fix git dubious permissions error
ed4a8339b8 ci: fix git dubious permissions error (josibake)

Pull request description:

  fixes https://github.com/bitcoin/bitcoin/pull/27376#issuecomment-1496449588

  this appears to be caused by a more recent version of git being sensitive to mismatched permissions on directories. we didn't notice this before because we were using two separate user accounts to fix up dir permissions in the container , but the second account was removed in 

  there might be a more elegant way to do this, but this does the trick and seems to be the way others are fixing this issue around the internets.

ACKs for top commit:
  RandyMcMillan:
    ACK ed4a833
  hebasto:
    re-ACK ed4a8339b8

Tree-SHA512: dad467deca101a24f3ed34b3e26a1db5099a5bd5c3e9c9a22771c59848f7d7e7843c7386348e6fdf86d5a556e4706e5e20005d7a6637193e1c8aef7a5ff7fb19
2023-04-06 10:04:01 +01:00
fanquake
06fb95b51b
Merge bitcoin/bitcoin#27335: Fixes compile errors in MSVC build
6a9a4d13b2 Fixes compile errors in MSVC build  (Ethan Heilman)

Pull request description:

  This PR is designed to address the issue https://github.com/bitcoin/bitcoin/issues/27332. The MSVC build is failing because of two bugs in how the build is configured.

  The issue
  ====

  When running `msbuild build_msvc\bitcoin.sln -property:Configuration=Release -maxCpuCount -verbosity:minima`l the build fails with following two errors.

  * `C:\Users\e0\Documents\GitHub\bitcoin\src\httpserver.cpp(637,9): error C2664: 'void evhttp_connection_get_peer(evhttp_connection *,const char **,uint16_t *)': cannot convert argument 2 from 'char **' to 'const char **' [C:\Users\e0\Documents\GitHub\bitcoin\build_msvc\libbitcoin_node\libbitcoin_node .vcxproj]`

  This error is occurs because bitcoin is using the wrong function signature for `evhttp_connection_get_peer` in libevent. In automake builds, configure.ac inspects the version of libevent it is building against and then defines `HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR` to flag the source code to use the correct signature. In MSVC build there does not appear to be a mechanism to do this. So it uses the wrong signature and fails. See the PR https://github.com/bitcoin/bitcoin/pull/23607 for when this logic was added to automake builds.

  * `event.lib(evutil_rand.c.obj) : error LNK2019: unresolved external symbol BCryptGenRandom referenced in function arc4_seed [C:\Users\e0\Documents\GitHub\bitcoin\build_msvc\bitcoin-cli\bitcoin-cli.vcxproj]
  C:\Users\e0\Documents\GitHub\bitcoin\build_msvc\x64\Release\bitcoin-cli.exe : fatal error LNK1120: 1 unresolved externals [C:\Users\e0\Documents\GitHub\bitcoin\build_msvc\bitcoin-cli\bitcoin-cli.vcxproj]`

  This error is caused by msbuild not being able to find the library bcrypt.lib because it has not been configured to use bcrypt.lib.

  Fixes
  ====

  While for automake builds a macro is being define to configure the current function signature for `evhttp_connection_get_peer` in libevent, this macro is not being defined for MSVC builds.

  1.  This PR addresses this issue by assuming more recent version of libevent is installed and always defining `HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR`. This logic is more brittle the automake logic, but someone following the MSVC build instructions should only get the more recent version of libevent.

  2. This PR fixes the bcrypt.lib errors this by setting this library as a dependency in build_msvc/common.init.vcxproj.in.

ACKs for top commit:
  hebasto:
    re-ACK 6a9a4d13b2

Tree-SHA512: 69d2cb6a62ecca976540a39e5f83a4e5386d920a564761cedc5127d82e5fa66ced7fcde3e5e5eb3bd6cde1cc78f843e94aa2789f02bd3e3414118030017d0387
2023-04-06 09:36:45 +01:00
Ethan Heilman
6a9a4d13b2 Fixes compile errors in MSVC build
+ Pins the compatible version of libevent in vcpkg
2023-04-05 16:49:53 -04:00
fanquake
04595484d9
Merge : ci: use clang-16 in tidy task
a56c96507a ci: use clang-16 in tidy task (fanquake)

Pull request description:

  Follow up to https://github.com/bitcoin/bitcoin/pull/27311#issuecomment-1481020371, as IWYU now has a [clang_16 branch](https://github.com/include-what-you-use/include-what-you-use/tree/clang_16).

  This also removes some workarounds for (now fixed) clang-tidy issues, and simplifies the IWYU install steps.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK a56c96507a
  josibake:
    ACK a56c96507a
  hebasto:
    ACK a56c96507a

Tree-SHA512: 5bbec6cc196c3305302895c77986f3695fc6f4024363ee57503654d54e0ebf108719a7a1d7908817f84115dcaa13377493eb764b00bdf574f1290c73251426fa
2023-04-05 14:03:01 +01:00