Commit graph

441 commits

Author SHA1 Message Date
Sjors Provoost
ebb8215f23
Rename getTipHash() to getTip() and return BlockRef 2024-09-17 09:23:59 +02:00
Sjors Provoost
89a8f74bbb
refactor: rename BlockKey to BlockRef 2024-09-17 09:14:15 +02:00
Sjors Provoost
dd87b6dff3
Have createNewBlock return BlockTemplate interface
An external program that uses the Mining interface may need quick access to some information in the block template, while it can wait a bit longer for the full raw transaction data.

This would be the case for a Stratum v2 Template Provider which needs to send a NewTemplate message (which doesn't include transactions) as quickly as possible.
2024-09-13 10:14:53 +02:00
Russell Yanofsky
30073e6b3a multiprocess: Add -ipcbind option to bitcoin-node
Add `-ipcbind` option to `bitcoin-node` to listen on an IPC socket and accept
connections from other processes. In the future, there will be an `-ipcconnect`
option added to `bitcoin-wallet` and `bitcoin-node` to allow wallet and gui
processes to connect to the node and access it.

Example usage:

    src/bitcoin-node -regtest -debug -ipcbind=unix
    src/bitcoin-wallet -regtest -ipcconnect=unix info
    src/bitcoin-gui -regtest -ipcconnect=unix
    src/bitcoin-mine -regtest -ipcconnect=unix
2024-09-06 09:08:10 -04:00
Russell Yanofsky
955d4077aa multiprocess: Add IPC connectAddress and listenAddress methods
Allow listening on and connecting to unix sockets.
2024-09-06 09:08:10 -04:00
Ava Chow
27e89bc2f5
Merge bitcoin/bitcoin#26619: log: expand BCLog::LogFlags (categories) to 64 bits
b31a0cd037 log: expand BCLog::LogFlags (categories) to 64 bits (Larry Ruane)

Pull request description:

  Increase the maximum number of logging categories from 32 to 64.

  We're currently using 29 of the 32 available logging categories (there are only 3 remaining). It would be good to increase the limit soon; the fourth PR to be merged that adds a new logging category will be blocked until something like this is done.

  This PR also adds a `TEST` category that uses the new range (`1ULL << 63`) in case there's a hidden assumption somewhere that the `BCLog::LogFlags` type is 32 bits. (Also added a test for this test category.) It also provides an example showing that the expression must be `1ULL << <shift>` for shift value 31 and beyond.

ACKs for top commit:
  achow101:
    ACK b31a0cd037
  vasild:
    ACK b31a0cd037
  ryanofsky:
    Code review ACK b31a0cd037, just dropping mask_bit constant since last review. I still think
  theStack:
    Code-review ACK b31a0cd037

Tree-SHA512: de422dbeb479848d370aed42d415f42461457ab0eda62b245dc7ff9f0e111626e7d4c0d62ff13082ec664d05fbb0db04c71eb4b6f22eb8f19198826a67c4035e
2024-09-03 16:33:49 -04:00
ismaelsadeeq
1b41d45d46
wallet: bugfix: ensure atomicity in settings updates
- Settings updates were not thread-safe, as they were executed in
  three separate steps:

  1) Obtain settings value while acquiring the settings lock.
  2) Modify settings value.
  3) Overwrite settings value while acquiring the settings lock.

  This approach allowed concurrent threads to modify the same base value
  simultaneously, leading to data loss. When this occurred, the final
  settings state would only reflect the changes from the last thread
  that completed the operation, overwriting updates from other threads.

  Fix this by making the settings update operation atomic.

- Add test coverage for this behavior.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2024-08-26 13:41:56 +01:00
Larry Ruane
b31a0cd037 log: expand BCLog::LogFlags (categories) to 64 bits
This will increase the maximum number of logging categories
from 32 to 64.
2024-08-13 13:27:10 -06:00
Ava Chow
d56a450bf5 gui: Use wallet name for wallet migration rather than WalletModel
To prepare for migrating wallets that are not loaded, when migration
occurs in the GUI, it should not rely on a WalletModel existing.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2024-08-13 11:25:38 -04:00
Ava Chow
28fc562f26 wallet, interfaces: Include database format in listWalletDir 2024-08-13 11:25:38 -04:00
Hennadii Stepanov
ec8b38c7b9
Merge bitcoin-core/gui#626: Showing Local Addresses in Node Window
189c987386 Showing local addresses on the Node Window (Jadi)
a5d7aff867 net: Providing an interface for mapLocalHost (Jadi)

