414 Commits

Author SHA1 Message Date
John Galt 0e8d31aafd networkmanager: catch queued send failures 2026-05-19 19:03:35 +02:00
John Galt 2a07f278b2 networkmanager: validate legacy p2p envelopes 2026-05-19 18:09:19 +02:00
John Galt c9e805195a networkmanager: bound native parser to packet 2026-05-19 17:44:04 +02:00
tomFlowee b00297da37 Remove broken tests. 2026-05-19 17:44:04 +02:00
John Galt 1713c8f940 networkmanager: reject short native packets 2026-05-19 10:22:58 +02:00
John Galt 79b389caf6 networkmanager: keep ring buffer full state distinct 2026-05-19 10:22:58 +02:00
John Galt 5282a24901 dsproof: bound pushdata while loading proofs 2026-05-19 10:22:58 +02:00
John Galt 4bae804db1 serialize: reject oversized CompactSize collection counts 2026-05-19 10:22:58 +02:00
John Galt 251107d457 streaming: reject invalid P2P parser byte counts 2026-05-19 10:22:58 +02:00
tomFlowee 0ae11a2bfc Fix test after moving bigint activation
Since we activated op-mul at the 64-bit upgrade date, this test
now follows this idea.
2026-05-17 13:10:22 +02:00
tomFlowee 467ec72e36 Remove scripts that are no longer invalid. 2026-05-17 13:05:16 +02:00
John Galt aadc7c0f5a script: include token prefix in forkid signing preimage 2026-05-14 21:28:31 +02:00
John Galt 3a7b716706 tests: cover post-Layla standardness and token commitments 2026-05-14 20:19:07 +02:00
John Galt 4b6f00a514 tests: cover May 2025 and 2026 VM rules 2026-05-14 20:19:07 +02:00
John Galt 99c81869ed script: let malformed multisig fall through to P2S 2026-05-14 20:19:07 +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 455db5d126 tests: expand CashTokens coverage 2026-05-14 10:28:44 +02:00
John Galt ad730f4d34 script: add CashToken introspection opcodes 2026-05-14 10:28:44 +02:00
John Galt 078ba3a49c script: hash token prefixes in SIGHASH_UTXOS 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 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 d27026027f Cleanup includes. 2026-05-13 16:35:51 +02:00
tomFlowee b8840e159c Cleanup test
This turns the code into readable data-driven test cases.
2026-05-12 16:23:25 +02:00
tomFlowee 8cfdc3c79c Cleanup test
Unit tests should keep using simple and readable code. Verbose is better
than hard to follow.
2026-05-12 16:07:59 +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 66b047853d Cleanup unit test 2026-05-12 00:11:54 +02:00
John Galt d1f6296398 script: enable May 2023 SIGHASH_UTXOS 2026-05-09 23:52:30 +02:00
tomFlowee 3e0195509e make compile 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 34fbdd38f6 Remove unneeded line of code. 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 0c59b0a70f Add constructor test 2026-05-08 22:53:38 +02:00
tomFlowee 078544445f Add testset for big int.
Imported json from our friends over at bchn.
2026-05-08 22:16:46 +02:00
tomFlowee 764e9d166c Rename tests to be nicer. 2026-05-07 22:10:35 +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
John Galt de512b9edb Import BigInt protocol upgrade 2026-05-07 17:51:05 +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
tomFlowee 2a53899909 Print message before failing. 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
John Galt d6c9886071 Avoid incorrectly detecting an error
This checks only the data inside of the leaf.
2026-05-04 21:48:45 +02:00