Commit Graph

106 Commits

Author SHA1 Message Date
tomFlowee 8e5809ddee Re-enable non-spv mode.
As we now follow the full ruleset of Bitcoin Cash again, we enable
normal validation rules for a full node again.
2026-05-15 10:53:24 +02:00
tomFlowee 0572486278 Move flag detection to before usage
As flags (like an upgrade being active) have been added in the codepath of
checks2 (contextualChecks), we need to make sure that we update the flags
to the current block just before we do that. So move this one up.
2026-05-15 09:19:57 +02:00
tomFlowee 519c76b149 Remove unused code 2026-05-15 09:19:57 +02:00
tomFlowee 6838d03e57 Fix op-mul activation 2026-05-15 00:03:09 +02:00
tomFlowee 7bb20aa818 Rename method to fix typo 2026-05-14 23:31:17 +02:00
tomFlowee cc4d9fb1f0 Rethrow exception of appropriate type 2026-05-14 23:31:17 +02:00
John Galt 12d94533dd init: recognize chipnet from the command line 2026-05-14 23:31:17 +02:00
John Galt db15db1354 core: accept legacy opcode aliases in script parser 2026-05-14 20:19:07 +02:00
John Galt 466d02a0e4 validation: apply May 2026 token commitment limit 2026-05-14 20:19:07 +02:00
John Galt 955b5642a7 policy: make post-Layla P2S standard 2026-05-14 20:19:07 +02:00
John Galt 1d463c68c8 script: charge signature hash iterations 2026-05-14 20:19:07 +02:00
John Galt 4f77768864 validation: activate May 2025 and 2026 script flags 2026-05-14 20:19:07 +02:00
tomFlowee 0d410b17d8 Change tx validation to default to on. 2026-05-14 15:21:44 +02:00
tomFlowee aa97cb2f3c Make logic cleaner. 2026-05-14 15:21:25 +02:00
tomFlowee ab318abac6 Remove unneeded checks
The checking usage prior to the activation makes no sense after we
already had activation.
2026-05-14 13:33:13 +02:00
tomFlowee 008eb35f95 Make compile faster
The IDE include checker got to the point where it is actually useful and
this removes a lot of unneeded includes.
Naturally, especially for headers like util.h, this may mean we need to
re-add includes in consuming cpp files that bloats the diff a bit.
2026-05-14 13:27:17 +02:00
tomFlowee 3bf765e2a3 Make sure we have access to Tx
Similar to the previous commit; make sure that the ValidationContext has
access to the new Tx format so new code can use it directly.

In practically all cases (outside of the unit tests) callers already had
a Tx instance. Making it just a matter of sending it with.

Notice that the Tx object is immutable and implicitly shared which makes
it cheaper to pass around.
2026-05-14 13:27:17 +02:00
tomFlowee 5451d1431b Make sure we have access to Tx
The MutableTransaction is only for creation,
the CTransaction is basically only there for backwards compatibility and
is kind of half deprecated.
The Tx class is to be used for all new code in validation.

The reason for this is because the CTransaction and friends are terribly
expensive to create and they have horrible effects on multi-threaded
validation.

So, to help this concept along we now pass both the old and the new tx
to a method that has not been ported to use the new yet. This at
least makes available the new Tx instance so when new code is written
it is easier to do the right thing (tm).
2026-05-14 13:27:17 +02:00
tomFlowee cd26dce4ed Cleanups
This rewrites one method to just use the iterator how it was meant
and it ends up saving a lot of CPU.
2026-05-14 13:27:17 +02:00
John Galt ad730f4d34 script: add CashToken introspection opcodes 2026-05-14 10:28:44 +02:00
John Galt a7f416ed68 validation: account CashToken NFTs 2026-05-14 10:28:44 +02:00
John Galt bdda379cc6 validation: account CashToken FT amounts 2026-05-14 10:28:44 +02:00
John Galt 056ceef245 validation: check CashToken input structure 2026-05-14 10:28:44 +02:00
John Galt 2af0af3641 validation: check CashToken output structure 2026-05-14 10:28:44 +02:00
John Galt 6f4c85570a primitives: fix indexed output lookup 2026-05-14 10:28:44 +02:00
tomFlowee b10f6ea2fb Merge UnspentOutputData classes
Two classes that were becoming very similar now are one.
2026-05-13 17:55:43 +02:00
tomFlowee 6996e56330 Cleanup includes 2026-05-13 17:55:03 +02:00
tomFlowee ced4f98beb Add token support to the Tx object
We add a Token class to Tx, which adds an easy to use API when compared
to the plain iterator. The main point of the API chosen is to make sure
we don't do unneeded parsing or copying for tokens unless needed.

