Commit graph

23982 commits

Author SHA1 Message Date
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
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
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
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
fanquake
04595484d9
Merge bitcoin/bitcoin#27404: 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
furszy
25ab14712b
refactor: coinselector_tests, unify wallet creation code
same lines of code repeated across the entire file over and over.
2023-04-05 09:32:39 -03:00
furszy
ba9431c505
test: coverage for bnb max weight
Basic positive and negative scenarios
2023-04-05 09:32:39 -03:00
furszy
5a2bc45ee0
wallet: clean post coin selection max weight filter
Now the coin selection algorithms contemplate the
maximum allowed weight internally and return
std::nullopt if their result exceeds it.
2023-04-05 09:32:39 -03:00
furszy
2d112584e3
coin selection: BnB, don't return selection if exceeds max allowed tx weight 2023-04-05 09:32:39 -03:00
furszy
d3a1c098e4
test: coin selection, add coverage for SRD 2023-04-05 09:32:39 -03:00
furszy
9d9689e5a6
coin selection: heap-ify SRD, don't return selection if exceeds max tx weight
Uses a min-effective-value heap, so we can remove the least valuable input/s
while the selected weight exceeds the maximum allowed weight.

Co-authored-by: Murch <murch@murch.one>
2023-04-05 09:32:39 -03:00
furszy
6107ec2229
coin selection: knapsack, select closest UTXO above target if result exceeds max tx size
The simplest scenario where this is useful is on the 'check_max_weight' unit test
already:

We create 1515 UTXOs with 0.033 BTC each, and 1 UTXO with 50 BTC. Then perform
Coin Selection.

As the selection of the 1515 small UTXOs exceeds the max allowed tx size, the
expectation here is to receive a selection result that only contain the big
UTXO (which is not happening for the reasons stated below).

As knapsack returns a result that exceeds the max allowed transaction size, we
fallback to SRD, which selects coins randomly up until the target is met. So
we end up with a selection result with lot more coins than what is needed.
2023-04-05 09:32:39 -03:00
fanquake
27ad26de2f
Merge bitcoin/bitcoin#27317: log: Check that the timestamp string is non-empty to avoid undefined behavior
73f4eb511c Check that the Timestamp String is valid (John Moffett)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/27233

  The current `FormatISO8601DateTime` function will return an empty string if it encounters an error when converting the `int64_t` seconds-since-epoch to a formatted date time. In the unlikely case that happens, here `strStamped.pop_back()` would be undefined behavior.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 73f4eb511c
  stickies-v:
    ACK 73f4eb511c

Tree-SHA512: 089ed639c193deb98870a8385039b31b4baed821ea907937bfc6f65a5b0981bbf8284b2afec81b2d0a922e2340716b48cf55349640eb6b8c311ef7af25abc361
2023-04-05 11:50:27 +01:00
fanquake
a56c96507a
ci: use clang-16 in tidy task 2023-04-05 11:43:42 +01:00
brunoerg
0076bed45e logging: log ASN when using -asmap
When using `-asmap`, it will log the ASN from the peer on some logs (e.g. when a new outbound peer has been connected).
2023-04-04 16:53:25 -03:00
furszy
68eed5df86
test,gui: add coverage for PSBT creation on legacy watch-only wallets 2023-04-03 17:23:43 -03:00
furszy
306aab5bb4
test,gui: decouple widgets and model into a MiniGui struct
So it can be reused across tests.
2023-04-03 17:23:43 -03:00
furszy
2f76ac0383
test,gui: decouple chain and wallet initialization from test case
Prepare ground for legacy watch-only test.
2023-04-03 17:23:43 -03:00
furszy
cd98b71739
gui: 'getAvailableBalance', include watch only balance
Only for wallets with private keys disabled.

The returned amount need to include the watch-only
available balance too.

Solves #26687.
2023-04-03 17:23:43 -03:00
furszy
74eac3a82f
test: add coverage for 'useAvailableBalance' functionality
The following cases were covered:

Case 1: No coin control selected coins.
  - 'useAvailableBalance' should fill the amount edit box with the total available balance.

Case 2: With coin control selected coins.
  - 'useAvailableBalance' should fill the amount edit box with the sum of the selected coins values.
2023-04-03 17:23:42 -03:00
furszy
dc1cc1c359
gui: bugfix, getAvailableBalance skips selected coins
The previous behavior for getAvailableBalance when coin control
has 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.

This turns into a GUI-only issue for the "use available balance"
button when the user manually select coins in the send screen.

Reason:
We missed to update the GetAvailableBalance function to include
the coin control selected coins on #25685.