Pull request description:

  This change adds a new row to the Node Window (debugwindow.ui)
  under the Network section which shows the LocalAddresses.

  fixes #564

  <!--
  *** Please remove the following help text before submitting: ***

  Pull requests without a rationale and clear improvement may be closed
  immediately.

  GUI-related pull requests should be opened against
  https://github.com/bitcoin-core/gui
  first. See CONTRIBUTING.md
  -->

  <!--
  Please provide clear motivation for your patch and explain how it improves
  Bitcoin Core user experience or Bitcoin Core developer experience
  significantly:

  * Any test improvements or new tests that improve coverage are always welcome.
  * All other changes should have accompanying unit tests (see `src/test/`) or
    functional tests (see `test/`). Contributors should note which tests cover
    modified code. If no tests exist for a region of modified code, new tests
    should accompany the change.
  * Bug fixes are most welcome when they come with steps to reproduce or an
    explanation of the potential issue as well as reasoning for the way the bug
    was fixed.
  * Features are welcome, but might be rejected due to design or scope issues.
    If a feature is based on a lot of dependencies, contributors should first
    consider building the system outside of Bitcoin Core, if possible.
  * Refactoring changes are only accepted if they are required for a feature or
    bug fix or otherwise improve developer experience significantly. For example,
    most "code style" refactoring changes require a thorough explanation why they
    are useful, what downsides they have and why they *significantly* improve
    developer experience or avoid serious programming bugs. Note that code style
    is often a subjective matter. Unless they are explicitly mentioned to be
    preferred in the [developer notes](/doc/developer-notes.md), stylistic code
    changes are usually rejected.
  -->

  <!--
  Bitcoin Core has a thorough review process and even the most trivial change
  needs to pass a lot of eyes and requires non-zero or even substantial time
  effort to review. There is a huge lack of active reviewers on the project, so
  patches often sit for a long time.
  -->

ACKs for top commit:
  pablomartin4btc:
    re-ACK 189c987386
  furszy:
    utACK 189c987

Tree-SHA512: 93f201bc6d21d81b27b87be050a447b841f01e3efb69b9eca2cc7af103023d7cd69eb5e16e2875855573ef51a5bf74a6ee6028636c1b6798cb4bb11567cb4996
2024-08-02 14:19:02 +01:00
Jadi
a5d7aff867 net: Providing an interface for mapLocalHost
Contributes to #564 by providing an interface for mapLocalHost
through net -> node interface -> clientModel. Later this value can be
read by GUI to show the local addresses.
2024-08-02 10:40:33 +03:30
Sjors Provoost
6b4c817d4b
refactor: pass BlockCreateOptions to createNewBlock
Rather than pass options individually to createNewBlock and then
combining them into BlockAssembler::Options, this commit introduces
BlockCreateOptions and passes that instead.

Currently there's only one option (use_mempool) but the next
commit adds more.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2024-07-16 10:27:57 +02:00
Hennadii Stepanov
ff100bb549
Merge bitcoin-core/gui#825: Show maximum mempool size in information window
4a028cf54c gui: show maximum mempool size in information window (Sebastian Falbesoner)
bbde6ffefe add node interface method for getting maximum mempool size (Sebastian Falbesoner)