Additionally refactor the ValidationPrivate::UnspentOutput class to
inherit from the Tx::Output class in order to avoid lots of duplicated
logic on handling the data.
2026-05-13 17:20:32 +02:00
tomFlowee 4ea0a66e9a Remove dead dns feed. 2026-05-12 17:12:22 +02:00
tomFlowee 562eba5b64 Make outscript usage shallow
The new SIGHASH_UTXO has a possible attack vector where prepared huge
outputs are used and required to be hashed for the signing preimage.
At most you can force the full node to prepare 20GB of (utxo) data
_prior_ to creation of the preimage. Which is a big issue when it comes
to memory usage of the node.
What this change does is we ensure that the class used for this data is
a ConstBuf as given to us from the utxo. Which are just pointers and not
full data, the data is memory mapped.
So we ensure shallow copies to avoid actually requiring the data to be
in memory until the point where it is used. And it can get swapped out
immediately after.

This ensures we are immune to the SIGHASH_UTXO attack vector.
2026-05-12 15:46:48 +02:00
tomFlowee 0aa874b621 Cleanups and fixes.
This fixes a surprising interaction of the utxo checks with the
script verify flag SCRIPT_VERIFY_STRICTENC.
2026-05-11 22:55:32 +02:00
John Galt d1f6296398 script: enable May 2023 SIGHASH_UTXOS 2026-05-09 23:52:30 +02:00
John Galt e2ad620969 script: enable May 2022 native introspection opcodes 2026-05-09 23:52:30 +02:00
tomFlowee 03a0e2d891 Cleanups 2026-05-08 23:52:03 +02:00
John Galt 3bb2e22859 validation: enforce May 2023 tx size and version rules 2026-05-08 23:22:28 +02:00
tomFlowee f1012f0797 Move classes out of public ones.
script.h is installed and part of the library 'flowee_utils', as such
it makes sense to move those new classes out of the ones seen by
downstream users.
2026-05-07 21:12:56 +02:00
tomFlowee cd317bc3c0 Cleanup p2sh32
The activation is past and there is no point in having a flag passed
through a dozen methods in order to detect when to enable it.
Because it is always enabled.
2026-05-07 16:15:26 +02:00
John Galt 96f036e78d script: enable Upgrade9 P2SH32 validation
Adds the SCRIPT_ENABLE_P2SH_32 script flag and applies it at the existing May 2023 activation point
2026-05-07 15:29:55 +02:00
John Galt 45b8369aaf add chipnet chain 2026-05-07 12:21:35 +02:00
tomFlowee b48aa63b58 Add booleans and block heights for upgrades. 2026-05-05 09:05:35 +02:00
tomFlowee f53daa79f6 Cleanup
This removes the transaction-signing code from the hub internal codebase.
The only user for this was the API call signrawtransaction,
and a lot of unit testing code.
I'd argue that if the user needs to send a private key to the hub via
RPC for signing his transaction, then they are doing it wrong.

This also removes the duplicate test double_spend which tests
functionality also tested in the DoubleSpendProofTest.

As an aside, the flowee/utils library still has full signing capability
and we suggest using the TransactionBuilder API for that.
2026-05-05 00:39:16 +02:00
tomFlowee 37f6039898 Remove unused include 2026-05-04 21:32:08 +02:00
tomFlowee 648f348c3a Apply best header to the header tip
This uses the header longest chain if that is longer than the fully
validated chain.
2026-05-04 21:32:08 +02:00
John Galt 26ee594ef5 validation: rescan live full-block arrivals 2026-05-04 21:31:35 +02:00
tomFlowee 25b91d9a48 Make this into a simple for loop
The usage of std::equal is tricky due to the lack of length
variable. This avoids any off-by-one issues.
2026-04-21 00:39:52 +02:00
tomFlowee c3e2f98b75 Remove expensive and not used ToString() methods.
The mining code still called that, this replaces it with standard
log lines that cost less at runtime and keeps the code that is
rarely run away from the shared parts.
2026-04-20 22:45:56 +02:00
tomFlowee 7db4a84bc3 Fix the way that orphan flushing is done.
Also use a faster container for fetching orphans.
2026-04-20 22:21:18 +02:00
tomFlowee f3dc67d3e1 Make faster. 2026-04-20 22:21:18 +02:00
tomFlowee 0a2e552168 Move more logic over to byte-array based Block
This introduces a new BlockHeader helper class which Block and
MutableBlock can both produce, which helps a lot of methods to
be ported to no longer be dependent on us using a MutableBlock
object, which is too costly to use when we have no intention
to alter the block.
2026-04-20 22:21:18 +02:00
tomFlowee 6cb1f97700 Move checking for space to the proper place. 2026-04-15 14:16:33 +02:00