Context:
Since #25685 we skip the selected coins inside `AvailableCoins`,
the reason is that there is no need to traverse the wallet's
txes map just to get coins that can directly be fetched by
their id.
2023-04-03 17:23:42 -03:00
brunoerg
9836c76ae0 net: add GetMappedAS in CConnman 2023-04-03 15:42:15 -03:00
fanquake
54e4061189
refactor: don't avoid sys/types.h on when building for Windows
We've already used it unguarded in `httpserver.cpp` for years, with no
build issues.
2023-04-03 14:44:48 +01:00
fanquake
369d4c03b7
Merge bitcoin/bitcoin#27254: refactor: Extract util/fs from util/system
00e9b97f37 refactor: Move fs.* to util/fs.* (TheCharlatan)
106b46d9d2 Add missing fs.h includes (TheCharlatan)
b202b3dd63 Add missing cstddef include in assumptions.h (TheCharlatan)
18fb36367a refactor: Extract util/fs_helpers from util/system (Ben Woosley)

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". This commit was originally authored by empact and is taken from its parent PR #25152.

  #### Context

  There is an ongoing effort to decouple the `ArgsManager` used for command line parsing user-provided arguments from the libbitcoinkernel library (https://github.com/bitcoin/bitcoin/pull/25290, https://github.com/bitcoin/bitcoin/pull/25487, https://github.com/bitcoin/bitcoin/pull/25527, https://github.com/bitcoin/bitcoin/pull/25862, https://github.com/bitcoin/bitcoin/pull/26177, and https://github.com/bitcoin/bitcoin/pull/27125). The `ArgsManager` is defined in `system.h`. A similar pull request extracting functionality from `system.h` has been merged in https://github.com/bitcoin/bitcoin/pull/27238.

  #### Changes

  Next to providing better code organization, this PR removes some reliance of the tree of libbitcoinkernel header includes on `system.h` (and thus the `ArgsManager` definition) by moving filesystem related functions out of the `system.*` files.

  There is already a pair of `fs.h` / `fs.cpp` in the top-level `src/` directory. They were not combined with the files introduced here, to keep the patch cleaner and more importantly because they are often included without the utility functions. The new files are therefore named `fs_helpers` and the existing `fs` files are moved into the util directory.

  Further commits splitting more functionality out of `system.h` are still in #25152 and will be submitted in separate PRs once this PR has been processed.

ACKs for top commit:
  hebasto:
    ACK 00e9b97f37

Tree-SHA512: 31422f148d14ba3c843b99b1550a6fd77c77f350905ca324f93d4f97b652246bc58fa9696c64d1201979cf88733e40be02d262739bb7d417cf22bf506fdb7666
2023-04-03 14:41:22 +01:00
fanquake
5150e28010
Merge bitcoin/bitcoin#27382: miniscript: explicit cast instead of comparing integers of different signs
9a54d88c8c miniscript: explicit cast instead of comparing integers of different signs (Antoine Poinsot)

Pull request description:

  Fixes #27381

ACKs for top commit:
  stickies-v:
    ACK 9a54d88c8c

Tree-SHA512: beba35ecf3325b3b0e87f3288af4522de455c2983f7f6dd64a34a1636e351afcd1e00d249dfe2b3cde4f65254d62b610daaebfbda4e4af76f1fef4dd168c631d
2023-04-02 13:06:10 +01:00
fanquake
8e9e2b4cb3
Merge bitcoin/bitcoin#27379: net processing: #26140 follow-ups
3fa4c54ac5 [net processing] Pass TxRelay to FindTxForGetData instead of Peer (dergoegge)
c85ee76a36 [net processin] Don't take cs_main in FindTxForGetData (dergoegge)

Pull request description:

  Addresses left over feedback from #26140.

  * https://github.com/bitcoin/bitcoin/pull/26140#discussion_r1153498543
  * https://github.com/bitcoin/bitcoin/pull/26140#discussion_r1153499627

  `mapRelay` is only accessed from the message processing thread and does not need to be kept in sync with anything validation specific, it is therfore perfectly fine to have it guarded by `g_msgproc_mutex`.

ACKs for top commit:
  jnewbery:
    utACK 3fa4c54ac5
  hebasto:
    ACK 3fa4c54ac5, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 3ef84bfe4abfa8d991a7e65d9184221294d80e0df0bbb47f0270ab6ca1593266c98abf83c610f9f86b4d16c7a4b62bcf83f8856c68d3c2e10894bff6ed3e88cd
2023-04-02 12:42:06 +01:00
Hennadii Stepanov
bc49a477de
Merge bitcoin-core/gui#724: Update translation source file for v25.0 string freeze
e414edd8fc qt: Update translation source file (Hennadii Stepanov)
b780095091 qt: Adjust plural forms for translations (Hennadii Stepanov)
6ae8a24009 GUI: Send: Make feerates translatable (Luke Dashjr)
bd42f5e1cd Bugfix: GUI: Send/PSBT: Correct virtual size unit and make translatable (Luke Dashjr)
1b0407f5f1 Bugfix: GUI: transactiondesc: Translate outlier "own address" and "watch-only" (Luke Dashjr)
170f3126f2 GUI: Use translated external signer errors for messagebox text (Luke Dashjr)
96989599d6 GUI: Make messages for copying unsigned PSBTs translatable (Luke Dashjr)
08b8b287d3 Bugfix: GUI: Debug info: Use correct "kB" case for small mempool sizes, and make translation-friendly (Luke Dashjr)
dacc322be1 GUI: PSBTOperationsDialog: Support translating window title (Luke Dashjr)
5a4fe55270 GUI: Intro: Support translating caption of data directory chooser (Luke Dashjr)
3868ba3a27 GUI: Support translating peer network names (Luke Dashjr)
f1f9811198 GUI: Support translating address type dropdown entries (Luke Dashjr)

Pull request description:

  This PR updates the `src/qt/locale/bitcoin_en.xlf` translation source file according to [Release schedule for 25.0](https://github.com/bitcoin/bitcoin/issues/26549).

  Some translation-related fixes have been picked from https://github.com/bitcoin-core/gui/pull/599 and https://github.com/bitcoin-core/gui/pull/716.

  Note for reviewers: it is expected to get a zero diff after running `make -C src translate` locally.

ACKs for top commit:
  jarolrod:
    ACK e414edd8fc

Tree-SHA512: 5b0c70db1e2f5871067e84f43ebea4ee4f0027fc5f2be49bbcb1d04e162ae76607b2b038e9d0622bcb5b3658d0ede8c10c4421ddaa3343f0e0be54315ca7a4f5
2023-04-01 22:05:37 +01:00
fanquake
a0d37d1d23
Merge bitcoin/bitcoin#27274: refactor: remove unused param from legacy pubkey interface
1869310f3c refactor: remove unused param from legacy pubkey (Bushstar)

Pull request description:

  Unused param present in legacy pubkey manager interface. This param will not be used and should be removed to prevent unintended usage.

ACKs for top commit:
  Sjors:
    ACK 1869310f3c
  furszy:
    ACK 1869310f3c

Tree-SHA512: 0fb41fc8f481f859262f2e8e9a93c990c1b4637e74fd9191ccc0b3c523d0e7d94217a3074bb357276e1941a10d29326f850f9b27eccc1eca57cf6b549353400c
2023-03-31 17:03:32 +01:00
Antoine Poinsot
9a54d88c8c
miniscript: explicit cast instead of comparing integers of different signs 2023-03-31 17:27:19 +02:00
Hennadii Stepanov
e414edd8fc
qt: Update translation source file
The diff is produced by running `make -C src translate`.
2023-03-31 12:23:03 +01:00
Hennadii Stepanov
b780095091
qt: Adjust plural forms for translations 2023-03-31 12:22:50 +01:00
Luke Dashjr
6ae8a24009
GUI: Send: Make feerates translatable 2023-03-31 12:22:21 +01:00
Luke Dashjr
bd42f5e1cd
Bugfix: GUI: Send/PSBT: Correct virtual size unit and make translatable 2023-03-31 12:22:16 +01:00
Luke Dashjr
1b0407f5f1
Bugfix: GUI: transactiondesc: Translate outlier "own address" and "watch-only" 2023-03-31 12:22:11 +01:00
Luke Dashjr
170f3126f2
GUI: Use translated external signer errors for messagebox text 2023-03-31 12:22:05 +01:00
Luke Dashjr
96989599d6
GUI: Make messages for copying unsigned PSBTs translatable 2023-03-31 12:22:00 +01:00
Luke Dashjr
08b8b287d3
Bugfix: GUI: Debug info: Use correct "kB" case for small mempool sizes, and make translation-friendly 2023-03-31 12:21:51 +01:00
Luke Dashjr
dacc322be1
GUI: PSBTOperationsDialog: Support translating window title 2023-03-31 12:21:42 +01:00
Luke Dashjr
5a4fe55270
GUI: Intro: Support translating caption of data directory chooser 2023-03-31 12:21:35 +01:00
Luke Dashjr
3868ba3a27
GUI: Support translating peer network names 2023-03-31 12:21:23 +01:00
Luke Dashjr
f1f9811198
GUI: Support translating address type dropdown entries 2023-03-31 12:21:11 +01:00
dergoegge
3fa4c54ac5 [net processing] Pass TxRelay to FindTxForGetData instead of Peer 2023-03-31 13:19:20 +02:00
dergoegge
c85ee76a36 [net processin] Don't take cs_main in FindTxForGetData
Taking cs_main is no longer necessary since we moved
`m_recently_announced_invs` to `Peer` and `mapRelay` is actually only
accessed from the message processing thread.
2023-03-31 13:18:39 +02:00
dergoegge
3a060ae7b6 scripted-diff: Rename nUnconnectingHeaders and fPreferHeaders
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren nUnconnectingHeaders     m_num_unconnecting_headers_msgs
ren fPreferHeaders           m_prefers_headers
ren MAX_UNCONNECTING_HEADERS MAX_NUM_UNCONNECTING_HEADERS_MSGS

-END VERIFY SCRIPT-
2023-03-30 14:56:34 +02:00
dergoegge
279c53d7e4 [net processing] Move m_recently_announced_invs from CNodeState to Peer 2023-03-30 14:56:19 +02:00
dergoegge
938a8e2566 [net processing] Annotate m_recently_announced_invs as guarded by g_msgproc_mutex 2023-03-30 14:56:19 +02:00
dergoegge
8a2cb1f749 [net processing] Move fPreferHeaders from CNodeState to Peer 2023-03-30 14:56:19 +02:00
dergoegge
3605011e79 [net processing] Annotate fPreferHeaders as guarded by g_msgproc_mutex 2023-03-30 14:56:19 +02:00