31 Commits

Author SHA1 Message Date
tomFlowee 6838d03e57 Fix op-mul activation 2026-05-15 00:03:09 +02:00
John Galt aadc7c0f5a script: include token prefix in forkid signing preimage 2026-05-14 21:28:31 +02:00
John Galt eb07e94a3c script: implement May 2026 loops 2026-05-14 20:19:07 +02:00
John Galt f473edf652 script: implement May 2026 functions 2026-05-14 20:19:07 +02:00
John Galt 6b288766ad script: split eval context for May 2026 frames 2026-05-14 20:19:07 +02:00
John Galt 9cd8f7908f script: implement May 2026 bitwise shifts 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 1751c3f14b script: enforce May 2025 VM accounting limits 2026-05-14 20:19:07 +02:00
tomFlowee a5505f66c7 Avoid confusion with bigint1 and bigint2 2026-05-14 15:30:23 +02:00
tomFlowee d3948cb5e9 Avoid expensive conversion. 2026-05-14 13:34:48 +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
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
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 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 4a12e4885f Use new math in interpreter, regardless of flags.
This avoids overhead for a case that never happens.
2026-05-07 21:40:25 +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 29069b5aa3 Fix error in tests. 2026-04-09 20:01:58 +02:00
tomFlowee 64fa922605 fix whitespace 2024-02-12 21:16:55 +01:00
tomFlowee fce11e8d4f Rename file to match class it is in.
This follows the coding style guideline that the file that contains a
class should follow the exact name of this (main) class.

pubkey.{h|cpp} -> PublicKey.{h|cpp}
pubkey_utils.{h|cpp} -> PublicKeyUtils.{h|cpp}
2023-11-24 22:20:40 +01:00
tomFlowee c9af7cca4a Rename class CPubKey -> PublicKey 2022-07-06 21:56:34 +02:00
tomFlowee 9fa877f425 Rename hashing methods to start with lowercase 2022-05-17 00:46:54 +02:00
tomFlowee fcb648916d Make pubkey follow coding styleguide 2021-04-19 14:48:18 +02:00
tomFlowee 5d750eb736 One less historical check needed so far after making them mandatory 2021-03-12 13:18:31 +01:00
tomFlowee 94ae61132b Promote 'interpreter' to the utils lib.
Being able to parse bitcoin-script is useful for users other than
the hub, using the flowee shared libraries they can now do so.
2021-01-21 15:47:46 +01:00