Pull request description:

  This PR adds the maximum mempool size to the information window (Menu "Window" -> "Information" -> section "Memory Pool" -> line "Memory usage").

  master:

  ![image](https://github.com/bitcoin-core/gui/assets/91535/157e92f5-7d06-4303-b4ef-bcdfac5527e3)

  PR:

  ![image](https://github.com/bitcoin-core/gui/assets/91535/796322aa-9f16-4b09-9893-bf52a3898a5c)

ACKs for top commit:
  MarnixCroes:
    tested ACK 4a028cf54c
  pablomartin4btc:
    tACK 4a028cf54c
  luke-jr:
    tACK 4a028cf54c & in Knots
  hebasto:
    ACK 4a028cf54c, tested on Ubuntu 24.04.

Tree-SHA512: c10fb23605d060cea19a86d11822fc4d12496b19547870052aace503670e62e4c4e19ae4c2c4fbf7420a472adb071c9ddebe82447e0cfbce5a6fb9fcd7b9eda3
2024-07-14 13:07:44 +01:00
MarcoFalke
3333bae9b2
tidy: modernize-use-equals-default 2024-07-08 11:12:01 +02:00
Sjors Provoost
a74b0f93ef
Have testBlockValidity hold cs_main instead of caller
The goal of interfaces is to eventually run in their own process,
so we can't use EXCLUSIVE_LOCKS_REQUIRED in their declaration.

However TestBlockValidaty will crash (in its call to ConnectBlock)
if the tip changes from under the proposed block.

Have the testBlockValidity implementation  hold the lock instead,
and non-fatally check for this condition.
2024-06-27 08:58:25 +02:00
Sjors Provoost
75ce7637ad
refactor: testBlockValidity make out argument last 2024-06-26 12:24:48 +02:00
Sjors Provoost
83a9bef0e2
Add missing include for mining interface
Needed for std::unique_ptr
2024-06-26 12:24:47 +02:00
Sebastian Falbesoner
bbde6ffefe add node interface method for getting maximum mempool size 2024-06-20 17:43:37 +02:00
Sjors Provoost
a9716c53f0
rpc: call IsInitialBlockDownload via miner interface 2024-06-18 21:07:51 +02:00
Sjors Provoost
dda0b0834f
rpc: minize getTipHash() calls in gbt
Set tip at the start of the function and only update it for a long poll.

Additionally have getTipHash return an optional, so the
caller can explicitly check that a tip exists.
2024-06-18 18:47:52 +02:00
Sjors Provoost
7b4d3249ce
rpc: call processNewBlock via miner interface 2024-06-18 18:47:52 +02:00
Sjors Provoost
9e228351e7
rpc: getTransactionsUpdated via miner interface 2024-06-18 18:47:52 +02:00
Sjors Provoost
4bf2e361da
rpc: call CreateNewBlock via miner interface 2024-06-18 18:47:51 +02:00
Sjors Provoost
404b01c436
rpc: getblocktemplate getTipHash() via Miner interface 2024-06-18 18:47:51 +02:00
Sjors Provoost
d8a3496b5a
rpc: call TestBlockValidity via miner interface 2024-06-18 18:47:51 +02:00
Sjors Provoost
8ecb681678
Introduce Mining interface
Start out with a single method isTestChain() that's used by the getblocktemplate RPC.
2024-06-18 18:47:51 +02:00
Ryan Ofsky
4d05d3f3b4 util: add TransactionError includes and namespace declarations
Add TransactionError to node namespace and include it directly instead of
relying on indirect include through common/messages.h

This is a followup to a previous commit which moved the TransactionError enum.
These changes were done in a separate followup just to keep the previous commit
more minimal and easy to review.
2024-05-16 10:16:08 -05:00
Ryan Ofsky
02e62c6c9a common: Add PSBTError enum
Add separate PSBTError enum instead of reusing TransactionError enum for PSBT
operations, and drop unused error codes. The error codes returned by PSBT
operations and transaction broadcast functions mostly do not overlap, so using
an unified enum makes it harder to call any of these functions and know which
errors actually need to be handled.

Define PSBTError in the common library because PSBT functionality is
implemented in the common library and used by both the node (for rawtransaction
RPCs) and the wallet.
2024-05-16 10:16:08 -05:00
Ryan Ofsky
6861f954f8 util: move util/message to common/signmessage
Move util/message to common/signmessage so it is named more clearly, and
because the util library is not supposed to depend on other libraries besides
the crypto library. The signmessage functions use CKey, CPubKey, PKHash, and
DecodeDestination functions in the consensus and common libraries.
2024-05-16 11:16:08 -04:00
Sjors Provoost
4357158c47
wallet: return and display signer error
Both RPC and GUI now render a useful error message instead of (silently) failing.

Replace bool with util::Result<void> to clarify that this either succeeds or returns an error message.
2024-04-16 17:47:43 +02:00
fanquake
143ace65db
Merge bitcoin/bitcoin#28890: rpc: Remove deprecated -rpcserialversion
fa46cc22bc Remove deprecated -rpcserialversion (MarcoFalke)

Pull request description:

  The flag is problematic for many reasons:

  * It is deprecated
  * It is a global flag, requiring a restart to change, as opposed to a flag that can be set on each RPC invocation
  * It may be hidden in config files by accident, hard to debug, causing LND crashes and bugs, see https://github.com/bitcoin/bitcoin/issues/28730#issuecomment-1780940868
  * It makes performance improvements harder to implement: https://github.com/bitcoin/bitcoin/pull/17529#issuecomment-556082818

  Fix all issues by removing it.

  If there is a use-case, likely a per-RPC flag can be added, if needed.

ACKs for top commit:
  ajtowns:
    crACK fa46cc22bc
  TheCharlatan:
    lgtm ACK fa46cc22bc

Tree-SHA512: 96ba1c60356ce93954fe5c2a59045771c6d1516ad0d9dc436ef1800a1f1b0153f0d5fb78ca99d53ad54ba25fbce36962bdf1d4325aceedfc8154a61347a6a915
2024-01-05 10:42:10 +00:00
ismaelsadeeq
8dec9c560b wallet, mempool: propagete checkChainLimits error message to wallet
Update CheckPackageLimits to use util::Result to pass the error message
instead of out parameter.

Also update test to reflect the error message from `CTxMempool`
`CheckPackageLimits` output.
2023-12-17 21:13:44 +01:00
MarcoFalke
fa46cc22bc
Remove deprecated -rpcserialversion 2023-12-11 18:22:13 +01:00
Anthony Towns
6e9e4e6130 Use ParamsWrapper for witness serialization 2023-11-14 08:45:30 +10:00
Ryan Ofsky
441d00c60f interfaces: Rename CalculateBumpFees methods to be compatible with capn'proto 2023-10-20 10:30:16 -04:00
Ryan Ofsky
156f49d682 interfaces: Change getUnspentOutput return type to avoid multiprocess segfault
Coin serialize method segfaults if IsSpent condition is true. This caused
multiprocess code to segfault when serializing the Coin& output argument to of
the Node::getUnspentOutput method if the coin was not found. Segfault could be
triggered by double clicking and viewing transaction details in the GUI
transaction list.

Fix this by replacing Coin& output argument with optional<Coin> return value to
avoid trying to serializing spent coins.
2023-10-20 10:30:16 -04:00
Ryan Ofsky
4978754c00 interfaces: Add schedulerMockForward method so mockscheduler RPC can work across processes
Needed to fix new wallet_groups.py and wallet_resendwallettransactions.py tests
with multiprocess bitcoin-node executable.
2023-10-20 10:30:16 -04:00
Ryan Ofsky
924327eaf3 interfaces: Fix const virtual method that breaks multiprocess support 2023-10-20 10:30:16 -04:00
James O'Beirne
4d8f4dcb45 validation: pass ChainstateRole for validationinterface calls
This allows consumers to decide how to handle events from background or
assumedvalid chainstates.
2023-09-30 06:38:47 -04:00
Hennadii Stepanov
b000ed5ee5
Merge bitcoin-core/gui#119: Replace send-to-self with dual send+receive entries
099dbe4224 GUI: TransactionRecord: When time/index/etc match, sort send before receive (Luke Dashjr)
2d182f77cd Bugfix: Ignore ischange flag when we're not the sender (Luke Dashjr)
71fbdb7f40 GUI: Remove SendToSelf TransactionRecord type (Luke Dashjr)
f3fbe99fcf GUI: TransactionRecord: Refactor to turn send-to-self into send+receive pairs (Luke Dashjr)
b9765ba1d6 GUI: TransactionRecord: Use "any from me" as the criteria for deciding whether a transaction is a send or receive (Luke Dashjr)

Pull request description:

  Makes the GUI transaction list more like the RPC, and IMO clearer in general.

  As a side effect, this also fixes the GUI entries when a transaction is a net profit to us, but some inputs were also from us.

  Originally https://github.com/bitcoin/bitcoin/pull/15115

  Has Concept ACKs from @*Empact @*jonasschnelli

ACKs for top commit:
  hebasto:
    ACK 099dbe4224.

Tree-SHA512: 7d581add2f59431aa019126d54232a1f15723def5147d7a1b672e9b6d525b6e5a944cc437701aa1bd5bd0fbe557a3d1f4b239337f42bdba4fe1d3960442d0e3b
2023-09-22 18:29:51 +01:00
Hennadii Stepanov
1d4846a844
Merge bitcoin-core/gui#738: Add menu option to migrate a wallet
48aae2cffe gui: Add File > Migrate Wallet (Andrew Chow)
577be889cd gui: Optionally return passphrase after unlocking (Andrew Chow)
5b3a85b4c6 interfaces, wallet: Expose migrate wallet (Andrew Chow)

Pull request description:

  GUI users need to be able to migrate wallets without going to the RPC console.

ACKs for top commit:
  jarolrod:
    ACK 48aae2cffe
  pablomartin4btc:
    tACK 48aae2cffe
  hebasto:
    ACK 48aae2cffe

Tree-SHA512: 2d02b1e85e7d6cfbf503f417f150cdaa0c63822942e9a6fe28c0ad3e7f40a957bb01a375c909a60432dc600e84574881aa446c7ec983b56f0bb23f07ef15de54
2023-09-20 22:32:31 +01:00
glozow
c57889da66
[node] interface to get bump fees 2023-09-13 14:33:55 -04:00
Andrew Chow
7a172c76d2 Move CTxDestination to its own file
CTxDestination is really our internal representation of an address and
doesn't really have anything to do with standard script types, so move
them to their own file.
2023-08-14 17:38:27 -04:00
Andrew Chow
86ea8bed54 Move CScriptID to script.{h/cpp}
CScriptID should be next to CScript just as CKeyID is next to CPubKey
2023-08-14 17:38:27 -04:00
Luke Dashjr
f3fbe99fcf GUI: TransactionRecord: Refactor to turn send-to-self into send+receive pairs 2023-06-23 02:05:24 +00:00
Andrew Chow
5b3a85b4c6 interfaces, wallet: Expose migrate wallet 2023-06-13 19:00:58 -04:00
Ryan Ofsky
c92fd63886
Merge bitcoin/bitcoin#27708: Return EXIT_FAILURE on post-init fatal errors
61c569ab60 refactor: decouple early return commands from AppInit (furszy)
4927167f85 gui: return EXIT_FAILURE on post-init fatal errors (furszy)
3b2c61e819 Return EXIT_FAILURE on post-init fatal errors (furszy)
3c06926cf2 refactor: index: use `AbortNode` in fatal error helper (Sebastian Falbesoner)
9ddf7e03a3 move ThreadImport ABC error to use AbortNode (furszy)

Pull request description:

  It seems odd to return `EXIT_SUCCESS` when the node aborted execution due a fatal internal error
  or any post-init problem that triggers an unrequested shutdown.

  e.g. blocks or coins db I/O errors, disconnect block failure, failure during thread import (external
  blocks loading process error), among others.

ACKs for top commit:
  TheCharlatan:
    ACK 61c569ab60
  ryanofsky:
    Code review ACK 61c569ab60
  pinheadmz:
    ACK 61c569ab60
  theStack:
    Code-review ACK 61c569ab60

Tree-SHA512: 18a59c3acc1c6d12cbc74a20a401e89659740c6477fccb59070c9f97922dfe588468e9e5eef56c5f395762187c34179a5e3954aa5b844787fa13da2e666c63d3
2023-06-12 12:54:49 -04:00
furszy
4927167f85
gui: return EXIT_FAILURE on post-init fatal errors 2023-06-10 11:10:29 -03:00
TheCharlatan
db77f87c63
scripted-diff: move settings to common namespace
-BEGIN VERIFY SCRIPT-
sed -i 's/namespace\ util/namespace\ common/g' src/common/settings.cpp src/common/settings.h
sed -i 's/util\:\:GetSetting/common\:\:GetSetting/g' $( git grep -l 'util\:\:GetSetting')
sed -i 's/util\:\:Setting/common\:\:Setting/g' $( git grep -l 'util\:\:Setting')
sed -i 's/util\:\:FindKey/common\:\:FindKey/g' $( git grep -l 'util\:\:FindKey')
sed -i 's/util\:\:ReadSettings/common\:\:ReadSettings/g' $( git grep -l 'util\:\:ReadSettings')
sed -i 's/util\:\:WriteSettings/common\:\:WriteSettings/g' $( git grep -l 'util\:\:WriteSettings')
-END VERIFY SCRIPT-
2023-05-30 17:26:51 +02:00